mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Haakon Bugge <haakon.bugge@oracle.com>
To: David Laight <david.laight.linux@gmail.com>
Cc: "linux-kernel@vger.kernel.org" <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"
	<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 17:21:41 +0000	[thread overview]
Message-ID: <A1E4F810-7A75-4AF8-9DE4-11BBA101F5E5@oracle.com> (raw)
In-Reply-To: <6546A220-4B85-4780-8B45-F8B35D24139C@oracle.com>



> On 14 Sep 2026, at 14:32, Haakon Bugge <haakon.bugge@oracle.com> wrote:
> 
> On 14 Sep 2026, at 11:35, David Laight <david.laight.linux@gmail.com> wrote:

[snip]

>> 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().
> 
> That is a good idea, but we then misses test coverage for atomic_t. But,
> what about:

[snip]

I ended up with:

struct mx_elem {
        /* This union contains locks and lock-free data types */
        union {
                spinlock_t spinlock;
                rwlock_t rwlock;
                struct mutex mutex;
                atomic_t atomic_lock;
                atomic_t atomic_counter;
                atomic64_t atomic64_counter;
                long cmpxchg_counter;
                unsigned long bits;
                struct ww_mutex ww_mutex;
                struct optimistic_spin_queue osq_lock;
        };
        /* A counter protected by one of the locks above */
        long counter;
};

This became quite simpler. I'll test somewhat more, and send out
a v2 tomorrow.


Thxs, Håkon


  reply	other threads:[~2026-09-14 17:22 UTC|newest]

Thread overview: 13+ 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
2026-09-14 12:32     ` Haakon Bugge
2026-09-14 17:21       ` Haakon Bugge [this message]
2026-09-14 21:40         ` David Laight
2026-09-21 15:52           ` 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=A1E4F810-7A75-4AF8-9DE4-11BBA101F5E5@oracle.com \
    --to=haakon.bugge@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=boqun@kernel.org \
    --cc=david.laight.linux@gmail.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®