From patchwork Thu May 8 14:40:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 29844 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f197.google.com (mail-yk0-f197.google.com [209.85.160.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D4AB4202DD for ; Thu, 8 May 2014 14:40:32 +0000 (UTC) Received: by mail-yk0-f197.google.com with SMTP id 19sf5310909ykq.8 for ; Thu, 08 May 2014 07:40:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=tfRpK9VywAojw8XSxICUZfck9oun8LQXuVowjopcoKA=; b=leucpHIFQDnBRYlwwXRgHzWwR35NV/KW+oH5QKpMBh5MF87xCO1bgbP4G0G6NlNkSq dZZlw9GkvzCaFVRZBxDWSXkjYc26pHGfEp0lOhEroVVR+IyOmeB/nO2HzBoFDFkx2K6a dyt0yP0KUtgXGglb3dlDYRQEsPPYdPHJvQa2YC5U9wIb0PUkuYHhOfYwcATi1Yjsh1qi PFx/YkIA7epaNKSZND3z3EE3By0UGaXEq5r9WxyC9sheKd9BkuXQJPcXKqmih6a2BfNz xbBp2l/R+Py/MDlek1X5fMH5tyB35Es8QNpJJ9sWRiLJEeQrEOWoaCsvsxQzqMNVS35g 9IAA== X-Gm-Message-State: ALoCoQmVVAc2TLOvdiuz92Myz31w5TcHiNje7/xm4zmcILWTHYeivNqMe3hpBq2lh3oV0wv18jio X-Received: by 10.236.92.15 with SMTP id i15mr1604812yhf.8.1399560032490; Thu, 08 May 2014 07:40:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.82.145 with SMTP id h17ls4050330qgd.31.gmail; Thu, 08 May 2014 07:40:32 -0700 (PDT) X-Received: by 10.221.67.67 with SMTP id xt3mr1190747vcb.41.1399560032286; Thu, 08 May 2014 07:40:32 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id fo15si205675vcb.171.2014.05.08.07.40.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 May 2014 07:40:32 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id hu19so404813vcb.34 for ; Thu, 08 May 2014 07:40:32 -0700 (PDT) X-Received: by 10.220.5.129 with SMTP id 1mr1016274vcv.71.1399560032187; Thu, 08 May 2014 07:40:32 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp409991vcb; Thu, 8 May 2014 07:40:31 -0700 (PDT) X-Received: by 10.180.7.227 with SMTP id m3mr3760534wia.59.1399560031369; Thu, 08 May 2014 07:40:31 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id q9si464336wjw.227.2014.05.08.07.40.30 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 08 May 2014 07:40:31 -0700 (PDT) Received-SPF: none (google.com: pm215@archaic.org.uk does not designate permitted sender hosts) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WiPUs-0004x2-08; Thu, 08 May 2014 15:40:30 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Laurent Desnogues Subject: [PATCH] target-arm/helper.c: Don't flush the TLB if SCTLR is rewritten unchanged Date: Thu, 8 May 2014 15:40:29 +0100 Message-Id: <1399560029-19007-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Linux makes a habit of writing the same value to the SCTLR that it already holds. In a sample boot of the kernel to a shell prompt it wrote the SCTLR with the value it already held 325465 times, and wrote different values just 3 times. Skip flushing the TLB if the SCTLR value isn't actually being changed; this speeds up my sample boot by 3-5%. Reported-by: Laurent Desnogues Signed-off-by: Peter Maydell Reviewed-by: Laurent Desnogues --- I believe there are kernel patches in the works to avoid being quite so profligate with SCTLR writes, but there are still a lot of older kernels out in the world, so this is worth having IMHO. target-arm/helper.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/target-arm/helper.c b/target-arm/helper.c index 3be917c..417161e 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -2081,6 +2081,13 @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri, { ARMCPU *cpu = arm_env_get_cpu(env); + if (env->cp15.c1_sys == value) { + /* Skip the TLB flush if nothing actually changed; Linux likes + * to do a lot of pointless SCTLR writes. + */ + return; + } + env->cp15.c1_sys = value; /* ??? Lots of these bits are not implemented. */ /* This may enable/disable the MMU, so do a TLB flush. */