Message ID | 9fc85cce8908938f4fd75ff50bc981c073779aa5.1682229876.git.baolin.wang@linux.alibaba.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2136046vqo; Sun, 23 Apr 2023 04:04:15 -0700 (PDT) X-Google-Smtp-Source: AKy350ayNbhBmt6W8Lu2NCY1o9vvjl61P55IQfIs/a2d2HSk138VHurWv8bK3pgvcmeKWMKppRQl X-Received: by 2002:a05:6a20:d489:b0:d9:f086:e756 with SMTP id im9-20020a056a20d48900b000d9f086e756mr11051903pzb.39.1682247855270; Sun, 23 Apr 2023 04:04:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682247855; cv=none; d=google.com; s=arc-20160816; b=GqxfFFaTYGmvsyRLdxZHUIqHBSNFjdADrYx3IEm8YA9UJhD6/NmhxEOO3JRERSeHEj OmiM99TGB6vBFk51eagFGIxi46IOSSas4CWyPWDtoHNJPZcj1o5oCaAlt3rojy0rw31p 2XZn0Hu8ed+FnqDJGTAwK9Z3q0flbt//mVHClFWzU0lviRIYNb2PE6i61Cde83i6wAE0 Oz0CYChTOkZLDVC7j+Qj786Hh1IVw4zSTrXG9ySplzPJVj7VENqAU6VmD15upuTJgf7t 1CNYfrAVojs6myY+OJECvF1CGJnUjPjVhlptjO4o21tkwpsf16Ea7wW950yK+02hvFQ5 M/FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=64GR5p2l4Z02IYdj0MM9eN1KhH4FGFdVF8hApvUlZkI=; b=JrRPL85B5J9xp6rBiVN/YqXwZgITamnaS5ixn3qH+cS5FYoyn9MyO7KiZHYKrSXF98 9ABSxczz+t7zoQeaPpyPnQTfGLNBb+WxzbNe/dGIKIkn9HWw0fCXPq0YrCk5WYGgjSUH r6Xrp684j4luT/cxxwOEQnJkPXz1calNln2wfHLj46lan4r4ZKXxzLevl7SIZ27G6jJy ERotAvt8lJy0sp6VPoih8nB2T3PGMED300g3YmYI8nb2SHgOz2iP6kWgJN6vf5Lh6PdU Xb7/SBE+VE5PgkFFjTj9gIO301Fq7euAG8DdYYrMswgyIrQwZZ3YOcH7G5kcP7Pjzbei KyxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a28-20020aa78e9c000000b0063b7c4435bcsi9069408pfr.50.2023.04.23.04.04.00; Sun, 23 Apr 2023 04:04:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229523AbjDWLAc (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Sun, 23 Apr 2023 07:00:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229595AbjDWLAH (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 23 Apr 2023 07:00:07 -0400 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 041D11997 for <linux-kernel@vger.kernel.org>; Sun, 23 Apr 2023 03:59:42 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0VgjkYeH_1682247579; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VgjkYeH_1682247579) by smtp.aliyun-inc.com; Sun, 23 Apr 2023 18:59:40 +0800 From: Baolin Wang <baolin.wang@linux.alibaba.com> To: akpm@linux-foundation.org Cc: rppt@kernel.org, ying.huang@intel.com, mgorman@techsingularity.net, vbabka@suse.cz, mhocko@suse.com, david@redhat.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] mm/page_alloc: drop the unnecessary pfn_valid() for start pfn Date: Sun, 23 Apr 2023 18:59:10 +0800 Message-Id: <9fc85cce8908938f4fd75ff50bc981c073779aa5.1682229876.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763964727027523520?= X-GMAIL-MSGID: =?utf-8?q?1763964727027523520?= |
Series |
[v2,1/2] mm/page_alloc: drop the unnecessary pfn_valid() for start pfn
|
|
Commit Message
Baolin Wang
April 23, 2023, 10:59 a.m. UTC
We've already used pfn_to_online_page() for start pfn to make sure it is online and valid, so the pfn_valid() for the start pfn is unnecessary, drop it. Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com> Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: "Huang, Ying" <ying.huang@intel.com> --- Changes from v1: - Collect reviewed tags. Thanks David and Ying. --- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Sun 23-04-23 18:59:10, Baolin Wang wrote: > We've already used pfn_to_online_page() for start pfn to make sure Who is we? I do not see any note explicitly requiring that start_pfn has to be valid for __pageblock_pfn_to_page. > it is online and valid, so the pfn_valid() for the start pfn is > unnecessary, drop it. > > Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com> > Reviewed-by: David Hildenbrand <david@redhat.com> > Reviewed-by: "Huang, Ying" <ying.huang@intel.com> > --- > Changes from v1: > - Collect reviewed tags. Thanks David and Ying. > --- > mm/page_alloc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 9de2a18519a1..6457b64fe562 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -1512,7 +1512,7 @@ struct page *__pageblock_pfn_to_page(unsigned long start_pfn, > /* end_pfn is one past the range we are checking */ > end_pfn--; > > - if (!pfn_valid(start_pfn) || !pfn_valid(end_pfn)) > + if (!pfn_valid(end_pfn)) > return NULL; > > start_page = pfn_to_online_page(start_pfn); > -- > 2.27.0
On 4/24/2023 5:50 PM, Michal Hocko wrote: > On Sun 23-04-23 18:59:10, Baolin Wang wrote: >> We've already used pfn_to_online_page() for start pfn to make sure > > Who is we? I do not see any note explicitly requiring that start_pfn has > to be valid for __pageblock_pfn_to_page. Sorry for confusing, what I mean is the __pageblock_pfn_to_page() function, which has used pfn_to_online_page() for start pfn. So the pfn_valid() in __pageblock_pfn_to_page() for start pfn is unnecessary. I will update the commit log to make it clear. >> it is online and valid, so the pfn_valid() for the start pfn is >> unnecessary, drop it. >> >> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com> >> Reviewed-by: David Hildenbrand <david@redhat.com> >> Reviewed-by: "Huang, Ying" <ying.huang@intel.com> >> --- >> Changes from v1: >> - Collect reviewed tags. Thanks David and Ying. >> --- >> mm/page_alloc.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c >> index 9de2a18519a1..6457b64fe562 100644 >> --- a/mm/page_alloc.c >> +++ b/mm/page_alloc.c >> @@ -1512,7 +1512,7 @@ struct page *__pageblock_pfn_to_page(unsigned long start_pfn, >> /* end_pfn is one past the range we are checking */ >> end_pfn--; >> >> - if (!pfn_valid(start_pfn) || !pfn_valid(end_pfn)) >> + if (!pfn_valid(end_pfn)) >> return NULL; >> >> start_page = pfn_to_online_page(start_pfn); >> -- >> 2.27.0 >
On Mon 24-04-23 18:46:40, Baolin Wang wrote: > > > On 4/24/2023 5:50 PM, Michal Hocko wrote: > > On Sun 23-04-23 18:59:10, Baolin Wang wrote: > > > We've already used pfn_to_online_page() for start pfn to make sure > > > > Who is we? I do not see any note explicitly requiring that start_pfn has > > to be valid for __pageblock_pfn_to_page. > > Sorry for confusing, what I mean is the __pageblock_pfn_to_page() function, > which has used pfn_to_online_page() for start pfn. So the pfn_valid() in > __pageblock_pfn_to_page() for start pfn is unnecessary. > > I will update the commit log to make it clear. Your comment suggested that the check _has_ already been done. Which is not the case. pfn_to_online_page is called later in the function so I guess you should rephrase as following: " __pageblock_pfn_to_page currently performs both pfn_valid check and pfn_to_online_page. The former one is redundant because the latter is a stronger check. Drop pfn_valid. " With that or something going along with that. Feel free to add Acked-by: Michal Hocko <mhocko@suse.com> > > > it is online and valid, so the pfn_valid() for the start pfn is > > > unnecessary, drop it. > > > > > > Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com> > > > Reviewed-by: David Hildenbrand <david@redhat.com> > > > Reviewed-by: "Huang, Ying" <ying.huang@intel.com> > > > --- > > > Changes from v1: > > > - Collect reviewed tags. Thanks David and Ying. > > > --- > > > mm/page_alloc.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > > index 9de2a18519a1..6457b64fe562 100644 > > > --- a/mm/page_alloc.c > > > +++ b/mm/page_alloc.c > > > @@ -1512,7 +1512,7 @@ struct page *__pageblock_pfn_to_page(unsigned long start_pfn, > > > /* end_pfn is one past the range we are checking */ > > > end_pfn--; > > > - if (!pfn_valid(start_pfn) || !pfn_valid(end_pfn)) > > > + if (!pfn_valid(end_pfn)) > > > return NULL; > > > start_page = pfn_to_online_page(start_pfn); > > > -- > > > 2.27.0 > >
On 4/24/2023 6:54 PM, Michal Hocko wrote: > On Mon 24-04-23 18:46:40, Baolin Wang wrote: >> >> >> On 4/24/2023 5:50 PM, Michal Hocko wrote: >>> On Sun 23-04-23 18:59:10, Baolin Wang wrote: >>>> We've already used pfn_to_online_page() for start pfn to make sure >>> >>> Who is we? I do not see any note explicitly requiring that start_pfn has >>> to be valid for __pageblock_pfn_to_page. >> >> Sorry for confusing, what I mean is the __pageblock_pfn_to_page() function, >> which has used pfn_to_online_page() for start pfn. So the pfn_valid() in >> __pageblock_pfn_to_page() for start pfn is unnecessary. >> >> I will update the commit log to make it clear. > > Your comment suggested that the check _has_ already been done. Which is > not the case. pfn_to_online_page is called later in the function so I > guess you should rephrase as following: > > " > __pageblock_pfn_to_page currently performs both pfn_valid check and > pfn_to_online_page. The former one is redundant because the latter is a > stronger check. Drop pfn_valid. > " Yes, will change the commit log. > > With that or something going along with that. Feel free to add > Acked-by: Michal Hocko <mhocko@suse.com> Thanks. >>>> it is online and valid, so the pfn_valid() for the start pfn is >>>> unnecessary, drop it. >>>> >>>> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com> >>>> Reviewed-by: David Hildenbrand <david@redhat.com> >>>> Reviewed-by: "Huang, Ying" <ying.huang@intel.com> >>>> --- >>>> Changes from v1: >>>> - Collect reviewed tags. Thanks David and Ying. >>>> --- >>>> mm/page_alloc.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c >>>> index 9de2a18519a1..6457b64fe562 100644 >>>> --- a/mm/page_alloc.c >>>> +++ b/mm/page_alloc.c >>>> @@ -1512,7 +1512,7 @@ struct page *__pageblock_pfn_to_page(unsigned long start_pfn, >>>> /* end_pfn is one past the range we are checking */ >>>> end_pfn--; >>>> - if (!pfn_valid(start_pfn) || !pfn_valid(end_pfn)) >>>> + if (!pfn_valid(end_pfn)) >>>> return NULL; >>>> start_page = pfn_to_online_page(start_pfn); >>>> -- >>>> 2.27.0 >>> >
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 9de2a18519a1..6457b64fe562 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1512,7 +1512,7 @@ struct page *__pageblock_pfn_to_page(unsigned long start_pfn, /* end_pfn is one past the range we are checking */ end_pfn--; - if (!pfn_valid(start_pfn) || !pfn_valid(end_pfn)) + if (!pfn_valid(end_pfn)) return NULL; start_page = pfn_to_online_page(start_pfn);