From patchwork Mon Dec 2 08:27:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumanth Korikkar X-Patchwork-Id: 13895593 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 CE631E7716D for ; Thu, 5 Dec 2024 15:34:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B7D106B00D7; Thu, 5 Dec 2024 10:19:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B1B26B0129; Thu, 5 Dec 2024 10:19:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D864C6B00C4; Thu, 5 Dec 2024 10:19:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3BEA36B0088 for ; Mon, 2 Dec 2024 03:28:12 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EC9E7121285 for ; Mon, 2 Dec 2024 08:28:11 +0000 (UTC) X-FDA: 82849341246.10.8D9E79B Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf28.hostedemail.com (Postfix) with ESMTP id D72D8C0007 for ; Mon, 2 Dec 2024 08:27:54 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="Z/qNdeW1"; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf28.hostedemail.com: domain of sumanthk@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=sumanthk@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733128078; a=rsa-sha256; cv=none; b=n76jnaLXBEQ6ARFoi+Lu/WgyVZQ6/B52fTngdp8quhDi0JSyJzraAN7R3TZKBxuAMiVABW MnGR34b/Q7nPr+6YmMQNKf1s1MxU29/HSC0ikP/qUBtihnF8IUlc1PuPE0KglG1q7jsrhN nqfCOb0hB7r17ROwupDM7gpB+WWPTDQ= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="Z/qNdeW1"; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf28.hostedemail.com: domain of sumanthk@linux.ibm.com designates 148.163.156.1 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=1733128078; 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=fxEOWl+pF9H+TPIB1u0RcA7fohWLpjI43sHvTpb8qt4=; b=SeV48I/QbBGTzfWrEzyiXodf+UUNTnN0P5jlWaZlP2xpa/v2oQ3Y9VVpe8Mldd5JvlyZRU 9FCQS/7rWNHpKsq4gVz8oRDNZvS7J4jGxdS0Hfkk61uCXrGzj1fzPwqR0qakD/WWHQeNlM Mr0T3fhEYUWmnAOUN+xkHYno1ORVxJE= Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B1Eb8e8018708; Mon, 2 Dec 2024 08:28:08 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=fxEOWl+pF9H+TPIB1 u0RcA7fohWLpjI43sHvTpb8qt4=; b=Z/qNdeW1gofwxI6550nITDLPJ574ZtZTI vb8pNpjuB0O9C+VyT4vska+5ZeGtWtAhzwh/U8KkRs7zQBA31Yd00QATdNDfwNOI 6jVLqWH7ETWt75IfQiZUhEprKXC+dlHtejp2gQXpfrLF5FLFAo13zlZ8W0cbcKC9 9JJRH5sOFj3zLWmfhM7AQNd5MUmxWe3E1d9SDM29mM992+sTdBZD0dez63AtIuRb ppsvMWDJCGSYHvrtQvFCDFI8zr9fW1Ug/uWEjc7+PLmi01xq3zHL2XJAXGlz+gf2 ZjoNaEWFjYjvZarxPo/yJ1pmU2Na6r+VzCDpoKQiTr6ARigK9202g== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 438kfgc0gb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Dec 2024 08:28:08 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4B28S3Qb005278; Mon, 2 Dec 2024 08:28:07 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 438fr19v96-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Dec 2024 08:28:07 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4B28S3Ct33096240 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 2 Dec 2024 08:28:03 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B840B20043; Mon, 2 Dec 2024 08:28:03 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8A6B920040; Mon, 2 Dec 2024 08:28:03 +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:03 +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 3/4] mm/memory_hotplug: Add max_configurable sysfs read attribute Date: Mon, 2 Dec 2024 09:27:31 +0100 Message-ID: <20241202082732.3959803-4-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: H14ztYqrnCyIw3sYL5zYSqhlBBOCiSmm X-Proofpoint-GUID: H14ztYqrnCyIw3sYL5zYSqhlBBOCiSmm 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 lowpriorityscore=0 spamscore=0 clxscore=1011 malwarescore=0 bulkscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 phishscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412020070 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D72D8C0007 X-Stat-Signature: d917h18doa3fe65y6faqoiohwrukr8jy X-Rspam-User: X-HE-Tag: 1733128074-851036 X-HE-Meta: U2FsdGVkX19In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AsRzv25vlnsBLHNyjaY9inIOW1PMn6ykNyLDPbK8QkQ4nSN40i6+hLayoX95KIxi5hJX61bC7J57cb+9fTIRU2afqNpEjymCSiJ/XuVCacDQkJVY6QP10GNAzYVRPT1jFBvC+4AXNRMCksRmMtCDJ8rdiS/dOjV7vLVHhP76+ovuJ4jkR/WQjoEIj5qKUa69jKMHff0dGjeNN3rTmpFZ44TtUFbo49mstWuCTDZZnzuhXPemUIEgqT5SDyv8MIhskBBX7QQ0QOsU1x0gMrQ== 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: Introduce /sys/devices/system/memory/max_configurable sysfs interface to list maximum number of configurable memory blocks by the architecture. Using this information, lsmem tool could possibly read memory blocks /sys/devices/system/memory/memory[0-9]+ as configured and list rest of the max_configurable count as deconfigured. Arch can define max_configurable by overriding arch_get_memory_max_configurable(). s390 usecase: /sys/devices/system/memory/max_configurable would be online + standby memory blocks count. The max_configurable attribute for s390 is configured in the next patch. x86 possible usecase: max_configurable could be initially set to count of all online memory blocks. Later, max_configurable can be updated whenever there is an acpi event generation for hotplugged memory. Userspace application like lsmem could possibly read memory blocks /sys/devices/system/memory/memory[0-9]+ as configured and rest of the max_configurable count as deconfigured. Reviewed-by: Gerald Schaefer Signed-off-by: Sumanth Korikkar --- drivers/base/memory.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 469adc7212fc..3da83345b570 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -665,6 +665,15 @@ bool __weak arch_validate_memory_range(unsigned long long start, return false; } +/* + * Arch can override the function and return the number of maximum configurable + * memory. + */ +ssize_t __weak arch_get_memory_max_configurable(void) +{ + return 0; +} + /* * Format: * echo config_mode,memoryrange,altmap_mode > @@ -759,6 +768,15 @@ static ssize_t configure_memory_store(struct device *dev, return ret ? ret : count; } static DEVICE_ATTR_WO(configure_memory); + +/* + * Show the maximum number of configurable memory. + */ +static ssize_t max_configurable_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%lu\n", arch_get_memory_max_configurable()); +} +static DEVICE_ATTR_RO(max_configurable); #endif /* CONFIG_RUNTIME_MEMORY_CONFIGURATION */ /* @@ -1075,6 +1093,7 @@ static struct attribute *memory_root_attrs[] = { #endif #ifdef CONFIG_RUNTIME_MEMORY_CONFIGURATION &dev_attr_configure_memory.attr, + &dev_attr_max_configurable.attr, #endif NULL };