From patchwork Thu Aug 5 19:02:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7BC9C4338F for ; Thu, 5 Aug 2021 19:03:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6CDF660EEA for ; Thu, 5 Aug 2021 19:03:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6CDF660EEA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 26C826B007D; Thu, 5 Aug 2021 15:03:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21D696B007E; Thu, 5 Aug 2021 15:03:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0BC4F6B0080; Thu, 5 Aug 2021 15:03:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0027.hostedemail.com [216.40.44.27]) by kanga.kvack.org (Postfix) with ESMTP id D61F36B007E for ; Thu, 5 Aug 2021 15:03:50 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8938A24397 for ; Thu, 5 Aug 2021 19:03:50 +0000 (UTC) X-FDA: 78441951420.40.D5BA46C Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by imf04.hostedemail.com (Postfix) with ESMTP id 472D2500032D for ; Thu, 5 Aug 2021 19:03:50 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id DA32D5C0164; Thu, 5 Aug 2021 15:03:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 05 Aug 2021 15:03:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=from :to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; s=fm1; bh=9b9lnDrs9VQeu LXncQCMIbv4vy0L5khM/fC6d/oCDXA=; b=OU4cZ8TjVlVmleX2bWKetvc5gwm7e jNkfnKbXADKL0QRCPeRLPUYmqPzTKQo8Ahc4VKw6mzAgL3RYFC8kT6o0M71/03G3 dNWLljRBSfrzRzdr+wXOlCQvWuo1CBUn0Aidpzrc9nwwqWHTkR2rhKzvGgqHnpt0 xq3S/JeOJ8/Xfc8HffM2q7IIecv7zOT9T+XhiT+0gysc4Th9IQd+p4cYWVLLqR2u oGQN/VXw1hOirdA59cfd6qTrm9aci5QwnaR6ZDfvpcPYAQkhaaYI02eOiCEn/cTC BDvUB28BUGnrCRTcvcojUZxP9SkoCciZBEneTq4H2RKbsjlpPTjPQA50w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:reply-to:subject :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=9b9lnDrs9VQeuLXncQCMIbv4vy0L5khM/fC6d/oCDXA=; b=dFXQ9IEJ kYsiA0Yev3dse3G5yyI07udU8K/EmFWe9HfhOVwymJigLFi5ru9alNfRIAIzgbU4 6L26WRHprShkvLASjc2/5Rh1PyTwQWDiOLJbGAspghSOmXseuY4g5QE72SF8Jhhr 6jEG8Qkvz70sMciuY1SkVND29uXciqrNXJBBmp39gqjKKHu79Mi/2iWIyo2JGLrb wTqDwSK7I5dOS+V1+/lIKC66qZHkzzbDgN5WQNlWDxzZHcHCZXztN9PXGbIYNo5y Uh6pQy1/7Gl+RZfb812ehwc22PlFwfUZAHPa0115lifI2Ft2UBHDmazpDZWgh/ls oXUQo5jhcb4QFA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgdduvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepieejue dvueduuefhgefhheeiuedvtedvuefgieegveetueeiueehtdegudehfeelnecuvehluhhs thgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvg hnthdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Aug 2021 15:03:49 -0400 (EDT) From: Zi Yan To: David Hildenbrand , linux-mm@kvack.org Cc: Matthew Wilcox , Vlastimil Babka , "Kirill A . Shutemov" , Mike Kravetz , Michal Hocko , John Hubbard , linux-kernel@vger.kernel.org, Zi Yan Subject: [RFC PATCH 06/15] mm: use PAGES_PER_SECTION instead for mem_map_offset/next(). Date: Thu, 5 Aug 2021 15:02:44 -0400 Message-Id: <20210805190253.2795604-7-zi.yan@sent.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210805190253.2795604-1-zi.yan@sent.com> References: <20210805190253.2795604-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 472D2500032D Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=OU4cZ8Tj; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=dFXQ9IEJ; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf04.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.26 as permitted sender) smtp.mailfrom=zi.yan@sent.com X-Stat-Signature: 3cfxi7tjt1g4ac4q4zqhiwy5dr4n54uk X-HE-Tag: 1628190230-647594 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: Zi Yan mem_map is only guaranteed to be virtually contiguous within a section, so mem_map_offset/next() uses pfn to handle mem_map discontiguity. Use PAGES_PER_SECTION instead of MAX_ORDER_NR_PAGES to describe this condition more precisely. Signed-off-by: Zi Yan Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index b1001ebeb286..4ca52c696902 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -485,7 +485,7 @@ static inline void vunmap_range_noflush(unsigned long start, unsigned long end) */ static inline struct page *mem_map_offset(struct page *base, int offset) { - if (unlikely(offset >= MAX_ORDER_NR_PAGES)) + if (unlikely(offset >= PAGES_PER_SECTION)) return nth_page(base, offset); return base + offset; } @@ -497,7 +497,7 @@ static inline struct page *mem_map_offset(struct page *base, int offset) static inline struct page *mem_map_next(struct page *iter, struct page *base, int offset) { - if (unlikely((offset & (MAX_ORDER_NR_PAGES - 1)) == 0)) { + if (unlikely((offset & (PAGES_PER_SECTION - 1)) == 0)) { unsigned long pfn = page_to_pfn(base) + offset; if (!pfn_valid(pfn)) return NULL;