From: David Laight <david.laight.linux@gmail.com>
To: "Håkon Bugge" <haakon.bugge@oracle.com>
Cc: linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Boqun Feng <boqun@kernel.org>, Waiman Long <longman@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org, John Stultz <jstultz@google.com>
Subject: Re: [PATCH 1/1] kernel/locking: Add mutual exclusion self-test
Date: Mon, 14 Sep 2026 10:35:45 +0100 [thread overview]
Message-ID: <20260914103545.3db6eb45@pumpkin> (raw)
In-Reply-To: <20260817130239.343594-2-haakon.bugge@oracle.com>
On Mon, 17 Aug 2026 15:02:36 +0200
Håkon Bugge <haakon.bugge@oracle.com> wrote:
> Add a stress test for locking and atomic synchronization primitives.
>
> The test maintains an array of elements containing counters
> initialized to zero. It creates four worker threads per online CPU. On
> each iteration, a worker chooses two elements at random, increments
> the first counter, and decrements the second. Each completed pair of
> updates therefore preserves the sum of all counters.
...
I think 1000 elements/locks/counters is far too many.
You are trying to hit contention so you want a relatively small number.
Possibly similar to the number of threads running the test, but maybe less.
Perhaps nearer the number of cpus.
Also you are only going to see an issue if the RMW of the 'counter += 1'
is split by the same RMW of a different thread.
That is pretty unlikely even without a lock.
It would be better to force a short delay between the R and W.
If you use change the MX_ATOMIC_ADD to use the atomic_long functions
(I've forgotten the exact name) then all the counter are the same type
and can be removed from the union.
The default 'just use +=' code can then be moved to the bottom of mx_add().
David
next prev parent reply other threads:[~2026-09-14 9:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 13:02 [PATCH 0/1] " Håkon Bugge
2026-08-17 13:02 ` [PATCH 1/1] " Håkon Bugge
2026-08-21 20:42 ` John Stultz
2026-08-24 12:29 ` Haakon Bugge
2026-08-24 21:48 ` John Stultz
2026-08-25 16:12 ` Haakon Bugge
2026-09-14 9:35 ` David Laight [this message]
2026-09-14 12:32 ` Haakon Bugge
2026-08-18 7:54 ` [PATCH 0/1] " Peter Zijlstra
2026-08-18 8:14 ` Haakon Bugge
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=20260914103545.3db6eb45@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=boqun@kernel.org \
--cc=haakon.bugge@oracle.com \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=shuah@kernel.org \
--cc=will@kernel.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
all inboxes | Powered by JetHome®