[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YgZaMkUU5Ve2GV9D@alley>
Date: Fri, 11 Feb 2022 13:44:34 +0100
From: Petr Mladek <pmladek@...e.com>
To: John Ogness <john.ogness@...utronix.de>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
Thomas Gleixner <tglx@...utronix.de>,
linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Marco Elver <elver@...gle.com>,
Stephen Boyd <swboyd@...omium.org>,
Alexander Potapenko <glider@...gle.com>,
Randy Dunlap <rdunlap@...radead.org>,
Nicholas Piggin <npiggin@...il.com>
Subject: Re: [PATCH printk v1 01/13] printk: rename cpulock functions
On Mon 2022-02-07 20:49:11, John Ogness wrote:
> Since the printk cpulock is CPU-reentrant and since it is used
> in all contexts, its usage must be carefully considered and
> most likely will require programming locklessly. To avoid
> mistaking the printk cpulock as a typical lock, rename it to
> cpu_sync. The main functions then become:
>
> printk_cpu_sync_get_irqsave(flags);
> printk_cpu_sync_put_irqrestore(flags);
It is possible that I will understand the motivation later when
reading the entire patchset. But my initial reaction is confusion ;-)
>From mo POV, it is a lock. It tries to get exclusive access and
has to wait until the current owner releases it.
As you say: "its usage must be carefully considered and most likely
will require programming locklessly." I guess that it is related to:
+ There is a risk of deadlocks that are typically associated with
locks. After all the word "lock" is part of "deadlock".
+ It requires lockless programming because it is supposed to be
terminal lock. It means that no other locks should be taken
under it.
Is there any other API using this naming scheme, please?
I have get() and put() associated with reference counting. But it has
an opposite meaning. It usually guards an object from freeing as long
as there is at least one user. And it allows to have many users.
Regarding the reentrancy. It seems that "_nested" suffix is used for
this type of locks, for example, mutex_lock_nested(),
spin_lock_nested().
It might be enough to add "_nested" suffix and explain why it has
to be used carefully (terminal lock) in a comment.
But I might miss something.
Best Regards,
Petr
Powered by blists - more mailing lists