Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2044257rdb; Sun, 19 Nov 2023 23:24:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFObkcyoBIwNGH/D1NLiGd1Wy2bgUvsOlmLw8vs87TwF52J5cGa3cERETok9jd+D+lXbMrh X-Received: by 2002:a17:902:f68a:b0:1cf:677d:964d with SMTP id l10-20020a170902f68a00b001cf677d964dmr141890plg.25.1700465067312; Sun, 19 Nov 2023 23:24:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700465067; cv=none; d=google.com; s=arc-20160816; b=C5O59VwY617ET2bhMXZvQSH92pzKC7lDRJ1oK08c+WXNXcufY4+3/lU2e9UF+0WD1N x4gAcOJGIkdIktaBId+eR6sFy/huoJC0wxP8BuuIC0dMd6UaEs2JYGVogIpGX7fPrJ9g XbR7WVgyU7TMa+jveJ+aqvNdGuCE8rK/jCjTz1v/JAfNIgkM0O3shaVrCEyIsMT56S+D bDQ9sd+NJdTaTJJHY42eZ4vEKiMQwLQ8HrWdGQTj/S2cYiMHrITjbY/ZN97yxZqdLEtl /wiPS/cZ4k9jHMk9SO4uOaHXqzMs5a0GokTxYOAdUQOTa3azqrTSq39cp67s1az/p/m4 Ysmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aDeQRku6qF8MgYKu7kDp5/ujjCadBbyKMfJTF6YyagQ=; fh=16z9eSgr+T6wkiFTMo20mXPHGWzPIsCuS8kXeZ8Bzu4=; b=kJr1/Td27pW9BeYuih+jtLPyyFFInGeh2NweEdhJgc2TZY0WIGuybXMpj3PXDgyl74 04GFB73SHpsxMoMlfvvPnA6zBk3Wl9QnvYgjB0cQhC2tH1sckms+QdExr2zgmEmajU/S sTaUA1UaQQh2IlM8BYMsQzz2QO4+/PKD78oE64MPW8o/yEVJZBqg5qgcqNDOjJXZYZhf L4b13FTjwNPena5ow5+SzjahYv6J654kF11xL7LSrl943wt6cpsBnxSpR/MUzJ0XAhZX PzOmN4LkA18sRQ/09TWMMHon219ayDdbP3M4g0VIKnc39IvFrdbutn5QrgWKgsColqrV YWbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Uz1eNN67; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id j14-20020a170902da8e00b001bb9375b349si7745091plx.536.2023.11.19.23.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 23:24:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Uz1eNN67; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4EFF6807C748; Sun, 19 Nov 2023 23:24:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232135AbjKTHXu (ORCPT + 99 others); Mon, 20 Nov 2023 02:23:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbjKTHXr (ORCPT ); Mon, 20 Nov 2023 02:23:47 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0000DAF; Sun, 19 Nov 2023 23:23:43 -0800 (PST) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AK7Fubv009362; Mon, 20 Nov 2023 07:23:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=aDeQRku6qF8MgYKu7kDp5/ujjCadBbyKMfJTF6YyagQ=; b=Uz1eNN67Dn8tXGb2jzNu+Wy7NNjNi4j9HVMtUL8L4hf226TRZqVWbNaq9GG+QjBP7qq3 oAKSZRJAXI3XceOTXP7Yad/2hZYkmVhaaypmMJGyZ/bfymb1ZxDgLiNq8kBq6wOgYl8H NEojattdDuOszlWRXbaaPKVG2l7s27VhekE0dm6meMwycJCf38dlgwzZsCwcVrmuSqSm Xa6WU7L71cSFAYW/EIHpzewKGovJnlnRckDL93EKoV65WEfexIS45sorAPqMrRJR9vta RUbts6oTvkemMNMbqUdk0tQPjy34A41A7l0dn+enc7bDndmMvP8CrbdizUnja5LTXh+z Lw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uf1f75jge-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Nov 2023 07:23:31 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AK7GGeM010484; Mon, 20 Nov 2023 07:23:31 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uf1f75jfs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Nov 2023 07:23:31 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AK7KVQS008740; Mon, 20 Nov 2023 07:23:29 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uf93kfexd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Nov 2023 07:23:29 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AK7NQl242074554 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Nov 2023 07:23:26 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 82EB12004B; Mon, 20 Nov 2023 07:23:26 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3650420043; Mon, 20 Nov 2023 07:23:26 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 20 Nov 2023 07:23:26 +0000 (GMT) From: Sumanth Korikkar To: linux-mm , Andrew Morton , David Hildenbrand Cc: Oscar Salvador , Michal Hocko , "Aneesh Kumar K.V" , Anshuman Khandual , Gerald Schaefer , Alexander Gordeev , Heiko Carstens , Vasily Gorbik , linux-s390 , LKML Subject: [PATCH 3/3] mm: use vmem_altmap code without CONFIG_ZONE_DEVICE Date: Mon, 20 Nov 2023 08:23:17 +0100 Message-Id: <20231120072317.3169630-4-sumanthk@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231120072317.3169630-1-sumanthk@linux.ibm.com> References: <20231120072317.3169630-1-sumanthk@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: fOcwcO2GdxtHgWM1gb_XUVRYNsl-Xv3S X-Proofpoint-ORIG-GUID: giaqMMErEImI2rd7aVgq2i-gi426kzpD Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-20_05,2023-11-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 mlxlogscore=671 priorityscore=1501 lowpriorityscore=0 clxscore=1015 phishscore=0 mlxscore=0 spamscore=0 bulkscore=0 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311200047 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 19 Nov 2023 23:24:23 -0800 (PST) vmem_altmap_free() and vmem_altmap_offset() could be utlized without CONFIG_ZONE_DEVICE enabled. For example, mm/memory_hotplug.c:__add_pages() relies on that. The altmap is no longer restricted to ZONE_DEVICE handling, but instead depends on CONFIG_SPARSEMEM_VMEMMAP. When CONFIG_SPARSEMEM_VMEMMAP is disabled, these functions are defined as inline stubs, ensuring compatibility with configurations that do not use sparsemem vmemmap. Without it, lkp reported the following: ld: arch/x86/mm/init_64.o: in function `remove_pagetable': init_64.c:(.meminit.text+0xfc7): undefined reference to `vmem_altmap_free' Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202311180545.VeyRXEDq-lkp@intel.com/ Reviewed-by: Gerald Schaefer Signed-off-by: Sumanth Korikkar --- include/linux/memremap.h | 12 ------------ include/linux/mm.h | 15 +++++++++++++++ mm/memremap.c | 14 +------------- mm/sparse-vmemmap.c | 13 +++++++++++++ 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 1314d9c5f05b..744c830f4b13 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -196,8 +196,6 @@ struct dev_pagemap *get_dev_pagemap(unsigned long pfn, struct dev_pagemap *pgmap); bool pgmap_pfn_valid(struct dev_pagemap *pgmap, unsigned long pfn); -unsigned long vmem_altmap_offset(struct vmem_altmap *altmap); -void vmem_altmap_free(struct vmem_altmap *altmap, unsigned long nr_pfns); unsigned long memremap_compat_align(void); #else static inline void *devm_memremap_pages(struct device *dev, @@ -228,16 +226,6 @@ static inline bool pgmap_pfn_valid(struct dev_pagemap *pgmap, unsigned long pfn) return false; } -static inline unsigned long vmem_altmap_offset(struct vmem_altmap *altmap) -{ - return 0; -} - -static inline void vmem_altmap_free(struct vmem_altmap *altmap, - unsigned long nr_pfns) -{ -} - /* when memremap_pages() is disabled all archs can remap a single page */ static inline unsigned long memremap_compat_align(void) { diff --git a/include/linux/mm.h b/include/linux/mm.h index bf5d0b1b16f4..a90f939d5d57 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3786,6 +3786,21 @@ void vmemmap_free(unsigned long start, unsigned long end, struct vmem_altmap *altmap); #endif +#ifdef CONFIG_SPARSEMEM_VMEMMAP +unsigned long vmem_altmap_offset(struct vmem_altmap *altmap); +void vmem_altmap_free(struct vmem_altmap *altmap, unsigned long nr_pfns); +#else +static inline unsigned long vmem_altmap_offset(struct vmem_altmap *altmap) +{ + return 0; +} + +static inline void vmem_altmap_free(struct vmem_altmap *altmap, + unsigned long nr_pfns) +{ +} +#endif + #define VMEMMAP_RESERVE_NR 2 #ifdef CONFIG_ARCH_WANT_OPTIMIZE_DAX_VMEMMAP static inline bool __vmemmap_can_optimize(struct vmem_altmap *altmap, diff --git a/mm/memremap.c b/mm/memremap.c index bee85560a243..9531faa92a7c 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -422,19 +423,6 @@ void devm_memunmap_pages(struct device *dev, struct dev_pagemap *pgmap) } EXPORT_SYMBOL_GPL(devm_memunmap_pages); -unsigned long vmem_altmap_offset(struct vmem_altmap *altmap) -{ - /* number of pfns from base where pfn_to_page() is valid */ - if (altmap) - return altmap->reserve + altmap->free; - return 0; -} - -void vmem_altmap_free(struct vmem_altmap *altmap, unsigned long nr_pfns) -{ - altmap->alloc -= nr_pfns; -} - /** * get_dev_pagemap() - take a new live reference on the dev_pagemap for @pfn * @pfn: page frame number to lookup page_map diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c index a2cbe44c48e1..bd1b9a137f93 100644 --- a/mm/sparse-vmemmap.c +++ b/mm/sparse-vmemmap.c @@ -46,6 +46,19 @@ static void * __ref __earlyonly_bootmem_alloc(int node, MEMBLOCK_ALLOC_ACCESSIBLE, node); } +unsigned long vmem_altmap_offset(struct vmem_altmap *altmap) +{ + /* number of pfns from base where pfn_to_page() is valid */ + if (altmap) + return altmap->reserve + altmap->free; + return 0; +} + +void vmem_altmap_free(struct vmem_altmap *altmap, unsigned long nr_pfns) +{ + altmap->alloc -= nr_pfns; +} + void * __meminit vmemmap_alloc_block(unsigned long size, int node) { /* If the main allocator is up use that, fallback to bootmem. */ -- 2.41.0