From mboxrd@z Thu Jan 1 00:00:00 1970 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 04ECCC28B23 for ; Fri, 7 Mar 2025 18:20:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40A806B007B; Fri, 7 Mar 2025 13:20:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 393B56B0082; Fri, 7 Mar 2025 13:20:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20D626B0083; Fri, 7 Mar 2025 13:20:20 -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 ED2186B007B for ; Fri, 7 Mar 2025 13:20:19 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9663CC0D32 for ; Fri, 7 Mar 2025 18:20:20 +0000 (UTC) X-FDA: 83195569800.08.DC4ABB7 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) by imf13.hostedemail.com (Postfix) with ESMTP id BDFDC20005 for ; Fri, 7 Mar 2025 18:20:18 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=aVOqiiQC; spf=pass (imf13.hostedemail.com: domain of joshua.hahnjy@gmail.com designates 209.85.128.178 as permitted sender) smtp.mailfrom=joshua.hahnjy@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741371618; 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=FeJw1/wk13slq8SaTOaUUmP/IYv8V17ltprOZMyg7cg=; b=Jsn3cJs44RozDxGu+J3g+ChX3sYbUwQp+acE34fEIvo7busTC7N5sX/rfcx4CCROBtyV3q mak2e4j8CoUTpf3XaVEyv+xdkI8yq91xq3yrE++Hc5VZBJoO9EyRmK5hZXHS2cs6/6EBxl +BQ7UeDuzA2sBxyzBofqw/O14f4F/rw= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=aVOqiiQC; spf=pass (imf13.hostedemail.com: domain of joshua.hahnjy@gmail.com designates 209.85.128.178 as permitted sender) smtp.mailfrom=joshua.hahnjy@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741371618; a=rsa-sha256; cv=none; b=J2iZLIs10zRg+Ujzq6nBtkGjaiElbDKmnEmSDU/TUScmH+WUojC3miF9kQo3kN5cOXFDuz Frm0TAofaqe+f3kVX/1gPlussqGuwQnIh2mDm95VW7bYpbQ2FD8F94zodU++ax93E6OWPc mk4mgHmdFoX+Elg02ejIxBdCM4URRbs= Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-6f77b9e0a34so18911957b3.2 for ; Fri, 07 Mar 2025 10:20:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741371618; x=1741976418; darn=kvack.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=FeJw1/wk13slq8SaTOaUUmP/IYv8V17ltprOZMyg7cg=; b=aVOqiiQCdik3sbKKTCtIZompkPgRcR49X0/97uILCToIlGgTTc67g0bGCc9ccSflL8 bh9szStmieMMeF83IaFq+YdTPY7IysPgNfBEdx16lf6VAHf8zSQahPOssI1+D14Rw8rR mlln1qas2OwbHUJJv+KCywf5Dbj5iWj5cWvMWoJvIsOvtlJF0GwNs4qUrrPzoocyOMY2 pTsjlhn8O2EynawxzMV2b3FuQbDZ+SHx0SLaGvm3bgir4TC+bKykGJVVpNKcABUe9YGV tLTA5ceeAp6s3pNZES6mhLz7dw/DvsEnlrlxelRvVI44AHiGJzCqT0ztC+5OJr0KDyMr iPHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741371618; x=1741976418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FeJw1/wk13slq8SaTOaUUmP/IYv8V17ltprOZMyg7cg=; b=QilgRK7sCZ+Cbd1fji7oERu+JFTOavesX9CQcco2M31zSJVl/FCB33pkPWo9bthM8T t07Aq7FXo/v0TvRm04+OTwBeea/cnZbtJH/6bG/vdeQvHIXO3lVXuYPXA6xkn5dD9vHM TBi+stbtBtFGgPeLUMdTGX2bfUSozjFHmjN4XF9TR3mFToU8+Gyt3uLa60QK8hQyV5Cm u73pj0wxT+3aiVX4AR21hjVfDmOSHB1Femi9X2GZ4XBQ1zSk1Q9dV8YRfx2mB1Lp9iBY R2FDwedxKNKfPFwWYUyMyxa50DWcfSQy9r1jM9PEzEHRb//rXxqpugw5QEz74ABDUMv4 ckSg== X-Forwarded-Encrypted: i=1; AJvYcCXIFpep8mVhPyea1OdN69YNzWCwokv54c3xN+6cSAJoPaVNS66hBqmx9n/8x7G3iKtfKJLSq7KixQ==@kvack.org X-Gm-Message-State: AOJu0YzMe8RuA7NVgjW0fsE0O2OUZutv+/NvtO2Z/p7FFUmSN8XfRh7O 1ETk+aQbzYwUkFxBgTF4aeuxGSGW38L/sHhkaalAXgiqEabEx5Re X-Gm-Gg: ASbGncsqX1w5Msyc9KyxDlkuB3nyDbF2Zm7jQNVGMk8hGgs45XxdeLBxS8g9e5NUSpB dvyJNlEBpiI/hHzFa2VPgwJ/dUf0u9pZq/UIbs7E2f+vrbrWv16i+vMns6gOPFkfJR8VhVSc06g 68QI9oOQwhyckJQDGrspf8bmGqVo6naXzCBYCd11KoF4aePys7GZk3qw5C7qQDbW5NoE5Rv2GyT dqZa2w8pKz4LOcZJwifx8ly4mf5Ji3zgM6y8MU3hAmPLE7J97w1kCAUQMPBxwTBja5Dxtxg39IV WPAmIBbg++j3mJ1WN41wNR3jI0MRtOXLu54hb+xeoVE= X-Google-Smtp-Source: AGHT+IG2YFy9NIzuiSU0JWQXIeYFv/n1+QFXy6BL1HyvwEsV80P0bUaURpLNAaL1ozbvN4gTQ0q7mA== X-Received: by 2002:a05:690c:998e:b0:6f9:ac35:4483 with SMTP id 00721157ae682-6febf3a9308mr61829397b3.25.1741371617759; Fri, 07 Mar 2025 10:20:17 -0800 (PST) Received: from localhost ([2a03:2880:25ff:2::]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6feb2a5c217sm8348817b3.38.2025.03.07.10.20.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Mar 2025 10:20:17 -0800 (PST) From: Joshua Hahn To: Rakie Kim Cc: gourry@gourry.net, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, joshua.hahnjy@gmail.com, dan.j.williams@intel.com, ying.huang@linux.alibaba.com, kernel_team@skhynix.com, honggyu.kim@sk.com, yunjeong.mun@sk.com Subject: Re: [PATCH 2/4] mm/mempolicy: Enable sysfs support for memory hotplug in weighted interleave Date: Fri, 7 Mar 2025 10:19:59 -0800 Message-ID: <20250307182015.489780-1-joshua.hahnjy@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250307063534.540-3-rakie.kim@sk.com> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Stat-Signature: ope49bgo9w44fbmgaidxx4d8azu7tmn8 X-Rspam-User: X-Rspamd-Queue-Id: BDFDC20005 X-Rspamd-Server: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9NDoTYYXnNqMfQ3XxNzJAJ0DX97GSMwUPQlgbdHuIYGFGisP6PU6KwI7gDZKZm02M99HXeKfMeBbljYZk3k1xjx5n75Ysue/pNOBq6d6EDHMdAuAbogsX6FAjs7vyb5Qr0OnncdXx7gkd3/h7pWhunXyhFjieQ3NCFHzFodtt3Zo9clNQt1Yl3CzkwH3TrfELCFtK1tnh471MEC+DZWHkpyxG6xgsGkYCr7J0nnRr3qPz89OaGQXYBSDlg+4ohCvy09/ChJAgknVsJoM9FxP40Fl0WsiaLsL787g1h5213jC/o6ItrCUULanYbqveNIs0OPmg4GSrkAreCEqgWqBkBPMQyBgNrmbfzk0dyBMzsEcZaltBLkrKdX8gXyvtaUj0j+DwtVlZ6OHrq0rTQXbHIuZ7/d00VSvNa+YSyf/GKC3zdDgVKiSUhqG8fb+GBH575jZNh5wrDkx2rmbvgWr5TEZk1qzH4ffq0ThAFusvWiZv2YSkf0qlvp2q2AQqMt3WevcGJH3F+a8Vik81QwBFx2nxFjKxTIxXEY5OY/9gKdBUTpF5vtxUW61dViV7tc3pk8 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: On Fri, 7 Mar 2025 15:35:31 +0900 Rakie Kim wrote: Hi Rakie, thank you for your work on this patch! I think it makes a lot of sense, given the discussion between Gregory & Honggyu in the weighted interleave auto-tuning patch. I have a few small nits and questions that I wanted to raise, but none that should change the behavior at all : -) > Previously, sysfs entries for weighted interleave were only created during > initialization, preventing dynamically added memory nodes from being recognized. > > This patch enables sysfs registration for nodes added via memory hotplug, > allowing weighted interleave settings to be updated as the system memory > configuration changes. > > Signed-off-by: Rakie Kim > --- > mm/mempolicy.c | 51 +++++++++++++++++++++++++++++++------------------- > 1 file changed, 32 insertions(+), 19 deletions(-) > > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > index 385607179ebd..fc10a9a4be86 100644 > --- a/mm/mempolicy.c > +++ b/mm/mempolicy.c > @@ -3389,6 +3389,13 @@ struct iw_node_attr { > int nid; > }; > > +struct iw_node_group { > + struct kobject *wi_kobj; > + struct iw_node_attr **nattrs; > +}; > + > +static struct iw_node_group *ngrp; > + > static ssize_t node_show(struct kobject *kobj, struct kobj_attribute *attr, > char *buf) > { > @@ -3431,8 +3438,6 @@ static ssize_t node_store(struct kobject *kobj, struct kobj_attribute *attr, > return count; > } > > -static struct iw_node_attr **node_attrs; > - > static void sysfs_wi_node_release(struct iw_node_attr *node_attr, > struct kobject *parent) > { > @@ -3448,7 +3453,7 @@ static void sysfs_wi_release(struct kobject *wi_kobj) > int i; > > for (i = 0; i < nr_node_ids; i++) > - sysfs_wi_node_release(node_attrs[i], wi_kobj); > + sysfs_wi_node_release(ngrp->nattrs[i], wi_kobj); Nit: I think it is slightly awkward to have a global struct ngrp, and then have its members passed individually like this. Of course there's nothing that we can do for sysfs_wi_release's argument, but I think we can make the arguments for sysfs_wi_node_release a bit cleaner. An idea would just be to pass an integer (nid) instead of the nattrs[i] pointer. We also don't need to pass wi_kobj, since it is accessible from within sysfs_wi_node_release. Once we make both these changes, patch 3 becomes a little bit cleaner (IMHO), where we acquire the lock for the ngrp struct, then access its contents, and we don't have to pass two pointers as arguments when they are already accessible via the global struct anyways. > kobject_put(wi_kobj); > } > > @@ -3486,12 +3491,10 @@ static int add_weight_node(int nid, struct kobject *wi_kobj) > return -ENOMEM; > } > > - node_attrs[nid] = node_attr; > + ngrp->nattrs[nid] = node_attr; > return 0; > } > > -struct kobject *wi_kobj; > - > static int wi_node_notifier(struct notifier_block *nb, > unsigned long action, void *data) > { > @@ -3504,10 +3507,10 @@ static int wi_node_notifier(struct notifier_block *nb, > > switch(action) { > case MEM_ONLINE: > - err = add_weight_node(nid, wi_kobj); > + err = add_weight_node(nid, ngrp->wi_kobj); Same idea here, we probably don't need to pass wi_kobj into add_weight_node. With that said, I can also see the argument for passing the struct itself, since it saves a line of variable declaration & definition. [...snip...] Please let me know what you think! I hope you have a great day, thank you again for this patch! Joshua Sent using hkml (https://github.com/sjp38/hackermail)