Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4530247imm; Mon, 20 Aug 2018 18:19:03 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxXvVFrkZcBvJT5dRJCeFhHPwxvxqbjbhDAEW6mezQtZmQff/Ep0T6aJxlD+l20pVigqq4k X-Received: by 2002:a62:455b:: with SMTP id s88-v6mr50451125pfa.203.1534814343779; Mon, 20 Aug 2018 18:19:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534814343; cv=none; d=google.com; s=arc-20160816; b=FfYZTsIf+49l/a0wRH2hIXL9Hh7SIeBNu6O/uIxClOaHwO4IwYD+GYOvVycF1j+5oU jiqLzDD8QQZJB692paQUik+CjEjvnpAabuVbU76sR9Wzg6Jxq9KywniNjsRE+qlQWlzC xzWUgOflg3iSmAMDV8hsWZD2sy322pOgfTBkqptRbX05osADGhBj+d639BvZSUZIqd7d CtTkkCucCXW3mhZLjfWXCeW1lLAhrSqJpBZjom1T5cWxl58pot2zB7wGZECJn86Lq/Tb ce1JDUW1vSwGKy6OK2YSEwaJIwBxC9CYPhZ8GF1DmA9bG1qdj/ttVaREg5bNoDPW25kz uPZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:arc-authentication-results; bh=QrOt+20hJrsD0m+RasZg5Zmj23oVwSkkPkmCfoAVEHo=; b=try9pTjRJnmIGTluebkb0NdV3OnMiExBKb+WkEr6Tbaz0vzKdJFRsB4Im+ZcYv1g+Z 7aHrreH3DnRHf4AP5MqdWhGb4jCVK6SLW3zLLOf60JqVt72htVBWiORYI7Y2PXxqZCKS teR+2tVKFKFUb7IeYgfGIojX0PW0MDsq79DREGNdEZAIUacigfRe8wv7Wt7axDmdlu10 aa8yh35C8/8RZV0ri7eJ0WZqG9mEPqiPly0B3AIpUcKg6XaGeEU1IIPvcwsuxNMUGtql F1Ga/d5fvuD1aYdMZgWbZnIQskErMeWTdqePXM4a7gDSvx4VCBAJTT50POoOoo6Rs7L1 6X1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5-v6si11170771plr.151.2018.08.20.18.18.39; Mon, 20 Aug 2018 18:19:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726688AbeHUEed (ORCPT + 99 others); Tue, 21 Aug 2018 00:34:33 -0400 Received: from mga07.intel.com ([134.134.136.100]:17761 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725733AbeHUEed (ORCPT ); Tue, 21 Aug 2018 00:34:33 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Aug 2018 18:16:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,267,1531810800"; d="scan'208";a="74359135" Received: from shbuild000.sh.intel.com (HELO byang_ol.sh.intel.com) ([10.239.144.215]) by FMSMGA003.fm.intel.com with ESMTP; 20 Aug 2018 18:16:36 -0700 From: Bin Yang To: tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, peterz@infradead.org, dave.hansen@intel.com, mark.gross@intel.com, bin.yang@intel.com Subject: [PATCH v3 1/5] x86/mm: avoid redundant checking if pgprot has no change Date: Tue, 21 Aug 2018 01:16:22 +0000 Message-Id: <1534814186-37067-2-git-send-email-bin.yang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534814186-37067-1-git-send-email-bin.yang@intel.com> References: <1534814186-37067-1-git-send-email-bin.yang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In try_preserve_large_page(), the check for pgprot_val(new_prot) == pgprot_val(old_port) can definitely be done at first to avoid redundant checking. The approach and some of the comments came from Thomas Gleixner's email example for how to do this Suggested-by: Thomas Gleixner Signed-off-by: Bin Yang --- arch/x86/mm/pageattr.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index 8d6c34f..68613fd 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -629,6 +629,22 @@ try_preserve_large_page(pte_t *kpte, unsigned long address, new_prot = static_protections(req_prot, address, pfn); /* + * The static_protections() is used to check specific protection flags + * for certain areas of memory. The old pgprot should be checked already + * when it was applied before. If it's not, then this is a bug in some + * other code and needs to be fixed there. + * + * If new pgprot is same as old pgprot, return directly without any + * additional checking. The following static_protections() checking is + * pointless if pgprot has no change. It can avoid the redundant + * checking and optimize the performance of large page split checking. + */ + if (pgprot_val(new_prot) == pgprot_val(old_prot)) { + do_split = 0; + goto out_unlock; + } + + /* * We need to check the full range, whether * static_protection() requires a different pgprot for one of * the pages in the range we try to preserve: @@ -642,14 +658,6 @@ try_preserve_large_page(pte_t *kpte, unsigned long address, goto out_unlock; } - /* - * If there are no changes, return. maxpages has been updated - * above: - */ - if (pgprot_val(new_prot) == pgprot_val(old_prot)) { - do_split = 0; - goto out_unlock; - } /* * We need to change the attributes. Check, whether we can -- 2.7.4