From: Gregory Price <gregory.price@memverge.com>
To: "Huang, Ying" <ying.huang@intel.com>
Cc: Gregory Price <gourry.memverge@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-api@vger.kernel.org, corbet@lwn.net,
akpm@linux-foundation.org, honggyu.kim@sk.com, rakie.kim@sk.com,
hyeongtak.ji@sk.com, mhocko@kernel.org, vtavarespetr@micron.com,
jgroves@micron.com, ravis.opensrc@micron.com,
sthanneeru@micron.com, emirakhur@micron.com, Hasan.Maruf@amd.com,
seungjun.ha@samsung.com, hannes@cmpxchg.org,
dan.j.williams@intel.com
Subject: Re: [PATCH v2 1/3] mm/mempolicy: implement the sysfs-based weighted_interleave interface
Date: Mon, 22 Jan 2024 11:58:53 -0500 [thread overview]
Message-ID: <Za6ezSUjXc5Lyz/i@memverge.com> (raw)
In-Reply-To: <875xzlx09i.fsf@yhuang6-desk2.ccr.corp.intel.com>
On Mon, Jan 22, 2024 at 04:03:53PM +0800, Huang, Ying wrote:
> Gregory Price <gourry.memverge@gmail.com> writes:
>
> > + /*
> > + * The default weight is 1 (for now), when the kernel-internal
> > + * default weight array is implemented, this should be updated to
> > + * collect the system-default weight of the node if the user passes 0.
> > + */
> > + if (!weight)
> > + weight = 1;
>
> From functionality point of view, it's OK to set "weight = 1" here now.
> But when we add system default weight table in the future, we need to
> use "weight = 0". Otherwise, we cannot distinguish whether the default
> value have been customized via sysfs. So, I suggest to use that rule.
>
[... snip ...]
> > + else
> > + memset(new, 1, nr_node_ids);
>
> With similar reason as above ("From functionality..."), I suggest to set
> "0" here.
>
blah - the comment is misleading at best. The future patch should pass
0 through to the sysfs table and the allocators updated to collect the
system-default weight of the node.
re: doing it this way right now -
I chose to do it this way for now because it ultimately simplifies the
logic in the allocators - all of which will need to be updated with the
future patch set regardless of our implementation choice now.
e.g.
rcu_read_lock();
table = rcu_dereference(iw_table);
if (!policy->wil.cur_weight)
policy->wil.cur_weight = table ? table[next] : 1;
^^^ only need single conditional now
rcu_read_unlock();
This logic will need to be updated to use default table values, so I
chose the simpler implementation and left the change to be explicit
at the time the default table is implemented.
If you prefer it the other way now, I can change it, but this seemed
cleaner and simpler for the time being.
> > + new[node_attr->nid] = weight;
> > + rcu_assign_pointer(iw_table, new);
> > + mutex_unlock(&iw_table_lock);
> > + synchronize_rcu();
> > + kfree(old);
> > + return count;
> > +}
> > +
> > +static struct iw_node_attr *node_attrs[MAX_NUMNODES];
>
> node_attrs[] can be allocated dynamically too. Just a suggestion.
>
ack to this and other references to nr_node_ids, will change.
> > + kfree(old);
>
> It appears unnecessary to free iw_table in error path. But this isn't a
> big deal because error path will almost never be executed in practice.
>
checkpatch.pl yells at you if you do null checks before kfree :]
> > + int err;
> > + struct kobject *mempolicy_kobj;
>
> This overrides the global "mempolicy_kobj" defined before function. But
> I don't think we need the global definition.
>
Assuming the exit path isn't needed then yeah the global isn't needed.
> > +static int __init mempolicy_sysfs_init(void)
> > +{
> > + /* A NULL iw_table is interpreted by interleave logic as "all 1s" */
> > + iw_table = NULL;
> > + return 0;
> > +}
> > +
> > +static void __exit mempolicy_exit(void) { }
> > +#endif /* CONFIG_SYSFS */
> > +late_initcall(mempolicy_sysfs_init);
> > +module_exit(mempolicy_exit);
>
> mempolicy.c will not be compiled as module, so we don't need
> module_exit().
>
ack
next prev parent reply other threads:[~2024-01-22 16:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-19 17:57 [PATCH v2 0/3] mm/mempolicy: weighted interleave mempolicy and sysfs extension Gregory Price
2024-01-19 17:57 ` [PATCH v2 1/3] mm/mempolicy: implement the sysfs-based weighted_interleave interface Gregory Price
2024-01-22 8:03 ` Huang, Ying
2024-01-22 16:58 ` Gregory Price [this message]
2024-01-19 17:57 ` [PATCH v2 2/3] mm/mempolicy: refactor a read-once mechanism into a function for re-use Gregory Price
2024-01-19 17:57 ` [PATCH v2 3/3] mm/mempolicy: introduce MPOL_WEIGHTED_INTERLEAVE for weighted interleaving Gregory Price
2024-01-23 3:02 ` Huang, Ying
2024-01-23 4:54 ` Gregory Price
2024-01-23 5:16 ` Gregory Price
2024-01-23 8:35 ` Huang, Ying
2024-01-23 21:27 ` Gregory Price
2024-01-24 1:51 ` Huang, Ying
2024-01-24 18:01 ` Gregory Price
2024-01-23 8:13 ` Huang, Ying
2024-01-23 8:40 ` Huang, Ying
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Za6ezSUjXc5Lyz/i@memverge.com \
--to=gregory.price@memverge.com \
--cc=Hasan.Maruf@amd.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=dan.j.williams@intel.com \
--cc=emirakhur@micron.com \
--cc=gourry.memverge@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=honggyu.kim@sk.com \
--cc=hyeongtak.ji@sk.com \
--cc=jgroves@micron.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=rakie.kim@sk.com \
--cc=ravis.opensrc@micron.com \
--cc=seungjun.ha@samsung.com \
--cc=sthanneeru@micron.com \
--cc=vtavarespetr@micron.com \
--cc=ying.huang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).