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 7C382C02198 for ; Sat, 8 Feb 2025 06:51:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0752A280004; Sat, 8 Feb 2025 01:51:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0253D280001; Sat, 8 Feb 2025 01:51:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2F44280004; Sat, 8 Feb 2025 01:51:45 -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 C685F280001 for ; Sat, 8 Feb 2025 01:51:45 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 589ACC19C1 for ; Sat, 8 Feb 2025 06:51:45 +0000 (UTC) X-FDA: 83095856970.13.C088E69 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf15.hostedemail.com (Postfix) with ESMTP id 2AB4AA0004 for ; Sat, 8 Feb 2025 06:51:42 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=nJMeWehv; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=EO2+v697; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=nJMeWehv; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=EO2+v697; spf=pass (imf15.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738997503; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=H0MWXuPM/bMM0908L1atALX4t7lCHtq7sbFIGN82KGU=; b=SXb9600NprGFjHF+pGED/kda45Xp/8k8XMuM37+uW4WvY77GuLGDZnGAVH+ClyWnPeH07f S6X9UC2RrkhJnXqvYBZOienSXen4LENFNiTQtc/6p5yT4RIHjoZMQpie3DscR2ovGmdSrC YjUbOjYbW2yieryswIOOXd7b51a+thg= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=nJMeWehv; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=EO2+v697; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=nJMeWehv; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=EO2+v697; spf=pass (imf15.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738997503; a=rsa-sha256; cv=none; b=iIhl4I51Qep+OkLFCiDdjAMsU9UAr+TanvRv+HQg3SL7vM2FoDAGymsdlPKVHveLfMAV4G sgNjb+yJe/JtdH0wFSft/wsXPStmqOYZ9II+diVveulLN3grVfPjljvztAFkIrBmZs8FiA OZiDPVoY0GMGiQqDsBN/q2FPvfNUda8= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5AC8C2115F; Sat, 8 Feb 2025 06:51:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1738997501; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=H0MWXuPM/bMM0908L1atALX4t7lCHtq7sbFIGN82KGU=; b=nJMeWehv/yy1KejSKMePgW9DSQ8Df4oel6vPtFXnGqkncwgEUdXm+W7imiCuqRCoEZ/JYL HTfJ0IejEclJKvbXJubRtiNul6LZv/XmAV0Ofe6Eh9lywC/x7B1AoyJByTEl3KF/+7jbFp MiX8jLniwfa38PQahFqGtioCTINKEjY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1738997501; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=H0MWXuPM/bMM0908L1atALX4t7lCHtq7sbFIGN82KGU=; b=EO2+v697wtHWhMOJqXUCtofVz39NF6AAz5vb7O5gkXfzNKrg+lRwTTzegmktD32UHDzXcN 3WPJpGNG6iDzmYBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1738997501; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=H0MWXuPM/bMM0908L1atALX4t7lCHtq7sbFIGN82KGU=; b=nJMeWehv/yy1KejSKMePgW9DSQ8Df4oel6vPtFXnGqkncwgEUdXm+W7imiCuqRCoEZ/JYL HTfJ0IejEclJKvbXJubRtiNul6LZv/XmAV0Ofe6Eh9lywC/x7B1AoyJByTEl3KF/+7jbFp MiX8jLniwfa38PQahFqGtioCTINKEjY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1738997501; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=H0MWXuPM/bMM0908L1atALX4t7lCHtq7sbFIGN82KGU=; b=EO2+v697wtHWhMOJqXUCtofVz39NF6AAz5vb7O5gkXfzNKrg+lRwTTzegmktD32UHDzXcN 3WPJpGNG6iDzmYBg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 41DFC139CB; Sat, 8 Feb 2025 06:51:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id KF27DPz+pmdZPwAAD6G6ig (envelope-from ); Sat, 08 Feb 2025 06:51:40 +0000 Date: Sat, 8 Feb 2025 07:51:38 +0100 From: Oscar Salvador To: Joshua Hahn Cc: gourry@gourry.net, hyeonggon.yoo@sk.com, ying.huang@linux.alibaba.com, honggyu.kim@sk.com, akpm@linux-foundation.org, rafael@kernel.org, lenb@kernel.org, gregkh@linuxfoundation.org, rakie.kim@sk.com, dan.j.williams@intel.com, Jonathan.Cameron@huawei.com, dave.jiang@intel.com, horen.chuang@linux.dev, hannes@cmpxchg.org, linux-kernel@vger.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org, kernel-team@meta.com Subject: Re: [PATCH v5] mm/mempolicy: Weighted Interleave Auto-tuning Message-ID: References: <20250207201335.2105488-1-joshua.hahnjy@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250207201335.2105488-1-joshua.hahnjy@gmail.com> X-Rspamd-Action: no action X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 2AB4AA0004 X-Stat-Signature: gwak7bn7u976g4jedk6mc168ktn1qa46 X-HE-Tag: 1738997502-500704 X-H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g1P5iekUp40MwVm9eJ4Afpmz5QEKVQwcTBpDKGRCOKS6GiOxUIe9NmuPZa/g9QNAAfkPnDWlX6IomwYpvXP2WuOVG5PCg17L2+lg9qWvMrA9NUk4RrcVBHBuWQUySdCtNCN/xMKgWL4ijdfJsB/htZYVNZC9AlFlAiekk9xM2CQXNtHJBd6fEblWB92MBEVY2VpOTpC+YzYv5dHEsRh8r5pq9jGBBPhuWANc7DeiMVQJs9Xz+MmKsOUNl+EpVoAtuQHThaT7nFlv91CoJiYaM/c7Ht0FjauNy4IKCQJVwxFi9/XjHub18kNQRt1S71R13esGe10Bhvieu0XYLIHRkPci6+h635aLw8gjiLaP3Phu1aNOL6WjVCaRAHuGU01dU1nuJu+wurgZdscEZANOw== 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, Feb 07, 2025 at 12:13:35PM -0800, Joshua Hahn wrote: > On machines with multiple memory nodes, interleaving page allocations > across nodes allows for better utilization of each node's bandwidth. > Previous work by Gregory Price [1] introduced weighted interleave, which > allowed for pages to be allocated across nodes according to user-set ratios. > > Ideally, these weights should be proportional to their bandwidth, so > that under bandwidth pressure, each node uses its maximal efficient > bandwidth and prevents latency from increasing exponentially. > > At the same time, we want these weights to be as small as possible. > Having ratios that involve large co-prime numbers like 7639:1345:7 leads > to awkward and inefficient allocations, since the node with weight 7 > will remain mostly unused (and despite being proportional to bandwidth, > will not aid in relieving the bandwidth pressure in the other two nodes). > > This patch introduces an auto-configuration mode for the interleave > weights that aims to balance the two goals of setting node weights to be > proportional to their bandwidths and keeping the weight values low. > In order to perform the weight re-scaling, we use an internal > "weightiness" value (fixed to 32) that defines interleave aggression. > > In this auto configuration mode, node weights are dynamically updated > every time there is a hotplug event that introduces new bandwidth. > > Users can also enter manual mode by writing "N" or "0" to the new "auto" > sysfs interface. When a user enters manual mode, the system stops > dynamically updating any of the node weights, even during hotplug events > that can shift the optimal weight distribution. The system also enters > manual mode any time a user sets a node's weight directly by using the > nodeN interface introduced in [1]. On the other hand, auto mode is > only entered by explicitly writing "Y" or "1" to the auto interface. > > There is one functional change that this patch makes to the existing > weighted_interleave ABI: previously, writing 0 directly to a nodeN > interface was said to reset the weight to the system default. Before > this patch, the default for all weights were 1, which meant that writing > 0 and 1 were functionally equivalent. > > This patch introduces "real" defaults, but moves away from letting users > use 0 as a "set to default" interface. Rather, users who want to use > system defaults should use auto mode. This patch seems to be the > appropriate place to make this change, since we would like to remove > this usage before users begin to rely on the feature in userspace. > Moreover, users will not be losing any functionality; they can still > write 1 into a node if they want a weight of 1. Thus, we deprecate the > "write zero to reset" feature in favor of returning an error, the same > way we would return an error when the user writes any other invalid > weight to the interface. > > [1] https://lore.kernel.org/linux-mm/20240202170238.90004-1-gregory.price@memverge.com/ > > Signed-off-by: Joshua Hahn > Co-developed-by: Gregory Price > Signed-off-by: Gregory Price > Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> > --- Hi Joshua > diff --git a/drivers/base/node.c b/drivers/base/node.c > index 0ea653fa3433..16e7a5a8ebe7 100644 > --- a/drivers/base/node.c > +++ b/drivers/base/node.c > @@ -7,6 +7,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -214,6 +215,12 @@ void node_set_perf_attrs(unsigned int nid, struct access_coordinate *coord, > break; > } > } > + > + /* When setting CPU access coordinates, update mempolicy */ > + if (access == ACCESS_COORDINATE_CPU) { > + if (mempolicy_set_node_perf(nid, coord)) > + pr_info("failed to set node%d mempolicy attrs\n", nid); Not a big deal but I think you want to make that consistent with the error pr_info? that is: "failed to set mempolicy attrs for node %d". Also, I guess we cannot reach here with a memoryless node, right? > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > index 04f35659717a..51edd3663667 100644 > --- a/mm/mempolicy.c > +++ b/mm/mempolicy.c > @@ -109,6 +109,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -138,16 +139,18 @@ static struct mempolicy default_policy = { > > static struct mempolicy preferred_node_policy[MAX_NUMNODES]; > > +static uint64_t *node_bw_table; > + > /* > - * iw_table is the sysfs-set interleave weight table, a value of 0 denotes > - * system-default value should be used. A NULL iw_table also denotes that > - * system-default values should be used. Until the system-default table > - * is implemented, the system-default is always 1. > - * > + * iw_table is the interleave weight table. > + * If bandwidth data is available and the user is in auto mode, the table > + * is populated with default values in [1,255]. > * iw_table is RCU protected > */ > static u8 __rcu *iw_table; > static DEFINE_MUTEX(iw_table_lock); > +static const int weightiness = 32; You explain why you chose this value in the changelog, but I would either drop a comment, probably in reduce_interleave_weights() elaborating a little bit, otherwise someone who stumbles upon that when reading that code will have to go through the changelog. -- Oscar Salvador SUSE Labs