Gregory Price <gourry@xxxxxxxxxx> writes: > On Sun, Dec 22, 2024 at 04:29:30PM +0800, Huang, Ying wrote: >> Gregory Price <gourry@xxxxxxxxxx> writes: >> >> > On Sat, Dec 21, 2024 at 01:57:58PM +0800, Huang, Ying wrote: >> >> Another choice is that if the user set a value, he/she set all values >> effectively. Even if he/she doesn't set the other values, he/she thinks >> that the other values are good, and more importantly, the ratio is good. > > This is probably the actual way to go. > >> If so, >> >> default_values [5,2,-] <- 1 node not set, expected to be hotplugged >> user_values [4,2,0] <- user has only set one value, not populated nodes have value 0 >> effective [4,2,0] >> >> hotplug event >> default_values [2,1,1] - reweight has occurred >> user_values [4,2,0] >> effective [4,2,0] >> >> In this way, 0 becomes a valid value too. >> >> What do you think about this? >> > > 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] 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] 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] 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 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. --- Best Regards, Huang, Ying