From patchwork Tue Mar 11 00:46:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 14010890 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE264C282DE for ; Tue, 11 Mar 2025 00:48:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 771F9280003; Mon, 10 Mar 2025 20:48:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74A11280001; Mon, 10 Mar 2025 20:48:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6119B280003; Mon, 10 Mar 2025 20:48:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 42AC9280001 for ; Mon, 10 Mar 2025 20:48:02 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7C7EE121661 for ; Tue, 11 Mar 2025 00:48:03 +0000 (UTC) X-FDA: 83207433246.19.C6071DB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf23.hostedemail.com (Postfix) with ESMTP id A8EE7140008 for ; Tue, 11 Mar 2025 00:48:01 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MrnzwuGv; spf=pass (imf23.hostedemail.com: domain of gshan@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=gshan@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741654081; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Hgrxg5qAPOx7K2ONkn1MCXNcggxF5k+2r/MNYL/OtKg=; b=7bJBxK4mFictYKAw4R68faIlQcmZJ6Oy+fnJRUnxA6dezszJ78t5x/vArokSXyVolk6dlA mDBxFFNRGv7TGdDTfImFr8hbAKA2dXBEZdyoveKyNoCxFxY3ZPtWv+hvk74MXEkj9/u4VM ND2SmPSqaUQZEgXh8M7yrqhs+LGeJ+w= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MrnzwuGv; spf=pass (imf23.hostedemail.com: domain of gshan@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=gshan@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741654081; a=rsa-sha256; cv=none; b=BhC2Vx+D+ad7vqaFR7+2fVCsnDr5m1YRAb8maHtex+WQXic/VUiF4fycd7XDwwcI33IlYO /14nyvWk7EvcfIm3eumXb4Pg9mq8ZLleQqbrSD9Hu/nkRiG3PYopu4jZI0RxqqtRK5zonE tF9Lv7CDBGjnaxe22GFRgXSpPH+ikVw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741654081; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Hgrxg5qAPOx7K2ONkn1MCXNcggxF5k+2r/MNYL/OtKg=; b=MrnzwuGva+Q7pe8/JHVRQk00PGnC4qqqQzFQ+AZnXWsYM0Jn6Bgp/gQOKKXgxmp4zkry/D SB/YxrFBqbNEusXsj5dDrmm2arvAdsYg/klgtUen/jRwyRTrVpSxjP9ZR5MU9q9hv7wGOA Lg4NheBahvTvdTx8p8T7IpNIde7DHpk= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-491-eQAVUnAIOIizaZ8uLe3bPw-1; Mon, 10 Mar 2025 20:47:56 -0400 X-MC-Unique: eQAVUnAIOIizaZ8uLe3bPw-1 X-Mimecast-MFC-AGG-ID: eQAVUnAIOIizaZ8uLe3bPw_1741654075 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C90271956048; Tue, 11 Mar 2025 00:47:54 +0000 (UTC) Received: from gshan-thinkpadx1nanogen2.remote.csb (unknown [10.64.136.79]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 611301828A8A; Tue, 11 Mar 2025 00:47:48 +0000 (UTC) From: Gavin Shan To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, akpm@linux-foundation.org, shan.gavin@gmail.com Subject: [PATCH v2 1/3] mm/sparse: Expose for_each_present_section_nr() Date: Tue, 11 Mar 2025 10:46:55 +1000 Message-ID: <20250311004657.82985-2-gshan@redhat.com> In-Reply-To: <20250311004657.82985-1-gshan@redhat.com> References: <20250311004657.82985-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Rspam-User: X-Rspamd-Queue-Id: A8EE7140008 X-Rspamd-Server: rspam03 X-Stat-Signature: pkcmwze49m9txdn76nt8igd19s64ysyc X-HE-Tag: 1741654081-431117 X-HE-Meta: U2FsdGVkX19tIVtXQs9tBpjppi7vjKYFDdbBBfT/kF/nofADnR72sMn7vXKYl1iVD3JSDgcrnXShj9AcDK+tx1xfe6geZzqXJdkxnFeUkIJHNCNvpxuopLOjOmGIVRCMNq99Faw1dDTEUIdYjLZ3YPx7SW5rR4Bz/OUlanMLrFsuornjuhsVaKFRfTev1f4LL6BWja2E8yluoHwxSnURgESO1IHwATEJ3vWtoprpwqOYgyVsQjBDMMpQD7D5qJoD0DhVlXqstz4MHjQx4aEOqfC246JMWW+NaGq3VJGBtBDLEAKP02eA23XMPHwllApan3MRpyw4bbuBnNVu+Mf0/JtLV/g8VhxaRlZcKWP5yWyHnF7X59X3aCRuMQobxIlkDo4XU17zkLm6Zf74kLR7t3hw80rzScwVWS1xG6T/ZVReQR9zyzRuGCo22rEnfLDakonxF7hqew7SdJI35VCX0q+bpCNg6+HHmpbbiMhGC8gmFaNpW7/Wn3rM2fUq3VGR/T4MI0MiDjGfQD4kOogoRrft05TFSWJT0X1SNHayDxhC9ZNUh7NazJE+Dl+RME571x5nGzdArsWGHGXemkMUIUSnyIyIExI3+Fwd9WPsRoQYoIJj9qcrp32KFPZqCG/ns8n+YGPRdCz3HLQA6mDQ7nkVYr+q/A6ETKjkVb3wZH3ndQ87DEJjl81e82/dolwxKHAU48lI3y+iKPssG2x3tdnMrL5owY50e9UyJXQQpVCy9ZoTTsunaJXAJBCGF6RmFQ98xN3JSAOL6nOr07YYrFw6IsGJqRp/560vJTCxBo20PfZ2MnwXWilL+qI/YLfVon38a+o7nZQ9CXNMK2lW3E1B23BFl/roBxe+QtlK4KpZAYBnjpnbtEQU8meUTmoHZu5mLmWK7zMbTqSDDYMyiQWhwSDBGJBVHQp9P+hpz6ny6PF2EGM93yhHmt5lpsdQhd/j1QxltVz3TVcejFt MZCk76iV +hCJ0O9MZQX11TjPWvRuhd8HCIy3EIvsqMujMerCzv1921sppyk15ixnaZ7HjfVoCWHqIij6VFeDGzqLxP3gKI+mQH6726T2a3K2umA/zPtO27mMgzVFfvCnMiW40gbRUWK9cQovsNyIhpsxqKirdq0Wpwx+yMYzOqr07HBwzIN0T3LqLl2bnrVuTXGycQaj5udiQODo+MjuCyi3LsF7pS4Hzx/5CSX68J7m2uHX6Zxp2gdTQC6Nk8jp/JfMksVunYMbjXOuraTy/T6uaS5yGYE25SR81qQ2QhZTyMJFUiV6KkWL8Oi1nwqGnUUqwpC4OfuXbmJoNWu4PALbMnWdhT0ayNixUI/lwuHqSXpzjfzF28jlNQSfzNVqZdkxKxkD+EBJEGE+4O3pfGPHLDRM0gUDdP4stx30ixoDGuAL2MMITOCo+vlE7MuZZXp+2zXZZDbX/1Mnn4vmHqmYKUIYGqrqhEy2J4078uRS3 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: List-Subscribe: List-Unsubscribe: Expose for_each_present_section_nr() to be used by drivers/base/memory in the next patch. No functional changes intended. Signed-off-by: Gavin Shan --- include/linux/mmzone.h | 5 +++++ mm/sparse.c | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 9540b41894da..0f6646da34d7 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -2097,6 +2097,11 @@ static inline unsigned long next_present_section_nr(unsigned long section_nr) return -1; } +#define for_each_present_section_nr(start, section_nr) \ + for (section_nr = next_present_section_nr(start - 1); \ + section_nr != -1; \ + section_nr = next_present_section_nr(section_nr)) + /* * These are _only_ used during initialisation, therefore they * can use __initdata ... They could have names to indicate diff --git a/mm/sparse.c b/mm/sparse.c index 133b033d0cba..fe77d523ab8d 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -170,11 +170,6 @@ static void __section_mark_present(struct mem_section *ms, ms->section_mem_map |= SECTION_MARKED_PRESENT; } -#define for_each_present_section_nr(start, section_nr) \ - for (section_nr = next_present_section_nr(start-1); \ - section_nr != -1; \ - section_nr = next_present_section_nr(section_nr)) - static inline unsigned long first_present_section_nr(void) { return next_present_section_nr(-1);