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 8B703C28B2E for ; Mon, 10 Mar 2025 08:29:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7A51D280003; Mon, 10 Mar 2025 04:29:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 75562280001; Mon, 10 Mar 2025 04:29:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F6D4280003; Mon, 10 Mar 2025 04:29:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 38910280001 for ; Mon, 10 Mar 2025 04:29:02 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 687A7C0BDE for ; Mon, 10 Mar 2025 08:29:03 +0000 (UTC) X-FDA: 83204966166.04.8234CDA Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf30.hostedemail.com (Postfix) with ESMTP id CA2FE8000C for ; Mon, 10 Mar 2025 08:29:00 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf30.hostedemail.com: domain of rakie.kim@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=rakie.kim@sk.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741595341; 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; bh=9/AsuDawiCCahBTz/L1lGbB8zYrE6c0KJxs48DnA+Gs=; b=B9ne6YT+06P5FwkNyrvXKoOVM/s9bJAj2MfnDQsj+kL21BPCHgnm7rJoTF87xTkLQb3Kkk FIhvwCzSsRka0YwKvztDY2uZ7kVSNoI+6jZx1pnif1H1nAnu7LOd/8IV1ingzXVJSVIS1k 8A2XgPJUiZnVVd5Pn9hGoRTlCj6Xx2w= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf30.hostedemail.com: domain of rakie.kim@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=rakie.kim@sk.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741595341; a=rsa-sha256; cv=none; b=NCGWuKPUgQoGsDeaTnv7gT0lnL9m9XG7ra8e0ej9xFJi36pG2rZdC+PfpbOZTTz7UtSubM jTvXbB02NNJHXGF1CMG6QnFESBs7Xw7MigmcXIAzE77xWTnSjlG1K7tbZ8zqwemu2Z0eJj D/QQdLNbtltQEhmdJGJ/kEjf+M9M/RU= X-AuditID: a67dfc5b-3c9ff7000001d7ae-62-67cea2ca9924 From: Rakie Kim To: Joshua Hahn Cc: gourry@gourry.net, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, dan.j.williams@intel.com, ying.huang@linux.alibaba.com, kernel_team@skhynix.com, honggyu.kim@sk.com, yunjeong.mun@sk.com, Rakie Kim Subject: Re: [PATCH 2/4] mm/mempolicy: Enable sysfs support for memory hotplug in weighted interleave Date: Mon, 10 Mar 2025 17:28:38 +0900 Message-ID: <20250310082854.606-1-rakie.kim@sk.com> X-Mailer: git-send-email 2.48.1.windows.1 In-Reply-To: <20250307182015.489780-1-joshua.hahnjy@gmail.com> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNLMWRmVeSWpSXmKPExsXC9ZZnoe6pRefSDT7/0bOYs34Nm8X0qRcY LX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p HhOIzSlgJ7HrxxKwXiEBHolXG/YzQtQLSpyc+YQFxGYWkJdo3jqbeQIjzywkqVlIUgsYmVYx imTmleUmZuaY6hVnZ1TmZVboJefnbmIEhu6y2j8TdzB+uex+iFGAg1GJh/fBvLPpQqyJZcWV uYcYJTiYlUR41bafShfiTUmsrEotyo8vKs1JLT7EKM3BoiTO6xWemiAkkJ5YkpqdmlqQWgST ZeLglGpgrHE4eSR5/YXCL+ohm9/aLLl/vHWWclD7ksW3eav/Vd53Mu44cWLiBdnlC79kMj89 zHey6U3d/o09+Su3vDm4n9/0weLAnFdTos8oeXXFJ+3NivRNXpvgWLrgaZBL3XKzEzaHrE6d y6r+XP3m4Kq6xsX69YIJ39pma/HN7/48q5tn2kRvrkLvfCWW4oxEQy3mouJEAKmylgZZAgAA X-CFilter-Loop: Reflected X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: CA2FE8000C X-Stat-Signature: s6beq6fjsrtjahx6he6jn38n11k6qdc9 X-Rspam-User: X-HE-Tag: 1741595340-779195 X-HE-Meta: U2FsdGVkX1/DiisuED47lees/yqiBdXHesiQTyLTHIXNpG08NYWfKswb7DD8Xwa/eU0C83JCqm7eu5xs37k6dNMz+8G42uHYJhoAc5//w8uG2Rz/M7yNOD74T9xdpErPRbOIeuFPwDqiAM0OJthw7+F20Idw1VoAKpMkrD1JCgPwPXV2mHAqTTWMMGseKyWP3oHJmmnzddAyfJ7LbNM8ZzVm5MVNdVKaE9D5ydF2dHJXKW8egvp9Vd0hFw0qXDObuUZSbczDBlQro3Sg1EepsqSRTMjfSnZq5HQcaeDg/I19tipxKdHemF5E8KClkzbKdSoZOM+h39DwgdOBU0/ltFGsLHfA80FCAMTKqDFKr9bmw736v6gIPk6zzSkoqPOtCo5e5ZuLGV9WgDSj+krz42YE0g8Y5PIsNUxBWoaR5HxiXOGGZL4/bqHbr+FD/me43m1mnXxFAaI1uY0QITt7MTMxN/goaQvLuVU1SyAUhoL9PUhnvYaeTD9dsRdxxicG+qHfbXOFrjbqiIRYYuBPeFVCb3JMPAklPbZwfNobQsmxlLsKjaWqUKTWAxJNEO+zlarIpe298vMpUNGM5ZCqX4ApIGT+bSlxqXrXTuk3fSp5XeaGNOoT1Vt7IGomYvkj+C4DORnT6Hqej+zT69PHntNuywFdMV8ztEUaNslHJvJpDQRWEY+Dp3keCqSfkyVC19KQOfQAftrvaxethgdS7Ke+MlJvsByinqlfsHYIV1o5ijakf8uon6oVrCDRpuh6b+HP5LtZNTpMoN4L9O9hmgK6KTYV9pH3S3R+APAVj537yzIvCT9Z7HUmoCgNEzWRfpgrUDvCaAG0UobY4KdICPdkETCxguemdKIsmh+55VkIllVRcAJSuvZhc9gs2IB+mmFV/6Fozaxe+RC9XJLnAjaYjcJqOanUFPgQWZxAO6KdsPUoQRQLEQ35imF17Q26RRErW5q99iYE6PbGMWW 6qTVhKX9 8Kpp6JR9XT52XDdTIiOcAtxi87SziOBXBbn/NOCUfhDIB8b8tDy0ojnc11Ufuuoe6nBA24GTCiE2hQi+maZRpXeMscIyhr+OI12lieytmvTQIXOuZxES4/YigTyYz8M+biZ6iL/FD8odyx5zq6AzPMIGnSQ== 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 10:19:59 -0800 Joshua Hahn wrote: Hi Joshua Thank you for your response regarding this patch. > 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. > I completely agree with your observations about the use of ngrp and wi_kobj. When I was working on this patch, I aimed to minimize changes to the existing code. This approach led to the creation of similar code being used differently, as you pointed out. I'll make the necessary adjustments and update the patch to version 2. > > 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 I will also update this issue in version 2. > > Sent using hkml (https://github.com/sjp38/hackermail) > Rakie