[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87ley73ka2.fsf@jogness.linutronix.de>
Date: Fri, 18 Feb 2022 23:09:01 +0106
From: John Ogness <john.ogness@...utronix.de>
To: Petr Mladek <pmladek@...e.com>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
Thomas Gleixner <tglx@...utronix.de>,
linux-kernel@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [PATCH printk v1 11/13] printk: reimplement console_lock for
proper kthread support
On 2022-02-18, John Ogness <john.ogness@...utronix.de> wrote:
>> This is another complexity. An easier solution would be to do:
>>
>> console_trylock()
>> {
>> if (down_trylock(&console_sem))
>> return failed;
>>
>> for_each_console(con) {
>> if (mutext_trylock(&con->lock))
>> goto fail;
>> }
>>
>> // sucess
>>
>> fail:
>> for_each_console(con_fail) {
>> if (con_fail == con)
>> break;
>> mutex_unlock(&con->lock);
>> }
>
> No, this cannot work. Semaphores are the _only_ synchonization object in
> the kernel that is allowed to perform a trylock from any context
> (because they don't have owners).
Sorry, I need to clarify this bold statement.
Semaphores are the only synchonization object in the kernel that is
allowed to perform a trylock from any context and does not disable
preemption upon locking. (This is important because console lock holders
expect preemption to be unaffected when taking the lock.)
John
Powered by blists - more mailing lists