[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y1hKaHmzVJ1cJPyn@cmpxchg.org>
Date: Tue, 25 Oct 2022 16:43:20 -0400
From: Johannes Weiner <hannes@...xchg.org>
To: Matthew Wilcox <willy@...radead.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, Eric Bergen <ebergen@...a.com>
Subject: Re: [PATCH] mm: vmscan: split khugepaged stats from direct reclaim
stats
On Tue, Oct 25, 2022 at 06:16:53PM +0100, Matthew Wilcox wrote:
> On Tue, Oct 25, 2022 at 01:05:19PM -0400, Johannes Weiner wrote:
> > +static int reclaimer_offset(void)
> > +{
> > + BUILD_BUG_ON(PGSTEAL_DIRECT - PGSTEAL_KSWAPD != 1);
> > + BUILD_BUG_ON(PGSTEAL_KHUGEPAGED - PGSTEAL_KSWAPD != 2);
> > + BUILD_BUG_ON(PGDEMOTE_DIRECT - PGDEMOTE_KSWAPD != 1);
> > + BUILD_BUG_ON(PGDEMOTE_KHUGEPAGED - PGDEMOTE_KSWAPD != 2);
> > + BUILD_BUG_ON(PGSCAN_DIRECT - PGSCAN_KSWAPD != 1);
> > + BUILD_BUG_ON(PGSCAN_KHUGEPAGED - PGSCAN_KSWAPD != 2);
> > +
> > + if (current_is_kswapd())
> > + return 0;
> > + if (current_is_khugepaged())
> > + return 2;
> > + return 1;
> > +}
>
> Would this be simpler as ...
>
> BUILD_BUG_ON(PGSTEAL_DIRECT - PGSTEAL_KSWAPD !=
> PGDEMOTE_DIRECT - PGDEMOTE_KSWAPD);
> BUILD_BUG_ON(PGSTEAL_DIRECT - PGSTEAL_KSWAPD !=
> PGSCAN_DIRECT - PGSCAN_KSWAPD);
> BUILD_BUG_ON(PGSTEAL_KHUGEPAGED - PGSTEAL_KSWAPD !=
> PGDEMOTE_KHUGEPAGED - PGDEMOTE_KSWAPD);
> BUILD_BUG_ON(PGSTEAL_KHUGEPAGED - PGSTEAL_KSWAPD !=
> PGSCAN_KHUGEPAGED - PGDEMOTE_KSWAPD);
>
> if (current_is_kswapd())
> return 0;
> if (current_is_khugepaged())
> return PGSTEAL_KHUGEPAGED - PGSTEAL_KSWAPD;
> return PGSTEAL_DIRECT - PGSTEAL_KSWAPD;
>
> Not that I think we'd ever want to separate them, but it is perhaps a
> bit less magic?
Yeah that looks better. I'll do that in v2, thanks!
Powered by blists - more mailing lists