From patchwork Mon Dec 2 08:27:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumanth Korikkar X-Patchwork-Id: 13895599 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 AF6E7E77176 for ; Thu, 5 Dec 2024 15:35:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D2DC6B013F; Thu, 5 Dec 2024 10:19:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2717D6B0137; Thu, 5 Dec 2024 10:19:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6C376B012C; Thu, 5 Dec 2024 10:19:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 62CCF6B0088 for ; Mon, 2 Dec 2024 03:28:08 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DB4918147B for ; Mon, 2 Dec 2024 08:28:07 +0000 (UTC) X-FDA: 82849340868.01.58AB3BE Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf01.hostedemail.com (Postfix) with ESMTP id D983C4000C for ; Mon, 2 Dec 2024 08:27:56 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=BD7l8Og9; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf01.hostedemail.com: domain of sumanthk@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=sumanthk@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733128074; a=rsa-sha256; cv=none; b=q7/7qYOCFdTA3qhnWU4wWo29KS2UrZfdf907S4KXno0akJl/zLbtO8L8Yswp4wxM6opSqy co9Q6Ab9YOV6WyYnUa+2NYp42k44u8ap1LJPUDSSiTMl+i7W7znm3CFOrt3TBNONKzQ2TH W3PVZp4aW3ytYfzVrU3YMVTWLzbhzQA= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=BD7l8Og9; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf01.hostedemail.com: domain of sumanthk@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=sumanthk@linux.ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733128074; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ttEIqKp1gqeMV+LBQOU9I5MsmYSVPQfGPglAO21iWo8=; b=dSoLZtHCiG4tQlGmNSzosBlJsy9nkUbLNI4ndmXJQ2+OFCsX4bSZfpO5ux4LsflRUejfoi gTf31YyEHn2pdhXnlxr8Xd5vWMxxMbEKzHECXUQKc+E98kMvV4qYmSvo9K0yz6E7xFF7gr 9MTHc1SfwfUloo2fRNGb0vGoFX4aHJ0= Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B1EFbRC026106; Mon, 2 Dec 2024 08:28:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=ttEIqKp1gqeMV+LBQ OU9I5MsmYSVPQfGPglAO21iWo8=; b=BD7l8Og9Y6eW5WSxBtuWl651pEWyQg5HX Oc3yuVmGg+fgBQck88JbJ/pi5ZFhK1ElbTvlsfPZe69pAga2FTS8iLZEceKrPKS6 RPsKx8QlIAP8iH5vbuFjH6FUA3BoKRcVFoXnITLN7oo+gfuub1jktFpn6O1V+OE4 xO3Uqgu+ILPAfOj1p0Jm5GqVr0R4EAITC/oOpNOpx7oXxmGkZ7W3SnNfA/JdTA/U pdGQ+RRcrvqU54IxN4Ui6Fqg/lq7bTvGmlqyBbwoSY+gckiAgKMSjzDaHxcax3SU dUypS7RWO9u4+QIzNIdhaNG84Dw0kc/3e1CrKHPfjm0nVDdchY2wA== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 437tbx7c12-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Dec 2024 08:28:04 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4B1J5ZZv017943; Mon, 2 Dec 2024 08:28:04 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 438d1s22jt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Dec 2024 08:28:03 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4B28S0We60424552 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 2 Dec 2024 08:28:00 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C83D20043; Mon, 2 Dec 2024 08:28:00 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EFED20040; Mon, 2 Dec 2024 08:28:00 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 2 Dec 2024 08:28:00 +0000 (GMT) From: Sumanth Korikkar To: David Hildenbrand , linux-mm Cc: Andrew Morton , Oscar Salvador , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , linux-s390 , LKML , Sumanth Korikkar Subject: [RFC PATCH 2/4] mm/memory_hotplug: Add memory block altmap sysfs attribute Date: Mon, 2 Dec 2024 09:27:30 +0100 Message-ID: <20241202082732.3959803-3-sumanthk@linux.ibm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241202082732.3959803-1-sumanthk@linux.ibm.com> References: <20241202082732.3959803-1-sumanthk@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ROhRVQNbGn0edF93JjKxvQRIWzG9HKXD X-Proofpoint-GUID: ROhRVQNbGn0edF93JjKxvQRIWzG9HKXD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 impostorscore=0 mlxscore=0 suspectscore=0 mlxlogscore=761 priorityscore=1501 bulkscore=0 phishscore=0 adultscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412020070 X-Stat-Signature: sf1gxc9iex5asuwuhru3yw5zh7p1gt34 X-Rspam-User: X-Rspamd-Queue-Id: D983C4000C X-Rspamd-Server: rspam08 X-HE-Tag: 1733128076-223112 X-HE-Meta: U2FsdGVkX18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zQ9KG0NedU5JDuwp0Knd3KmtgFEt7yxwdpag4onhEkDaklTCvLVpMT2zRG3fpkaVOdniU4ZSFSDdZhjtLOcvlMhW/eerWCPLq/ziwictrcp4Go60/v2zYwmpsAZ7pXUD2X5KJIT6s1gHNbwdajrGapEchJOKzLKwwysTzBz7T1UNnqqlQhSCGzMyse9pSPPlZGYjgZ+PN65fLPonia8SWXIcmMDx8H/KvQLbXsR1Ut43iWCNXNwtBj8WzD4ZkdXPn/xvHKVfQLg6UQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000009, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Currently memmap_on_memory sysfs attribute can determine if the altmap is supported in the entire system. However, with CONFIG_RUNTIME_MEMORY_CONFIGURATION, user can dynamically add or remove individual memory blocks with/without altmap support. Hence, it is more beneficial to the user, if the altmap support can also be represented per memory block. lsmem output could look like the following: RANGE SIZE STATE BLOCK ALTMAP 0x0000000000000000-0x000000007fffffff 2G online 0-7 0 0x0000000080000000-0x00000001ffffffff 6G online 8-31 0 0x0000000200000000-0x00000002ffffffff 4G offline 32-47 1 Reviewed-by: Gerald Schaefer Signed-off-by: Sumanth Korikkar --- drivers/base/memory.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index f024444b3301..469adc7212fc 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -431,6 +431,14 @@ static ssize_t phys_device_show(struct device *dev, arch_get_memory_phys_device(start_pfn)); } +static ssize_t altmap_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct memory_block *mem = to_memory_block(dev); + + return sysfs_emit(buf, "%u\n", mem->altmap ? 1 : 0); +} + #ifdef CONFIG_MEMORY_HOTREMOVE static int print_allowed_zone(char *buf, int len, int nid, struct memory_group *group, @@ -492,6 +500,7 @@ static DEVICE_ATTR_RO(phys_index); static DEVICE_ATTR_RW(state); static DEVICE_ATTR_RO(phys_device); static DEVICE_ATTR_RO(removable); +static DEVICE_ATTR_RO(altmap); /* * Show the memory block size (shared by all memory blocks). @@ -785,6 +794,7 @@ static struct attribute *memory_memblk_attrs[] = { #ifdef CONFIG_MEMORY_HOTREMOVE &dev_attr_valid_zones.attr, #endif + &dev_attr_altmap.attr, NULL };