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 3E222E7718B for ; Thu, 26 Dec 2024 01:35:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B85E6B007B; Wed, 25 Dec 2024 20:35:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 666906B0083; Wed, 25 Dec 2024 20:35:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52DDE6B0085; Wed, 25 Dec 2024 20:35:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 36C126B007B for ; Wed, 25 Dec 2024 20:35:52 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B9F79A0CD8 for ; Thu, 26 Dec 2024 01:35:51 +0000 (UTC) X-FDA: 82935392148.13.46701AB Received: from out30-97.freemail.mail.aliyun.com (out30-97.freemail.mail.aliyun.com [115.124.30.97]) by imf24.hostedemail.com (Postfix) with ESMTP id 36F5718000E for ; Thu, 26 Dec 2024 01:35:42 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b="axF/D7rx"; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf24.hostedemail.com: domain of ying.huang@linux.alibaba.com designates 115.124.30.97 as permitted sender) smtp.mailfrom=ying.huang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735176911; a=rsa-sha256; cv=none; b=EwsuotX6Ft3q83AehThU9pySycYocYAgBomzamMASXUUMZA49CqbBxft6NRbarkLC0YKlg TwjDYSJxUFqk3MjwSVS0DqLLXWXZCc55GW8jjwXlf38dR3VAfAphK6g2gO3ou8zX8HmwoD 4tbfb60CLWmRVix/1nW9wZyh6qRZ7Uk= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b="axF/D7rx"; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf24.hostedemail.com: domain of ying.huang@linux.alibaba.com designates 115.124.30.97 as permitted sender) smtp.mailfrom=ying.huang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1735176911; 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=LgMyQTcokgOo73uKJV1KP+xRroEyuPt5ZYl/VKgG9TA=; b=Xm0jejmT8zVwDPvGflruEvesOnrQkTeU7Ycq5PSKrKoH2cTxyPAR0stY9LW1SP46aVTLVV bqmQSoSoQelfYJlyammiZbMM0fL3hohsoRY/Cw9Mx6hyPHRu40GaNNB3YLTDN+arQh9bfF Q09dHMnrTtYZkj4LDrRV7FTsGmxgrKI= DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1735176945; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; bh=LgMyQTcokgOo73uKJV1KP+xRroEyuPt5ZYl/VKgG9TA=; b=axF/D7rxGHcavi9GyHiGlssRXTIcK4d9pj1KqaOpg/bJkcpMw1qwdFjVCwrPW7LF9CVcmOMrJ2T0q/L8FIC521thRkHBC8z9LUNkawfMMUQ1kkgu19ERXO71GI8M2+RG5tYeIsuljsL1RJei5RMmddOcZsFxDqKjHqqG/0r5H+g= Received: from DESKTOP-5N7EMDA(mailfrom:ying.huang@linux.alibaba.com fp:SMTPD_---0WMGJQaw_1735176936 cluster:ay36) by smtp.aliyun-inc.com; Thu, 26 Dec 2024 09:35:44 +0800 From: "Huang, Ying" To: Joshua Hahn Cc: Gregory Price , hyeonggon.yoo@sk.com, kernel_team@skhynix.com, "rafael@kernel.org" , "lenb@kernel.org" , "gregkh@linuxfoundation.org" , "akpm@linux-foundation.org" , =?utf-8?B?6rmA7ZmN6recKEtJTSBIT05HR1lVKQ==?= System SW , =?utf-8?B?6rmA65296riwKEtJTSBSQUtJRSk=?= System SW , "dan.j.williams@intel.com" , "Jonathan.Cameron@huawei.com" , "dave.jiang@intel.com" , "horen.chuang@linux.dev" , "hannes@cmpxchg.org" , "linux-kernel@vger.kernel.org" , "linux-acpi@vger.kernel.org" , "linux-mm@kvack.org" , "kernel-team@meta.com" Subject: Re: [External Mail] [RFC PATCH] mm/mempolicy: Weighted interleave auto-tuning In-Reply-To: <20241225093042.7710-1-joshua.hahnjy@gmail.com> (Joshua Hahn's message of "Wed, 25 Dec 2024 18:30:42 +0900") References: <20241225093042.7710-1-joshua.hahnjy@gmail.com> Date: Thu, 26 Dec 2024 09:35:32 +0800 Message-ID: <874j2rp6or.fsf@DESKTOP-5N7EMDA> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Stat-Signature: 4edbn6ggjuu4xa5fd99y9cy58ocn3c7n X-Rspam-User: X-Rspamd-Queue-Id: 36F5718000E X-Rspamd-Server: rspam08 X-HE-Tag: 1735176942-718342 X-HE-Meta: U2FsdGVkX1+2k9Esm8kgjbKbnUX4/r87lqU0PIajQtEraMtahuXtz4LB67MNzOSmDRX9IP9wQqL89Ps9Ny3aJuM3R9i6+TGkKsavvbW1by40D1hJUnr8dvTSEVn3H1I3EakuR1XldlhcXuo/6qrtIZrwa4+MghFyWzTIPz7ic/MCbItnTi7KbyrTeJWio91egqXm2LxE/1JoeXAmQYdZAxWRs7zVZmqrTGuWhhW6pYNOYMzOxA0oAltmB5SCGunYlk0M0wlZzyGWqQelHxvmZAtFwb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IVubl6XihKZfu29lsigDgR2kk/jMB4QLceyeNhomY8ciL2pdcrIDVtPFhKr9avik7JR+ISA981A2hdRtNS49I8xowHZQA544EhiF9IUS2nVIEL8fTt 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: Hi, Joshua, Joshua Hahn writes: > Hi Gregory and Huang, > > Sorry for the silence on my end for the past few days. I decided to take > some time off of the computer, but I should be more reponsive now! > > On Wed, 25 Dec 2024 08:25:13 +0800 "Huang, Ying" wrote: > >> Gregory Price writes: >> >> > On Sun, Dec 22, 2024 at 04:29:30PM +0800, Huang, Ying wrote: >> >> Gregory Price writes: >> >> >> >> > On Sat, Dec 21, 2024 at 01:57:58PM +0800, Huang, Ying wrote: > > [.....8<.....] > >> > We decided when implementing weights that 0 was a special value that >> > reverts to the system default: >> > >> > Writing an empty string or `0` will reset the weight to the >> > system default. The system default may be set by the kernel >> > or drivers at boot or during hotplug events. >> > >> > I'm ok pulling the default weights in collectively once the first one is >> > written, but 0 is an invalid value which causes issues. >> > >> > We went through that when we initially implemented the feature w/ task-local >> > weights and why the help function overrides it to 1 if it's ever seen. >> > >> > We'll revert back to our initial implementation w/ default_iw_table and >> > iw_table - where iw_table contains user-defined weights. Writing a 0 to >> > iw_table[N] will allow get_il_weight() to retrieve default_iw_table[N] >> > as the docs imply it should. >> >> So, the suggested behavior becomes the following? >> >> default_values [5,2,-] <- 1 node not set, expected to be hotplugged >> user_values [4,2,1] <- user has only set one value, not populated nodes have value 1 >> effective [4,2,1] >> >> hotplug event >> default_values [2,1,1] - reweight has occurred >> user_values [4,2,1] >> effective [4,2,1] > > Yes, I think this was the intended effect when we were discussing what > interface made the most sense. > >> Even if so, we still have another issue. The effective values may be a >> combination of default_values and user_values and it's hard for users to >> identify which one is from default_values and subject to change. For >> example, >> >> user reset weight of node 0 to default: echo 0 > node0 >> default_values [2,1,1] >> user_values [0,2,1] >> effective [2,2,1] >> >> change the default again >> default_values [3,1,1] - reweight again >> user_values [0,2,1] >> effective [3,2,1] > > Agreed. Actually, this confusion was partly what motivated our new > re-work of the patch in v2, which got rid of the default and user > layers, and made all internal values transparent to the user as well. > That way, there would be no confusion as to the true source of the > value, and the user could be aware that re-weighting would impact > all values, regardless of whehter they were default values or not. > > If we are moving away from allowing users to dynamically change the > weightiness (max_node_weight) parameter however, then I think that there > may be more merit to using the two-level default & user values system to > allow for more flexibility. > >> This is still quite confusing. Another possible solution is to copy the >> default value instead, >> >> user reset weight of node 0 to default: echo 0 > node0 >> default_values [2,1,1] >> user_values [2,2,1] - copy default value when echo 0 >> effective [2,2,1] >> >> change the default again >> default_values [3,1,1] - reweight again >> user_values [2,2,1] >> effective [2,2,1] > > This makes a lot sense to me, I think it lets us keep both the > transparency of the new one-layered system and all the benefits that > come with having default values that can adapt to hotplug events. One > thing we should consider is that the user should probably be able to > check what the default value is for a given node before deciding to > copy that value over to the weight table. > > Having two files for each node (nodeN, defaultN) seems a bit too > cluttered for the user perspective. Making the nodeN interfaces serve > multiple purposes (i.e. echo -1 into the nodes will output the default > value for that node) also seems a bit too complicated as well, in my > opinion. Maybe having a file 'weight_tables' that contains a table of > default/user/effective weights (as have been used in these conversations) > might be useful for the user? (Or maybe just the defaults) > > Then a workflow for the user may be as such: > > $ cat /sys/kernel/mm/mempolicy/weighted_interleave/weight_tables > default vales: [4,7,2] > user values: [-,-,-] > effective: [4,7,2] AFAIK, this breaks the sysfs attribute format rule as follows. https://docs.kernel.org/filesystems/sysfs.html#attributes It's hard to use array sysfs attribute here too. Because the node ID may be non-consecutive. This makes it hard to read. > $ echo 4 > /sys/kernel/mm/mempolicy/weighted_interleave/node2 > 4 > ... > >> The remaining issue is that we cannot revert to default atomically. >> That is, user_values may becomea combination of old and new >> default_values if users echo 0 to each node one by one when kernel is >> changing default_values. To resolve this, we may add another interface >> to do that, for example, "use_default". >> >> echo 1 > use_default >> >> will use default_values for all nodes. We can check whether we are >> using default via >> >> cat use_default > > Like mentioned in the previous comments, I think that the "setting one > value to set all the others" is a good method, especially since the > more I think about it (in my limited experience), I think there is rarely > a scenario where a user wants to use a hybrid of manually-set and > default values and is switching back and forth between default and > manual values. > >> Anyway, I think that we need a thorough thought about the user space >> interface. And add good document, at least in change log. It's really >> hard to make user space interface right. >> >> I'm open to better user space interface design. > > I agree with this, thank you for your feedback. I think there has been > a lot of great points raised in these conversations, and I will do my > best to take these comments into consideration when writing better > documentation. > > Thank you for your input! I hope you have a great day and happy holidays! Happy holidays! --- Best Regards, Huang, Ying