[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMvvPS7ozBjY-YWHrkkGVQA8ug=0=xT=BeyZxi0YrHp6PNQmHg@mail.gmail.com>
Date: Mon, 23 Jun 2025 09:27:16 -0500
From: Bijan Tabatabai <bijan311@...il.com>
To: SeongJae Park <sj@...nel.org>
Cc: damon@...ts.linux.dev, linux-mm@...ck.org, linux-kernel@...r.kernel.org,
akpm@...ux-foundation.org, david@...hat.com, ziy@...dia.com,
matthew.brost@...el.com, joshua.hahnjy@...il.com, rakie.kim@...com,
byungchul@...com, gourry@...rry.net, ying.huang@...ux.alibaba.com,
apopple@...dia.com, bijantabatab@...ron.com, venkataravis@...ron.com,
emirakhur@...ron.com, ajayjoshi@...ron.com, vtavarespetr@...ron.com
Subject: Re: [RFC PATCH v2 2/2] mm/damon/paddr: Allow multiple migrate targets
On Sat, Jun 21, 2025 at 1:11 PM SeongJae Park <sj@...nel.org> wrote:
>
> On Sat, 21 Jun 2025 11:02:15 -0700 SeongJae Park <sj@...nel.org> wrote:
>
> [...]
> > I'd hence suggest to implement and use a simple weights handling mechanism
> > here. It could be roud-robin way, like weighted interleaving, or probabilistic
> > way, using damon_rand().
> >
> > The round-robin way may be simpler in my opinion. For example,
> >
> > unsigned int damos_pa_nid_to_migrate(struct damos_migrate_dest *dest)
> > {
> > static unsigned int nr_migrated = 0;
> > unsigned int total_weight = 0;
> > unsigned int weights_to_ignore;
> > size_t i;
> >
> > for (i = 0; i < dest->nr_dests; i++)
> > total_weight += dest->weight_arr[i];
> > weights_to_ignore = nr_migrate++ % total_weight;
>
> Actually, probabilistic way may be not that complicated. Maybe we could to
> below here.
>
> return damon_rand(0, total_weight) >= weight_to_ignore;
>
> > total_weight = 0;
> > for (i = 0; i < dest->nr_dests; i++) {
> > total_weight += dest->weight_arr[i];
> > if (total_weight >= weights_to_ignore)
> > return dest->node_id_arr[i];
> > }
> > WARN_ON_ONCE(1, "I don't know what I did wrong");
> > return 0;
> > }
>
> But damon_rand() might be more expensive than the roud-robin way, and arguably
> roud-robin way is what usrs who familiar with weighted interleaving may easily
> expect and even prefer? I have no preferrence here.
I think my comments about the round-robin approach also apply here,
but all things equal, I generally prefer being deterministic over
being probabilistic when possible.
Bijan
[...]
Powered by blists - more mailing lists