All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Gabriele Monaco <gmonaco@redhat.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mel Gorman <mgorman@suse.de>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>
Subject: Re: [PATCH] sched: Move task_mm_cid_work to mm delayed work
Date: Mon, 9 Dec 2024 10:33:31 -0500	[thread overview]
Message-ID: <cbc0a3c5-2ae5-439e-ae5d-7fb68ea49aec@efficios.com> (raw)
In-Reply-To: <481a7b7716cf4eb2d592b08558d297d343d9aa25.camel@redhat.com>

On 2024-12-09 08:45, Gabriele Monaco wrote:
> 
>> Thinking back on this, you'll want a program that does the following
>> on a system with N CPUs:
>>
>> - Phase 1: run one thread per cpu, pinned on each cpu. Print the
>>     mm_cid from each thread with the cpu number every second or so.
>>
>> - Exit all threads except the main thread, join them from the main
>>     thread,
>>
>> - Phase 2: the program is now single-threaded. We'd expect the
>>     mm_cid value to converge towards 0 as the periodic task clears
>>     unused CIDs.
>>
>> So I think in phase 2 we can have an actual automated test: If after
>> an order of magnitude more time than the 100ms delay between periodic
>> tasks we still observe mm_cid > 0 in phase 2, then something is
>> wrong.
> 
> Been thinking about this and came up with a simple draft, I'll probably
> send it as a separate patch.
> 
> Doing this can lead to false positives: the main thread may be assigned
> the mm_cid 0 and keep it till the end, in this scenario the other
> threads (CPUs) would get different mm_cids and exit, the main thread
> will still have 0 and pass the test regardless.
> 
> I have an idea to make it a bit more robust: we can run threads as you
> described in phase 1, stop all but one (let's say the one running on
> the last core), make sure the main thread doesn't accidentally run on
> the same core by pinning to core 0 and wait until we see the 2
> remaining threads holding 0 and 1, in any order.
> Besides a special case if we have only 1 available core, this should
> work fine, sure we could get false positives but it seems to me much
> less likely.
> 
> Does it make sense to you?

A small tweak on your proposed approach: in phase 1, get each thread
to publish which mm_cid they observe, and select one thread which
has observed mm_cid > 1 (possibly the largest mm_cid) as the thread
that will keep running in phase 2 (in addition to the main thread).

All threads other than the main thread and that selected thread exit
and are joined before phase 2.

So you end up in phase 2 with:

- main (observed any mm_cid)
- selected thread (observed mm_cid > 1, possibly largest)

Then after a while, the selected thread should observe a
mm_cid <= 1.

This test should be skipped if there are less than 3 CPUs in
allowed cpumask (sched_getaffinity).

Thoughts ?

Thanks,

Mathieu

-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com


  reply	other threads:[~2024-12-09 15:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-05  8:31 [PATCH] sched: Move task_mm_cid_work to mm delayed work Gabriele Monaco
2024-12-05 14:33 ` Gabriele Monaco
2024-12-05 16:25   ` Mathieu Desnoyers
2024-12-06  8:53     ` Gabriele Monaco
2024-12-06 14:06       ` Mathieu Desnoyers
2024-12-09  8:04         ` Gabriele Monaco
2024-12-09  8:12         ` Gabriele Monaco
2024-12-09 13:45         ` Gabriele Monaco
2024-12-09 15:33           ` Mathieu Desnoyers [this message]
2024-12-09 15:48             ` Mathieu Desnoyers
2024-12-11 12:27               ` Gabriele Monaco
2024-12-11 17:07                 ` Mathieu Desnoyers
2024-12-12 11:09                   ` Gabriele Monaco
2024-12-12 14:06                     ` Mathieu Desnoyers

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=cbc0a3c5-2ae5-439e-ae5d-7fb68ea49aec@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=akpm@linux-foundation.org \
    --cc=gmonaco@redhat.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=vincent.guittot@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.