From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E27324B8DC5 for ; Thu, 2 Jul 2026 09:42:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782985332; cv=none; b=r7/0hQUU9iRkss17TpIGdFAFANrbr/BBj9SR/+SKeNsAqZwqRFnb7i1cQ1XMoNz6hlY60cFmp75HuJ0d3w/XzHYsgbew3NnUNy76WLXOwVWwDNW+Git+EAoEDjMtes0v7tRzr59aTKkeDxIbU8LS4hr9ivSpcrO8j2hVqPN6f2E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782985332; c=relaxed/simple; bh=AlQOLMxW/OEpLN/rDIVoWzEj6TfMnjuMHbJB5sevzMQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O2PioKkbG+hgZN6DA23WdrXofOmj2Q54arAsN4bWJjrJ7LZ4HRUMnCtk7kskgYHjQl/BdDgOPGCxHhYGpHf96WJLirbACbwXu3KKtGalNLZ5cPgwGBgzN/ikKkasvTL+WvUk1DBTQ2S1MDZj+qL0H3MV90TZwerUEF7p2Qg9PPU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=KiaMDfN+; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="KiaMDfN+" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-380cda7f00cso811869a91.0 for ; Thu, 02 Jul 2026 02:42:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1782985330; x=1783590130; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X8WOo2/LwuTarNNHReKN/SGCsoN0ybWO9PsEDIa5haM=; b=KiaMDfN+PdS42BLlzbjgbe4h1VG7qJce7N818uqCsSafHBFJ7vgWEJt4DobHPmJBLg S9r1amk8J/GU8VEYm5BJjUPodDSmwn10gGw86+j5QQIyQijxNthkVIEAytyd1et8qgpS QOPugKA/5zMELiFL90GWOlP+38NL6CLcxXLH6SEtaj0WD5dQrI16qvd0uwEmn1Wv03jf y8Fs75Zf5GWkm8KOcgFt3Y54A4vcHUS7KgvG1AY7zfXTtmkbk2kzFOux5whGXURBEQIR WiEUhW+i0IyVLbhhwm1vnMZ1tI6L3mg35Z0uOJRUmYVBCdDz7iY2NfvhaqqZMYO2scUD VbeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782985330; x=1783590130; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=X8WOo2/LwuTarNNHReKN/SGCsoN0ybWO9PsEDIa5haM=; b=l+hOwccJdoz5gzbaI6uVH8X2omyVMFWoH/ZbveGvZUnJ2gZPj3xeDI3GQD0RtCa29o o/lJvlssjFQTAdBb/Zc4NAo/4zJXUzq1SZvql5So0ay4T/SDZaauBAhTNb6/ULYDLvk+ eSN/QAIjJ2k45be/YcYMjrUoKRKNRVZSbVzWrsedcmywtDLSt6RlVRDsm8OlXVT76Iki zY2AJZqJa2C7aGwg9VCCxdAnELk77ositNBC7hLq0zzN2ovjNM60wE8BNWVmU4DWyeNF J/7Wts4Okfqc4M9IoHh8Kh9IwAw2Wt8gF1Vcdd+1YpMJqu0JcBNnE/J6v2UHzXOYHOWN rMyg== X-Forwarded-Encrypted: i=1; AHgh+Rre1Vmu/w6RZRrVgRRWcTaj2mR3b2O+FTjqMb1zNPZlCfbSJrltC3c7zn/BKqukFWAuRc3CzO3SwN+VChE=@vger.kernel.org X-Gm-Message-State: AOJu0YwFMXoxk55Ew0SmZsXrCrtBfi8ZYN6rYdPWmhqEjBNBYvAbHv4S 5eA+w4nQfZR9kbJuBvOYogWXth5R+JDDpwJFeK26niHMAKeyDiMaSRoseSYvouQ5MLw= X-Gm-Gg: AfdE7cn0RUkvbVkmS4RD9yBc5BeSNKLnOro5r6oeNnli22g0ATjlfXuysnl/WI6Voly eiatojQKj1iVhtQhvgdY+5ce/knU1gaGdOTjnGuVldrfOYgrlyqiPIAKwKVDKDqdJCF9OXbWPiE APDVXAB6X+JSe00Oi0pDpt/Rw3TJ8QtOKhIZQVZR0IK/4mCIqXKyN+CSXINWyV6iJP3RUW/RxVG nGma/nJZIg6a5Z9rRlsFek7aIEuEdrMidjfJHsoBawveg5zjWgQTmUUFGBuogMwsIR/yEoR8xnB 8dXZklyqrbQ1w9u/B18BAWT+nzHznN65O+bHNCYzY2JL68cM7pyaBk7slIfAB+27NRei3wS4JD6 lUFpY98nMNpxp2cEBGKiBBzCfXq/wKbuBRH8r3t0TZPL9nGBvxXVvvhq3omiAF3n6UhRDPMqZYN uVtlw2L6lswj05/eeBtIjhTo4U/rDA/wka X-Received: by 2002:a17:90b:1844:b0:37f:c2a9:468 with SMTP id 98e67ed59e1d1-380baa6b497mr4491100a91.18.1782985330023; Thu, 02 Jul 2026 02:42:10 -0700 (PDT) Received: from n232-176-004.byted.org ([36.110.163.98]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ca9a8f8458sm10971085ad.18.2026.07.02.02.42.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2026 02:42:09 -0700 (PDT) From: Muchun Song To: Andrew Morton , Oscar Salvador , David Hildenbrand , linux-mm@kvack.org Cc: Mike Rapoport , Vlastimil Babka , Lorenzo Stoakes , Michal Hocko , linux-kernel@vger.kernel.org, Muchun Song , muchun.song@linux.dev Subject: [PATCH 13/17] mm/sparse: remove section_map_size() Date: Thu, 2 Jul 2026 17:38:17 +0800 Message-ID: <20260702093821.2740183-14-songmuchun@bytedance.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260702093821.2740183-1-songmuchun@bytedance.com> References: <20260702093821.2740183-1-songmuchun@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit section_map_size() no longer provides any shared logic. After the sparse-vmemmap changes, its only remaining user is the !CONFIG_SPARSEMEM_VMEMMAP path in __populate_section_memmap(), which can compute the size inline with PAGE_ALIGN(sizeof(struct page) * PAGES_PER_SECTION). Remove section_map_size() and inline the remaining calculation. Signed-off-by: Muchun Song --- include/linux/mm.h | 1 - mm/sparse.c | 15 ++------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 113f5e2c973b..60cbc106760e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4889,7 +4889,6 @@ static inline void print_vma_addr(char *prefix, unsigned long rip) } #endif -unsigned long section_map_size(void); struct page * __populate_section_memmap(unsigned long pfn, unsigned long nr_pages, int nid, struct vmem_altmap *altmap, struct dev_pagemap *pgmap); diff --git a/mm/sparse.c b/mm/sparse.c index 4e5f6c327043..6ba6f31672cf 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -222,23 +222,12 @@ size_t mem_section_usage_size(void) return sizeof(struct mem_section_usage) + usemap_size(); } -#ifdef CONFIG_SPARSEMEM_VMEMMAP -unsigned long __init section_map_size(void) -{ - return ALIGN(sizeof(struct page) * PAGES_PER_SECTION, PMD_SIZE); -} - -#else -unsigned long __init section_map_size(void) -{ - return PAGE_ALIGN(sizeof(struct page) * PAGES_PER_SECTION); -} - +#ifndef CONFIG_SPARSEMEM_VMEMMAP struct page __init *__populate_section_memmap(unsigned long pfn, unsigned long nr_pages, int nid, struct vmem_altmap *altmap, struct dev_pagemap *pgmap) { - unsigned long size = section_map_size(); + unsigned long size = PAGE_ALIGN(sizeof(struct page) * PAGES_PER_SECTION); return memmap_alloc(size, size, __pa(MAX_DMA_ADDRESS), nid, false); } -- 2.54.0