From patchwork Fri Jan 10 15:56:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Xinhai X-Patchwork-Id: 11327771 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 E0B656C1 for ; Fri, 10 Jan 2020 15:58:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AD62320842 for ; Fri, 10 Jan 2020 15:58:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kkTEjfzF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD62320842 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EA4648E0006; Fri, 10 Jan 2020 10:58:35 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E54368E0001; Fri, 10 Jan 2020 10:58:35 -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 D69588E0006; Fri, 10 Jan 2020 10:58:35 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0253.hostedemail.com [216.40.44.253]) by kanga.kvack.org (Postfix) with ESMTP id BFA528E0001 for ; Fri, 10 Jan 2020 10:58:35 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 625CF3CFB for ; Fri, 10 Jan 2020 15:58:35 +0000 (UTC) X-FDA: 76362182190.21.skin19_852407720521e X-Spam-Summary: 2,0,0,db4d0fcc8283f2bb,d41d8cd98f00b204,lixinhai.lxh@gmail.com,::kirill.shutemov@linux.intel.com:mike.kravetz@oracle.com:mhocko@kernel.org,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:5007:6119:6120:6261:6653:7514:7875:7901:7903:8957:9413:10004:11026:11232:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12895:13069:13161:13229:13255:13311:13357:14096:14181:14384:14394:14687:14721:21080:21444:21451:21627:21666:21990:30054:30064:30070,0,RBL:209.85.167.65:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: skin19_852407720521e X-Filterd-Recvd-Size: 4491 Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Fri, 10 Jan 2020 15:58:34 +0000 (UTC) Received: by mail-lf1-f65.google.com with SMTP id 9so1834428lfq.10 for ; Fri, 10 Jan 2020 07:58:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=bIh1modZqiuCmU74TsonscwsBdzJuUnJI2FqW10PryE=; b=kkTEjfzFgq/lNI8ZRc0nf1/PrCgKxqsyH6jmN3PNX4Ge/B98CchNg9deOivJTNdVZQ 5Jj9ZiY0U2XEpZI9KkbVDAh9UaIN2kQxTbrBC6drD1ftCbTYuHmMZ9xxfYGH2ZfI0K9t BrJ+vHahZxGkTZHjqfN29D0UmUOQ/cj0AoLo/Y+Sy09lrP8Tfl1YwR1kwN5tM54nj14Y v2WirKQTxDlxXuZ7zUALsqKtLCU4lkkh6cje0+FTUTzXPiU/V5eCBVqRg67L/it8RRyf hlqGco/j5+T4OgiqpN2tark2r5wXn79O2vRBFA7ddDhaRALXcwbcmIS12BL6atWzGp8t HHGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bIh1modZqiuCmU74TsonscwsBdzJuUnJI2FqW10PryE=; b=nG19VAUmU+YUOAM0Mr1ebk8ZZvJGASNSawHs5UOyeEwzWWVFDTBToaSWaVoK6KmA8V bYBQKTVGTyyz6Ct4EsfxEtU/eNzuMjG5xBAsdtA+jUVDqnAus3Y6vC+SDh/1iO9SHv45 PNr3zzm0Gww04iB4BU+tbo+lwLDsD2jLLpJAxpSZba4LjPbectiEpnns38Tvpk8OgsMZ IswjB5JkEwxGHpnJNvcDlliIKz2cd04LlbvKDQdCGyRUcu0GmuuVZNoutqi9NUF8sBKf o4TsmT3tCw347cEsJ+0oaqhqRyLGcpF8nL9ykTkm10tMzFvq5JxYwHbOX2+yHfbYLQiF 4XrA== X-Gm-Message-State: APjAAAWseeY6IDuWKqDHz9vVlybqeCl7HF3jn9ngvoMHJ131nMnyM7hm Io1RHH7nUOhpH4VCQNqugDHFcB4Vrb4= X-Google-Smtp-Source: APXvYqxXXVtMpDI3vSNeltS4fxSbuzuJSLZt37SVn0G11p8wF/KBKQqHbxlRERSktGl8Ew2olWI4BA== X-Received: by 2002:ac2:5468:: with SMTP id e8mr2814434lfn.113.1578671913160; Fri, 10 Jan 2020 07:58:33 -0800 (PST) Received: from localhost.localdomain.localdomain ([131.228.2.21]) by smtp.gmail.com with ESMTPSA id w71sm1458184lff.0.2020.01.10.07.58.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Jan 2020 07:58:32 -0800 (PST) From: Li Xinhai To: linux-mm@kvack.org Cc: "Kirill A. Shutemov" , Mike Kravetz , Michal Hocko Subject: [PATCH v3] mm/page_vma_mapped.c: Explicitly compare pfn for noraml, hugetlbfs and THP page Date: Fri, 10 Jan 2020 15:56:44 +0000 Message-Id: <1578671804-8297-1-git-send-email-lixinhai.lxh@gmail.com> X-Mailer: git-send-email 1.8.3.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: When check_pte, pfn of normal, hugetlbfs and THP page need be compared. The current implementation apply comparison as - normal page: page_pfn <= pfn < page_pfn + 1 - hugetlbfs page: page_pfn <= pfn < page_pfn + HPAGE_PMD_NR - THP page: page_pfn <= pfn < page_pfn + HPAGE_PMD_NR in pfn_in_hpage. For hugetlbfs page, it should be page_pfn == pfn Now, change pfn_in_hpage to pfn_is_match to highlight that comparison is not only for THP and explicitly compare for these cases. Signed-off-by: Li Xinhai Cc: Kirill A. Shutemov Cc: Mike Kravetz Cc: Michal Hocko Acked-by: Kirill A. Shutemov --- mm/page_vma_mapped.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index eff4b45..a286ff7 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -52,12 +52,16 @@ static bool map_pte(struct page_vma_mapped_walk *pvmw) return true; } -static inline bool pfn_in_hpage(struct page *hpage, unsigned long pfn) +static inline bool pfn_is_match(struct page *page, unsigned long pfn) { - unsigned long hpage_pfn = page_to_pfn(hpage); + unsigned long page_pfn = page_to_pfn(page); + + /* normal page and hugetlbfs page */ + if (!PageCompound(page) || PageHuge(page)) + return page_pfn == pfn; /* THP can be referenced by any subpage */ - return pfn >= hpage_pfn && pfn - hpage_pfn < hpage_nr_pages(hpage); + return pfn >= page_pfn && pfn - page_pfn < hpage_nr_pages(page); } /** @@ -108,7 +112,7 @@ static bool check_pte(struct page_vma_mapped_walk *pvmw) pfn = pte_pfn(*pvmw->pte); } - return pfn_in_hpage(pvmw->page, pfn); + return pfn_is_match(pvmw->page, pfn); } /**