From patchwork Mon Mar 16 07:59:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenqiwu X-Patchwork-Id: 11439869 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 1F8E390 for ; Mon, 16 Mar 2020 07:59:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D823F2071C for ; Mon, 16 Mar 2020 07:59:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fVDPsV2+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D823F2071C 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 873996B0003; Mon, 16 Mar 2020 03:59:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7FD7A6B0005; Mon, 16 Mar 2020 03:59:53 -0400 (EDT) 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 6ED0A6B0007; Mon, 16 Mar 2020 03:59:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0177.hostedemail.com [216.40.44.177]) by kanga.kvack.org (Postfix) with ESMTP id 531D86B0003 for ; Mon, 16 Mar 2020 03:59:53 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 44D73181AEF31 for ; Mon, 16 Mar 2020 07:59:53 +0000 (UTC) X-FDA: 76600476666.22.error22_564863a848129 X-Spam-Summary: 2,0,0,5d90715feeb6b7b6,d41d8cd98f00b204,qiwuchen55@gmail.com,,RULES_HIT:41:355:379:541:800:960:968:973:988:989:1260:1345:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3866:3867:3868:3870:4321:4419:5007:6261:6653:7576:9413:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12895:12986:13069:13146:13230:13311:13357:14096:14181:14384:14394:14721:21063:21080:21444:21451:21627:21666:21990:30012:30054,0,RBL:209.85.216.67:@gmail.com:.lbl8.mailshell.net-62.50.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:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: error22_564863a848129 X-Filterd-Recvd-Size: 3943 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Mon, 16 Mar 2020 07:59:52 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id hg10so3914266pjb.1 for ; Mon, 16 Mar 2020 00:59:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=VjoQPk5sxxaR9u22JdtAtxKeUNB6cKV7hNZxaOhndew=; b=fVDPsV2+ohyCbZ+BJObwbX2+ejIbMslKVZdT7Dd6dvuimr6vIKSu0YXJYfCWTuttBW Ncm5lhDohmbjODRdul1LlzbBjY1heV8WA1Ehc9v2IjgC3957QjIEN3iHg7RFtTTd9xH0 w43hKh/pjgplwtDcEOCVQshDFahVQsdp05Po4VLZOGJxuKjom4Jcxaydx98KcXIfjkQh MN19546DpFYbIUABjFa+uNes5Q5z0Zkn13HkJQ623s5/Thj4WCKzMlkaEGL0Ithld/IO 9vH/gXRoxe4SalUT5iGMFOvVJCWKzBAKEGFFeoy4e71bmd7W5K+I+1xvJgpAl/k8SWXi hiWw== 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=VjoQPk5sxxaR9u22JdtAtxKeUNB6cKV7hNZxaOhndew=; b=C53z7TsXRpB7RNE3Bb0czLo8uB/wbfev7waYWE9bZIZBOQ1pJn3qQm9Qufe6qCTiER 6rxwdPCLL7ZOPMNJtVzOAlvzWQ0Ycq9Tu7eZqjgOlRRC3Or0j1IECewgdc4KkbHbdqya omHKwgxiiO3OtXP2SahpZNuwxNo4DIY0lvl3oCaeHzJCKrf6GbWQgGmhj87U5h7vZPFR LZyLBqKQlGVsiR7s1suNiCuR0zE/SccDxfZaOHMbxH7ZIBuQhngy6MqUNA9+HhKGoVJg oyZ2t/BI69qRMKHZTsxTaJ6y4qcNHoCn4UmDW3nB+Ec6O+77A1/LLqnNtZ0NUiQcVc/M 75bw== X-Gm-Message-State: ANhLgQ052uquxhr3VEtIP7ypCNAVr/YT5etru07Mm2ic615GvoU+KC8P uWEaovSoYgLyKJANULizZHs= X-Google-Smtp-Source: ADFU+vvs0P7lXVGFfpe3z+roCy+Vb+EMf0bKFyTxGccxhAi6L7r4N89jpPkhx6yADdxFdTpYusKOYA== X-Received: by 2002:a17:902:778e:: with SMTP id o14mr23549416pll.183.1584345591524; Mon, 16 Mar 2020 00:59:51 -0700 (PDT) Received: from localhost ([43.224.245.179]) by smtp.gmail.com with ESMTPSA id o66sm52748046pfb.93.2020.03.16.00.59.50 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 16 Mar 2020 00:59:51 -0700 (PDT) From: qiwuchen55@gmail.com To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, chenqiwu Subject: [RESEND PATCH] mm/sparse: remove duplicated pfn_to_section_nr() Date: Mon, 16 Mar 2020 15:59:47 +0800 Message-Id: <1584345587-16769-1-git-send-email-qiwuchen55@gmail.com> X-Mailer: git-send-email 1.9.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: From: chenqiwu Remove duplicated pfn_to_section_nr() in pfn_valid() and pfn_present() to increase executing efficiency of code. Signed-off-by: chenqiwu Acked-by: Pankaj Gupta --- include/linux/mmzone.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 462f687..35763b5 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1358,10 +1358,11 @@ static inline int pfn_section_valid(struct mem_section *ms, unsigned long pfn) static inline int pfn_valid(unsigned long pfn) { struct mem_section *ms; + unsigned long sec_nr = pfn_to_section_nr(pfn); - if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS) + if (sec_nr >= NR_MEM_SECTIONS) return 0; - ms = __nr_to_section(pfn_to_section_nr(pfn)); + ms = __nr_to_section(sec_nr); if (!valid_section(ms)) return 0; /* @@ -1374,9 +1375,11 @@ static inline int pfn_valid(unsigned long pfn) static inline int pfn_present(unsigned long pfn) { - if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS) + unsigned long sec_nr = pfn_to_section_nr(pfn); + + if (sec_nr >= NR_MEM_SECTIONS) return 0; - return present_section(__nr_to_section(pfn_to_section_nr(pfn))); + return present_section(__nr_to_section(sec_nr)); } static inline unsigned long next_present_section_nr(unsigned long section_nr)