From patchwork Thu Aug 23 13:07:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10573807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 829E15A4 for ; Thu, 23 Aug 2018 13:08:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DAAB2BDD8 for ; Thu, 23 Aug 2018 13:08:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80A8B2C00B; Thu, 23 Aug 2018 13:08:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F34B2BDD8 for ; Thu, 23 Aug 2018 13:08:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12B416B2A35; Thu, 23 Aug 2018 09:08:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 088746B2A36; Thu, 23 Aug 2018 09:08:22 -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 DF7296B2A37; Thu, 23 Aug 2018 09:08:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 958936B2A35 for ; Thu, 23 Aug 2018 09:08:22 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id r20-v6so2883465pgv.20 for ; Thu, 23 Aug 2018 06:08:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=vdC762qOUw0lNwQ8NtRgmdcaQ3KYQZC1JLVRC9JiUic=; b=cQmLKTw56aV4PXRcnp7LzJtPfo1SB5THqtizqY0HQxogPubpqKpNAdYXm18MJvnGkg 15DE7fS8amSRTC7rnhQhvFmY94izEFXJ3JInn4tswuBQ4r29znSvtJv9WvV08QGMiu4r bnwy3AtVZ+Z0sSyUsXPAchuU3nRFC7lXhaYdTP7LlXkwdOxlDjdpxzbPUaah4EkSLvjZ 1beybFuBHVZyn56WTG1sLaycQzxUjz8fLkG+Y0myseQhFCwzPnqyFyBrnDQuXNM01Jde 1RlotoQ1ScRERZp76MeVL0L7kQuu8lrTfbjuB9juxRaEddOA4fHp1H3c4r94R2Hua8DG HUvQ== X-Gm-Message-State: APzg51CshuS7SMYL7dRJ1FkX2BXeORbuO7RQA9rXv4pjZJqkzUeqEzv4 CoUHG9JiKqgMrTepd7MApIwEmAxkJ5iZv6oIvc9GE2Nkn9uZgoB2ShD5nnv4vQ9/PAn0DSe3usT YFjgMbvA+WnJbcTh4dJggOeGnGAZ4MhZWvdQfMMi1VTqdO4ULcXhdUHDf1Ug1WhTN/wX8dk+g8c mWWXMezC5k7csPkPfUW6HsGiN5eJeVt2O4GuwNh6QPKrAWVR0/8LGd8vapUuzmH2N+/FGJYObwS dQGJSqZxSi0k8ZN3HXZRpwJ8tPwkwsl7z3KwwSJ69zA8kUdVUB2ypVyuJBhqOI0a+TzPERcEDy3 3O+hMX5PiyecxSw6DTGtDf3MSlK8fR+ZOtKJhEuPWWAX3WRvAUB3UYa8QVUhteOBWYHONBglmSR / X-Received: by 2002:a62:9e08:: with SMTP id s8-v6mr6713081pfd.23.1535029702292; Thu, 23 Aug 2018 06:08:22 -0700 (PDT) X-Received: by 2002:a62:9e08:: with SMTP id s8-v6mr6713001pfd.23.1535029701239; Thu, 23 Aug 2018 06:08:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535029701; cv=none; d=google.com; s=arc-20160816; b=FGLLAfummaY332KBpjiPTOLAsH4UO3L9jU/7p7gW+Ne6wk/+RNhgXU4vFPhFm2L8MU y5TUQr+X8SSQzmtWTbPRVZqndm5UJ+DANA5mBEqmafFzCKir9brkZPRqSEU5IO9IOfhh C6FY9cMuNkWqmU9fWV/A4ei357ktAQBbMHogdZmQPxugwt5jrGZTjcfS3oaCJ2AMtBjg khcc2k7/Wj8zsgcxeWlLsNF2kTgVv3thqpgpliZyzu40o0z357OuY9L12Q35c8u0zW+w vgLHbBBnnO0dQ78qD0kSARJycJlkp3WQRHJzXQsKi0U+NLhsoptLfeDDZRRZmHLuvLcT EmFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=vdC762qOUw0lNwQ8NtRgmdcaQ3KYQZC1JLVRC9JiUic=; b=wFjLHSeSPZusUKryMV4KINskZEnvgxhwgrHaUb0PHp7FMp89MsNWQMdoNKMNCtsP/G Dl51CLb3T5EZICNJT9UwRXt/19sIpHIC6ZPKCo9oxEu0uEVfYE37JhfnMDXiVqoaJUGv w/D4Y6VmdN1V5DBxjruHZlVa62WONZ2u9MOXErit6nifhqHaF0M2AA0rQKTZw9AMSc+3 K1PlFBGRy6q5uf6EGhmR63TsVcWQh9FnizLwbosXOYjg5/tU38WNNInMhY28lsnCKfYD xQPgvL6zgE5Rswt7JlD5AD6HgH6L34o7alw3O6I/Rivqo4muaJ/ao13k1QSPHq6LAlks b0pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l6Iq0DzM; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id o1-v6sor1394536pfk.89.2018.08.23.06.08.21 for (Google Transport Security); Thu, 23 Aug 2018 06:08:21 -0700 (PDT) Received-SPF: pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l6Iq0DzM; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vdC762qOUw0lNwQ8NtRgmdcaQ3KYQZC1JLVRC9JiUic=; b=l6Iq0DzMokhKtLtJIXZOSbe73JNmsGx+UunFNp4BETth/7Hoh/msgHqmFO+U0yRmpX 3EOu53dW20ZnJ2PmV+2x7dtCF526IHA75kKuweAKyWMFN+8fS6ZQb2XrlcgLsS1moMhk PucSPf+lUP5SCQ4tfqRXKB1e0WxEFV7exYTv+QfdvYiZJ4rspMiTadIyW9P8K0+eb5Hp uGtfQj/EV6Lzg62A5/s5vtSxeptQ0n6cW3Hrmq8EwoaMrNnsDWCMa/JMtQ96aHhDsLs/ sVZV1Px0f0vYcWqq3xw+nPkMfb2ZMqxxCgZglWDw1sX7dPNiGBbe3EWAqSak4Br+9ltj JEWA== X-Google-Smtp-Source: AA+uWPzjzUNTxvETEwHIfUZbjgJN47Ud1BEknUWBEKlMcFKfO6+uBHtUdL8r0tlWMFAnA+CabGnDLw== X-Received: by 2002:a62:d113:: with SMTP id z19-v6mr62056329pfg.98.1535029701013; Thu, 23 Aug 2018 06:08:21 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id i26-v6sm6381736pfo.107.2018.08.23.06.08.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 06:08:20 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org, mhocko@suse.com, rientjes@google.com Cc: linux-mm@kvack.org, kirill.shutemov@linux.intel.com, bob.picco@hp.com, Wei Yang Subject: [PATCH 3/3] mm/sparse: use __highest_present_section_nr as the boundary for pfn check Date: Thu, 23 Aug 2018 21:07:32 +0800 Message-Id: <20180823130732.9489-4-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180823130732.9489-1-richard.weiyang@gmail.com> References: <20180823130732.9489-1-richard.weiyang@gmail.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: X-Virus-Scanned: ClamAV using ClamSMTP And it is known, __highest_present_section_nr is a more strict boundary than NR_MEM_SECTIONS. This patch uses a __highest_present_section_nr to check a valid pfn. Signed-off-by: Wei Yang --- include/linux/mmzone.h | 4 ++-- mm/sparse.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 33086f86d1a7..5138efde11ae 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1237,7 +1237,7 @@ extern int __highest_present_section_nr; #ifndef CONFIG_HAVE_ARCH_PFN_VALID static inline int pfn_valid(unsigned long pfn) { - if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS) + if (pfn_to_section_nr(pfn) > __highest_present_section_nr) return 0; return valid_section(__nr_to_section(pfn_to_section_nr(pfn))); } @@ -1245,7 +1245,7 @@ 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) + if (pfn_to_section_nr(pfn) > __highest_present_section_nr) return 0; return present_section(__nr_to_section(pfn_to_section_nr(pfn))); } diff --git a/mm/sparse.c b/mm/sparse.c index 90bab7f03757..a9c55c8da11f 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -174,6 +174,7 @@ void __meminit mminit_validate_memmodel_limits(unsigned long *start_pfn, * those loops early. */ int __highest_present_section_nr; +EXPORT_SYMBOL(__highest_present_section_nr); static void section_mark_present(struct mem_section *ms) { int section_nr = __section_nr(ms);