linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Palmer Dabbelt <palmer@rivosinc.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	heiko@sntech.de, guoren@kernel.org, shorne@gmail.com,
	peterz@infradead.org, mingo@redhat.com,
	Will Deacon <will@kernel.org>,
	boqun.feng@gmail.com, jonas@southpole.se,
	stefan.kristiansson@saunalahti.fi,
	Paul Walmsley <paul.walmsley@sifive.com>,
	aou@eecs.berkeley.edu, macro@orcam.me.uk,
	Greg KH <gregkh@linuxfoundation.org>,
	sudipm.mukherjee@gmail.com, wangkefeng.wang@huawei.com,
	jszhang@kernel.org, linux-csky@vger.kernel.org,
	linux-kernel@vger.kernel.org, openrisc@lists.librecores.org,
	linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org
Subject: Re: [PATCH v3 1/7] asm-generic: ticket-lock: New generic ticket-based spinlock
Date: Fri, 15 Apr 2022 13:02:42 -0400	[thread overview]
Message-ID: <8f2a3903-ab49-23cc-a362-a9857dc38410@redhat.com> (raw)
In-Reply-To: <mhng-f4d144dd-b6ed-4f3f-bfc3-6dc29fab14e4@palmer-ri-x1c9>

On 4/15/22 12:46, Palmer Dabbelt wrote:
>
>>> diff --git a/include/asm-generic/spinlock_types.h 
>>> b/include/asm-generic/spinlock_types.h
>>> new file mode 100644
>>> index 000000000000..e56ddb84d030
>>> --- /dev/null
>>> +++ b/include/asm-generic/spinlock_types.h
>>> @@ -0,0 +1,17 @@
>>> +/* SPDX-License-Identifier: GPL-2.0 */
>>> +
>>> +#ifndef __ASM_GENERIC_TICKET_LOCK_TYPES_H
>>> +#define __ASM_GENERIC_TICKET_LOCK_TYPES_H
>>> +
>>> +#include <linux/types.h>
>>> +typedef atomic_t arch_spinlock_t;
>>> +
>>> +/*
>>> + * qrwlock_types depends on arch_spinlock_t, so we must typedef 
>>> that before the
>>> + * include.
>>> + */
>>> +#include <asm/qrwlock_types.h>
>>
>> I believe that if you guard the include line by
>>
>> #ifdef CONFIG_QUEUED_RWLOCK
>> #include <asm/qrwlock_types.h>
>> #endif
>>
>> You may not need to do the hack in patch 5.
>
> Yes, and we actually had it that way the first time around 
> (specifically the ARCH_USES_QUEUED_RWLOCKS, but IIUC that's the same 
> here).  The goal was to avoid adding the ifdef to the asm-generic code 
> and instead keep the oddness in arch/riscv, it's only there for that 
> one commit (and just so we can split out the spinlock conversion from 
> the rwlock conversion, in case there's a bug and these need to be 
> bisected later).
>
> I'd also considered renaming qrwlock* to rwlock*, which would avoid 
> the ifdef and make it a touch easier to override the rwlock 
> implementation, but that didn't seem useful enough to warrant the 
> diff.  These all seem a bit more coupled than I expected them to be 
> (both {spin,qrw}lock{,_types}.h and the bits in linux/), I looked into 
> cleaning that up a bit but it seemed like too much for just the one 
> patch set.

Then you are forcing arches that use asm_generic/spinlock.h to use 
qrwlock as well. Even though most of them probably will, but forcing it 
this way remove the flexibility an arch may want to have.

The difference between CONFIG_QUEUED_RWLOCK and ARCH_USES_QUEUED_RWLOCKS 
is that qrwlock will not be compiled in when PREEMPT_RT || !SMP. So 
CONFIG_QUEUED_RWLOCK is a more accurate guard as to whether qrwlock 
should really be used.

Cheers,
Longman


  reply	other threads:[~2022-04-15 17:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-14 22:02 [PATCH v3 0/7] Generic Ticket Spinlocks Palmer Dabbelt
2022-04-14 22:02 ` [PATCH v3 1/7] asm-generic: ticket-lock: New generic ticket-based spinlock Palmer Dabbelt
2022-04-15  1:09   ` Boqun Feng
2022-04-15  5:20     ` Palmer Dabbelt
2022-04-17  2:44       ` Boqun Feng
2022-04-15  1:27   ` Waiman Long
2022-04-15 16:46     ` Palmer Dabbelt
2022-04-15 17:02       ` Waiman Long [this message]
2022-04-14 22:02 ` [PATCH v3 2/7] asm-generic: qspinlock: Indicate the use of mixed-size atomics Palmer Dabbelt
2022-04-14 22:02 ` [PATCH v3 3/7] asm-generic: qrwlock: Document the spinlock fairness requirements Palmer Dabbelt
2022-04-14 22:02 ` [PATCH v3 4/7] openrisc: Move to ticket-spinlock Palmer Dabbelt
2022-04-30  7:52   ` Stafford Horne
2022-04-14 22:02 ` [PATCH v3 5/7] RISC-V: Move to generic spinlocks Palmer Dabbelt
2022-04-14 22:02 ` [PATCH v3 6/7] RISC-V: Move to queued RW locks Palmer Dabbelt
2022-04-14 22:02 ` [PATCH v3 7/7] csky: Move to generic ticket-spinlock Palmer Dabbelt

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=8f2a3903-ab49-23cc-a362-a9857dc38410@redhat.com \
    --to=longman@redhat.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=arnd@arndb.de \
    --cc=boqun.feng@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=guoren@kernel.org \
    --cc=heiko@sntech.de \
    --cc=jonas@southpole.se \
    --cc=jszhang@kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-csky@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=macro@orcam.me.uk \
    --cc=mingo@redhat.com \
    --cc=openrisc@lists.librecores.org \
    --cc=palmer@rivosinc.com \
    --cc=paul.walmsley@sifive.com \
    --cc=peterz@infradead.org \
    --cc=shorne@gmail.com \
    --cc=stefan.kristiansson@saunalahti.fi \
    --cc=sudipm.mukherjee@gmail.com \
    --cc=wangkefeng.wang@huawei.com \
    --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;
as well as URLs for NNTP newsgroup(s).