From patchwork Mon Mar 16 07:48:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenqiwu X-Patchwork-Id: 11439857 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 B071D913 for ; Mon, 16 Mar 2020 07:48:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6957320679 for ; Mon, 16 Mar 2020 07:48:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bcm0s21U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6957320679 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 9DC796B0003; Mon, 16 Mar 2020 03:48:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 98DA16B0005; Mon, 16 Mar 2020 03:48:29 -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 87B146B0007; Mon, 16 Mar 2020 03:48:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6E27D6B0003 for ; Mon, 16 Mar 2020 03:48:29 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 484948248047 for ; Mon, 16 Mar 2020 07:48:29 +0000 (UTC) X-FDA: 76600447938.15.toy79_8446348e61632 X-Spam-Summary: 2,0,0,ba02f2c8dbf8e737,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:6119: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.65:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.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: toy79_8446348e61632 X-Filterd-Recvd-Size: 3933 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Mon, 16 Mar 2020 07:48:28 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id ca13so8185056pjb.2 for ; Mon, 16 Mar 2020 00:48:28 -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=J8oTM+vcGvGmWWC7jWqEDDOb677KhAGKK2PahEFFx9g=; b=bcm0s21UgFgYLtO3kbA0LcZAbnOP/E0pb0rjiJ9VbhJylrW5z+PKcVdwK8bG5i7eJV ahBUkPsesSEdtc0grg3ZyVTM3NCvd3ehuHSMfNl4cdw3j6G3Zo5UcTHbUAU6wdVaX+0j kNOvuWmCe/SieaK1K+J1gq9IcXcGAk906UbFWyX8c+EtWVF7NEm5fzILrnbaT++UfTet 8YQ3zHuMxG3g/TnSR1zfnsGO0bXnHnrwLL5dYQ3ddFcz5evaN7Z1q51IVPSZeEg578Zk xvUYcQzTywhiRXYHJwl9K198GaCmNClhovgng5gyQ2m2ivQ/dEDXMBpQDHONm79fCwbP hmXg== 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=J8oTM+vcGvGmWWC7jWqEDDOb677KhAGKK2PahEFFx9g=; b=Xz/oNMqodwsM5I9BnIM4gNnHCek2YigWs1IW1yLK4eRvSgEyEV98krkxBBDcEcKLJK 0t/3ZJCCedypMQgqw32CIReicAAOEy5CRVRj77gKaDgqHcmdAhsctr8HSks4llaR9AbT iYA7pB+Nz26TjVxpM67KiR6ycNkaG5hrZq+ZNRhVdzEQ23M5X5RRAM1lhlamjOOaiv66 jloRKFqSmPKUs8vdzIkIFR/4dJgiwtdApsrMR3n4LYAbzkSYqwEuMqslHyqDgZSVlyAu PZPyBBHK6eGq4LyQuBpjDuu7lgOQ5R4otTQ1Hlr2y953ncAaRFy6v7pObxUndMBLWJ85 Sgcw== X-Gm-Message-State: ANhLgQ0MGgQWbB2om1l3JQQE7VwEGzBqNMUYY1aIuF6zZQzzXtiVmZzh 1pXgX9dIiPPyWF6erivlfSo= X-Google-Smtp-Source: ADFU+vudcIx3zWuTepywvHB3Wxp50a+B13F6y7oaWIR6oAylAA8Cd91dQAx6VX8zzd/RUEoQYmAlew== X-Received: by 2002:a17:90a:36c7:: with SMTP id t65mr23316762pjb.182.1584344907267; Mon, 16 Mar 2020 00:48:27 -0700 (PDT) Received: from localhost ([43.224.245.179]) by smtp.gmail.com with ESMTPSA id w205sm9900803pfc.75.2020.03.16.00.48.25 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 16 Mar 2020 00:48:26 -0700 (PDT) From: qiwuchen55@gmail.com To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, chenqiwu Subject: [PATCH] mm/sparse: remove duplicated pfn_to_section_nr() Date: Mon, 16 Mar 2020 15:48:20 +0800 Message-Id: <1584344900-16593-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 --- 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..c2b7868 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 (pfn >= 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)