From patchwork Thu Nov 28 01:03:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11265057 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9782F109A for ; Thu, 28 Nov 2019 01:03:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 710D6215F1 for ; Thu, 28 Nov 2019 01:03:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 710D6215F1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7C9006B04F2; Wed, 27 Nov 2019 20:03:49 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 751996B04F4; Wed, 27 Nov 2019 20:03:49 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 640B26B04F5; Wed, 27 Nov 2019 20:03:49 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0152.hostedemail.com [216.40.44.152]) by kanga.kvack.org (Postfix) with ESMTP id 494BB6B04F2 for ; Wed, 27 Nov 2019 20:03:49 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 0237F181AEF10 for ; Thu, 28 Nov 2019 01:03:49 +0000 (UTC) X-FDA: 76203888978.26.desk57_41db71e97c43 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,richardw.yang@linux.intel.com,:akpm@linux-foundation.org:kirill.shutemov@linux.intel.com::linux-kernel@vger.kernel.org:richardw.yang@linux.intel.com,RULES_HIT:30003:30054,0,RBL:192.55.52.43:@linux.intel.com:.lbl8.mailshell.net-62.18.0.100 64.95.201.95,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: desk57_41db71e97c43 X-Filterd-Recvd-Size: 1934 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Thu, 28 Nov 2019 01:03:48 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Nov 2019 17:03:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,251,1571727600"; d="scan'208";a="221159840" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga002.jf.intel.com with ESMTP; 27 Nov 2019 17:03:44 -0800 From: Wei Yang To: akpm@linux-foundation.org Cc: kirill.shutemov@linux.intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH 1/2] mm/page_vma_mapped: use PMD_SIZE instead of calculating it Date: Thu, 28 Nov 2019 09:03:20 +0800 Message-Id: <20191128010321.21730-1-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: At this point, we are sure page is PageTransHuge, which means hpage_nr_pages is HPAGE_PMD_NR. This is safe to use PMD_SIZE instead of calculating it. Signed-off-by: Wei Yang --- mm/page_vma_mapped.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index eff4b4520c8d..76e03650a3ab 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -223,7 +223,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) if (pvmw->address >= pvmw->vma->vm_end || pvmw->address >= __vma_address(pvmw->page, pvmw->vma) + - hpage_nr_pages(pvmw->page) * PAGE_SIZE) + PMD_SIZE) return not_found(pvmw); /* Did we cross page table boundary? */ if (pvmw->address % PMD_SIZE == 0) { From patchwork Thu Nov 28 01:03:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11265059 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A810109A for ; Thu, 28 Nov 2019 01:03:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 06A332158A for ; Thu, 28 Nov 2019 01:03:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 06A332158A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 13BB36B04F5; Wed, 27 Nov 2019 20:03:51 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 09BFA6B04F6; Wed, 27 Nov 2019 20:03:50 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2FC96B04F7; Wed, 27 Nov 2019 20:03:50 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0099.hostedemail.com [216.40.44.99]) by kanga.kvack.org (Postfix) with ESMTP id C4AC46B04F5 for ; Wed, 27 Nov 2019 20:03:50 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 75540180AD807 for ; Thu, 28 Nov 2019 01:03:50 +0000 (UTC) X-FDA: 76203889020.17.seat88_45c9f9e0230e X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,richardw.yang@linux.intel.com,:akpm@linux-foundation.org:kirill.shutemov@linux.intel.com::linux-kernel@vger.kernel.org:richardw.yang@linux.intel.com,RULES_HIT:30003:30012:30054:30070,0,RBL:134.134.136.20:@linux.intel.com:.lbl8.mailshell.net-62.18.0.100 64.95.201.95,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: seat88_45c9f9e0230e X-Filterd-Recvd-Size: 2735 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Thu, 28 Nov 2019 01:03:49 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Nov 2019 17:03:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,251,1571727600"; d="scan'208";a="217486814" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga001.fm.intel.com with ESMTP; 27 Nov 2019 17:03:46 -0800 From: Wei Yang To: akpm@linux-foundation.org Cc: kirill.shutemov@linux.intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH 2/2] mm/page_vma_mapped: page table boundary is already guaranteed Date: Thu, 28 Nov 2019 09:03:21 +0800 Message-Id: <20191128010321.21730-2-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191128010321.21730-1-richardw.yang@linux.intel.com> References: <20191128010321.21730-1-richardw.yang@linux.intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The check here is to guarantee pvmw->address iteration is limited in one page table boundary. To be specific, here the address range should be in one PMD_SIZE. If my understanding is correct, this check is already done in the above check: address >= __vma_address(page, vma) + PMD_SIZE The boundary check here seems not necessary. Signed-off-by: Wei Yang --- Test: more than 48 hours kernel build test shows this code is not touched. --- mm/page_vma_mapped.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index 76e03650a3ab..25aada8a1271 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -163,7 +163,6 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) return not_found(pvmw); return true; } -restart: pgd = pgd_offset(mm, pvmw->address); if (!pgd_present(*pgd)) return false; @@ -225,17 +224,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) __vma_address(pvmw->page, pvmw->vma) + PMD_SIZE) return not_found(pvmw); - /* Did we cross page table boundary? */ - if (pvmw->address % PMD_SIZE == 0) { - pte_unmap(pvmw->pte); - if (pvmw->ptl) { - spin_unlock(pvmw->ptl); - pvmw->ptl = NULL; - } - goto restart; - } else { - pvmw->pte++; - } + pvmw->pte++; } while (pte_none(*pvmw->pte)); if (!pvmw->ptl) {