linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Eric Bergen <ebergen@meta.com>
Subject: Re: [PATCH] mm: vmscan: split khugepaged stats from direct reclaim stats
Date: Tue, 25 Oct 2022 18:16:53 +0100	[thread overview]
Message-ID: <Y1gaBXp+IENVIU7z@casper.infradead.org> (raw)
In-Reply-To: <20221025170519.314511-1-hannes@cmpxchg.org>

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?



  reply	other threads:[~2022-10-25 17:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25 17:05 Johannes Weiner
2022-10-25 17:16 ` Matthew Wilcox [this message]
2022-10-25 20:43   ` Johannes Weiner
2022-10-25 19:40 ` Yang Shi
2022-10-25 20:54   ` Johannes Weiner
2022-10-25 21:53     ` Yang Shi
2022-10-26 17:32       ` Johannes Weiner
2022-10-26 20:51         ` Yang Shi
2022-10-27  2:41           ` Yosry Ahmed
2022-10-27 14:15             ` Johannes Weiner
2022-10-27 20:43               ` Yosry Ahmed
2022-10-28 14:39                 ` Johannes Weiner
2022-10-28 17:41                   ` Yosry Ahmed
2022-10-31 16:00                     ` Johannes Weiner
2022-10-31 16:46                       ` Yosry Ahmed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y1gaBXp+IENVIU7z@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=ebergen@meta.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox