From: Davidlohr Bueso <dave@stgolabs.net>
To: Gregory Price <gourry.memverge@gmail.com>
Cc: linux-mm@kvack.org, jgroves@micron.com, ravis.opensrc@micron.com,
sthanneeru@micron.com, emirakhur@micron.com,
Hasan.Maruf@amd.com, linux-doc@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org,
linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org,
akpm@linux-foundation.org, arnd@arndb.de, tglx@linutronix.de,
luto@kernel.org, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
mhocko@kernel.org, tj@kernel.org, ying.huang@intel.com,
gregory.price@memverge.com, corbet@lwn.net, rakie.kim@sk.com,
hyeongtak.ji@sk.com, honggyu.kim@sk.com,
vtavarespetr@micron.com, peterz@infradead.org
Subject: Re: [RFC PATCH 01/11] mm/mempolicy: implement the sysfs-based weighted_interleave interface
Date: Thu, 7 Dec 2023 13:56:07 -0800 [thread overview]
Message-ID: <uxqkbmqbvcvx6wc3g2h6vhkutv5flrq6rslwdfs7pa6kknupwh@a245pbtfqfgj> (raw)
In-Reply-To: <20231207002759.51418-2-gregory.price@memverge.com>
On Wed, 06 Dec 2023, Gregory Price wrote:
>Signed-off-by: Rakie Kim <rakie.kim@sk.com>
>Signed-off-by: Honggyu Kim <honggyu.kim@sk.com>
>Co-developed-by: Gregory Price <gregory.price@memverge.com>
>Signed-off-by: Gregory Price <gregory.price@memverge.com>
>Co-developed-by: Hyeongtak Ji <hyeongtak.ji@sk.com>
>Signed-off-by: Hyeongtak Ji <hyeongtak.ji@sk.com>
fyi Rakie's tag needs to be last, per the From.
...
>+What: /sys/kernel/mm/mempolicy/weighted_interleave/
>+Date: December 2023
>+Contact: Linux memory management mailing list <linux-mm@kvack.org>
>+Description: Configuration Interface for the Weighted Interleave policy
>+
>+What: /sys/kernel/mm/mempolicy/weighted_interleave/nodeN/
>+Date: December 2023
>+Contact: Linux memory management mailing list <linux-mm@kvack.org>
>+Description: Configuration interface for accesses initiated from nodeN
>+
>+ The directory to configure access initiator weights for nodeN.
>+
>+ Possible numa nodes which have not been marked as a CPU node
>+ at boot will not have a nodeN directory made for them at boot.
This could be better rephrased without the negation. ie:
"Only numa nodes with CPUs (compute) will have a nodeN directory."
>+ Hotplug for CPU nodes is not supported.
Can this even happen? Hot-adding a previously offlined CPU won't change/add a
new numa node. So just rm the line altogether?
>+
>+What: /sys/kernel/mm/mempolicy/weighted_interleave/nodeN/nodeM
>+ /sys/kernel/mm/mempolicy/weighted_interleave/nodeN/nodeM/weight
>+Date: December 2023
>+Contact: Linux memory management mailing list <linux-mm@kvack.org>
>+Description: Configuration interface for target nodes accessed from nodeNN
>+
>+ The interleave weight for a memory node (M) from initiating
>+ node (N). These weights are utilized by processes which have set
>+ the mempolicy to MPOL_WEIGHTED_INTERLEAVE and have opted into
>+ global weights by omitting a task-local weight array.
>+
>+ These weights only affect new allocations, and changes at runtime
>+ will not cause migrations on already allocated pages.
>+
>+ If the weight of 0 is desired, the appropriate way to do this is
>+ by removing the node from the weighted interleave nodemask.
>+
>+ Minimum weight: 1
>+ Maximum weight: 255
>diff --git a/mm/mempolicy.c b/mm/mempolicy.c
>index 10a590ee1c89..ce332b5e7a03 100644
>--- a/mm/mempolicy.c
>+++ b/mm/mempolicy.c
>@@ -131,6 +131,11 @@ static struct mempolicy default_policy = {
>
> static struct mempolicy preferred_node_policy[MAX_NUMNODES];
>
>+struct interleave_weight_table {
>+ unsigned char weights[MAX_NUMNODES];
>+};
>+static struct interleave_weight_table *iw_table;
>+
> /**
> * numa_nearest_node - Find nearest node by state
> * @node: Node id to start the search
>@@ -3067,3 +3072,224 @@ void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)
> p += scnprintf(p, buffer + maxlen - p, ":%*pbl",
> nodemask_pr_args(&nodes));
> }
>+
>+struct iw_node_info {
>+ struct kobject kobj;
>+ int src;
>+ int dst;
>+};
>+
>+static ssize_t node_weight_show(struct kobject *kobj,
>+ struct kobj_attribute *attr, char *buf)
>+{
>+ struct iw_node_info *node_info = container_of(kobj, struct iw_node_info,
>+ kobj);
>+ return sysfs_emit(buf, "%d\n",
>+ iw_table[node_info->src].weights[node_info->dst]);
>+}
>+
>+static ssize_t node_weight_store(struct kobject *kobj,
>+ struct kobj_attribute *attr,
>+ const char *buf, size_t count)
>+{
>+ unsigned char weight = 0;
>+ struct iw_node_info *node_info = NULL;
>+
>+ node_info = container_of(kobj, struct iw_node_info, kobj);
>+
>+ if (kstrtou8(buf, 0, &weight) || !weight)
>+ return -EINVAL;
>+
>+ iw_table[node_info->src].weights[node_info->dst] = weight;
>+
>+ return count;
>+}
iw_table will need some (basic) form of serialization.
...
>+static int __init mempolicy_sysfs_init(void)
>+{
>+ int err, nid;
>+ int cpunodes = 0;
>+ struct kobject *root_kobj;
>+
>+ for_each_node_state(nid, N_CPU)
>+ cpunodes += 1;
>+ iw_table = kmalloc_array(cpunodes, sizeof(*iw_table), GFP_KERNEL);
>+ if (!iw_table) {
>+ pr_err("failed to create interleave weight table\n");
>+ err = -ENOMEM;
>+ goto fail_obj;
No ref here yet, just return -ENOMEM.
>+ }
>+ memset(iw_table, 1, cpunodes * sizeof(*iw_table));
>+
>+ root_kobj = kzalloc(sizeof(struct kobject), GFP_KERNEL);
>+ if (!root_kobj)
>+ return -ENOMEM;
>+
>+ kobject_init(root_kobj, &mempolicy_kobj_ktype);
>+ err = kobject_add(root_kobj, mm_kobj, "mempolicy");
>+ if (err) {
>+ pr_err("failed to add kobject to the system\n");
>+ goto fail_obj;
>+ }
>+
>+ err = sysfs_create_group(root_kobj, &mempolicy_attr_group);
>+ if (err) {
>+ pr_err("failed to register mempolicy group\n");
>+ goto fail_obj;
>+ }
>+
>+ err = add_weighted_interleave_group(root_kobj);
>+fail_obj:
>+ if (err)
>+ kobject_put(root_kobj);
>+ return err;
>+
>+}
>+late_initcall(mempolicy_sysfs_init);
>--
>2.39.1
>
>
next prev parent reply other threads:[~2023-12-07 21:56 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-07 0:27 [RFC PATCH 00/11] mempolicy2, mbind2, and weighted interleave Gregory Price
2023-12-07 0:27 ` [RFC PATCH 01/11] mm/mempolicy: implement the sysfs-based weighted_interleave interface Gregory Price
2023-12-07 21:56 ` Davidlohr Bueso [this message]
2023-12-07 22:17 ` Davidlohr Bueso
2023-12-08 0:11 ` Gregory Price
2023-12-07 0:27 ` [RFC PATCH 02/11] mm/mempolicy: introduce MPOL_WEIGHTED_INTERLEAVE for weighted interleaving Gregory Price
2023-12-07 0:27 ` [RFC PATCH 03/11] mm/mempolicy: refactor sanitize_mpol_flags for reuse Gregory Price
2023-12-07 0:27 ` [RFC PATCH 04/11] mm/mempolicy: create struct mempolicy_args for creating new mempolicies Gregory Price
2023-12-07 0:27 ` [RFC PATCH 05/11] mm/mempolicy: refactor kernel_get_mempolicy for code re-use Gregory Price
2023-12-07 0:27 ` [RFC PATCH 06/11] mm/mempolicy: allow home_node to be set by mpol_new Gregory Price
2023-12-07 0:27 ` [RFC PATCH 07/11] mm/mempolicy: add userland mempolicy arg structure Gregory Price
2023-12-07 7:13 ` Arnd Bergmann
2023-12-07 14:58 ` Gregory Price
2023-12-07 15:43 ` Arnd Bergmann
2023-12-08 0:05 ` Gregory Price
2023-12-07 0:27 ` [RFC PATCH 08/11] mm/mempolicy: add set_mempolicy2 syscall Gregory Price
2023-12-07 0:27 ` [RFC PATCH 10/11] mm/mempolicy: add the mbind2 syscall Gregory Price
2023-12-07 0:27 ` [RFC PATCH 11/11] mm/mempolicy: extend set_mempolicy2 and mbind2 to support weighted interleave Gregory Price
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=uxqkbmqbvcvx6wc3g2h6vhkutv5flrq6rslwdfs7pa6kknupwh@a245pbtfqfgj \
--to=dave@stgolabs.net \
--cc=Hasan.Maruf@amd.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=emirakhur@micron.com \
--cc=gourry.memverge@gmail.com \
--cc=gregory.price@memverge.com \
--cc=honggyu.kim@sk.com \
--cc=hpa@zytor.com \
--cc=hyeongtak.ji@sk.com \
--cc=jgroves@micron.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-arch@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=luto@kernel.org \
--cc=mhocko@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rakie.kim@sk.com \
--cc=ravis.opensrc@micron.com \
--cc=sthanneeru@micron.com \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=vtavarespetr@micron.com \
--cc=x86@kernel.org \
--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