On Tue, Jan 2, 2024 at 8:21 AM Dan Schatzberg <schatzberg.dan@xxxxxxxxx> wrote: > > Hi Yu Zhao, > > Thanks for the feedback, sorry for the delayed response. > > On Thu, Dec 21, 2023 at 10:31:59PM -0700, Yu Zhao wrote: > > On Wed, Dec 20, 2023 at 8:27 AM Dan Schatzberg <schatzberg.dan@xxxxxxxxx> wrote: > > > > > > ... > > > > The cover letter says: > > "Previously, this exact interface addition was proposed by Yosry[3]." > > > > So I think it should be acknowledged with a Suggested-by, based on: > > "A Suggested-by: tag indicates that the patch idea is suggested by the > > person named and ensures credit to the person for the idea." > > from > > https://docs.kernel.org/process/submitting-patches.html#using-reported-by-tested-by-reviewed-by-suggested-by-and-fixes > > Sure, will do. > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > > index d91963e2d47f..aa5666842c49 100644 > > > --- a/mm/vmscan.c > > > +++ b/mm/vmscan.c > > > @@ -92,6 +92,9 @@ struct scan_control { > > > unsigned long anon_cost; > > > unsigned long file_cost; > > > > > > + /* Swappiness value for reclaim. NULL will fall back to per-memcg/global value */ > > > + int *swappiness; > > > > Using a pointer to indicate whether the type it points to is > > overridden isn't really a good practice. > > > > A better alternative was suggested during the v2: > > "Perhaps the negative to avoid unnecessary dereferences." > > https://lore.kernel.org/linux-mm/dhhjw4h22q4ngwtxmhuyifv32zjd6z2relrcjgnxsw6zys3mod@o6dh5dy53ae3/ > > I did have a couple versions with a negative but it creates > initialization issues where every instantiation of scan_control needs > to make sure to initialize swappiness or else it will behave as if > swappiness is 0. That's pretty error prone so using the pointer seemed > the better approach. > > > Since only proactive reclaim can override swappiness, meaning it only > > happens if sc->proactive is true, I think the best way to make it work > > without spending much effort is create a helper as Michal suggest but > > it should look like: > > > > sc_swappiness() > > { > > return sc->proactive ? sc->swappiness : mem_cgroup_swappiness(memcg); > > } > > > > In this patchset, sc->swappiness really means > > sc->proactive_swappiness. So it should be renamed accordingly. > > Helper aside, I disagree with this point about coupling with the > proactive flag. Sure. But I would like to hear a *concrete* counterexample. > The fact that the only user currently is proactive > reclaim Yes, that's a fact, and we should make the decision based on the current known facts. > doesn't imply to me that the interface (in scan_control) > should be coupled to the use-case. Future always has its uncertainty which I would not worry so much about. > It's easier to reason about a > swappiness field that overrides swappiness for all scans that set it > regardless of the users. For example? And how likely would that happen in the next few years?