From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AC68C433E6 for ; Tue, 2 Mar 2021 10:31:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D4CAC64EE8 for ; Tue, 2 Mar 2021 10:31:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383000AbhCBK2J (ORCPT ); Tue, 2 Mar 2021 05:28:09 -0500 Received: from mx2.suse.de ([195.135.220.15]:38720 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382760AbhCBKN3 (ORCPT ); Tue, 2 Mar 2021 05:13:29 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1614679962; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YXXc7AQv1pqE/dRNpAhoKuRsqfR3x8w5S1lFIECmSg8=; b=KaQ2PwfYTSpIajwKR1VYEfuRJRuYlLHKOvPxekMwA9Bfn80eDSNCLaK0Wt2Xasak8hSV1f 0Ra0VPZPtM3rlGFqSgyxu5igRjnd3QlMKZrUKB0TL0x8X47zfaDCm48KD52wtGYhr00SJY fcNDNvmTOymy3TQbRFhPdEDcDFEdUyA= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D4E0DB07D; Tue, 2 Mar 2021 10:12:41 +0000 (UTC) Date: Tue, 2 Mar 2021 11:12:41 +0100 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jeff Dike , Richard Weinberger , Anton Ivanov , Thomas Meyer , Andy Shevchenko , linux-um@lists.infradead.org Subject: Re: [PATCH next v3 01/15] um: synchronize kmsg_dumper Message-ID: References: <20210225202438.28985-1-john.ogness@linutronix.de> <20210225202438.28985-2-john.ogness@linutronix.de> <87y2f6yo7k.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87y2f6yo7k.fsf@jogness.linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2021-03-02 09:06:07, John Ogness wrote: > On 2021-03-01, Petr Mladek wrote: > >> > diff --git a/arch/um/kernel/kmsg_dump.c b/arch/um/kernel/kmsg_dump.c > >> > index 6516ef1f8274..4869e2cc787c 100644 > >> > --- a/arch/um/kernel/kmsg_dump.c > >> > +++ b/arch/um/kernel/kmsg_dump.c > >> > @@ -1,5 +1,6 @@ > >> > // SPDX-License-Identifier: GPL-2.0 > >> > #include > >> > +#include > >> > #include > >> > #include > >> > #include > >> > @@ -9,6 +10,7 @@ > >> > static void kmsg_dumper_stdout(struct kmsg_dumper *dumper, > >> > enum kmsg_dump_reason reason) > >> > { > >> > + static DEFINE_SPINLOCK(lock); > >> > static char line[1024]; > >> > struct console *con; > >> > size_t len = 0; > >> > @@ -29,11 +31,16 @@ static void kmsg_dumper_stdout(struct kmsg_dumper *dumper, > >> > if (con) > >> > return; > >> > > >> > + if (!spin_trylock(&lock)) > >> > >> I have almost missed this. It is wrong. The last version correctly > >> used > >> > >> if (!spin_trylock_irqsave(&lock, flags)) > >> > >> kmsg_dump(KMSG_DUMP_PANIC) is called in panic() with interrupts > >> disabled. We have to store the flags here. > > > > Ah, I get always confused with these things. spin_trylock() can > > actually get called in a context with IRQ disabled. So it is not > > as wrong as I thought. > > > > But still. panic() and kmsg_dump() can be called in IRQ context. > > So, this function might be called in IRQ context. So, it feels > > more correct to use the _irqsafe variant here. > > > > I know that there is the trylock so it probably does not matter much. > > Well, the disabled irq might help to serialize the two calls when > > one is in normal context and the other would happen in IRQ one. > > > > As I said, using _irqsafe variant looks better to me. > > For the record, the reason I removed the _irqsave for v3 is because I > felt like it was misleading, appearing to be necessary when it is not. > > I think anyone could argue both sides. Yeah, I could imagine myself to have different opinion another day or year. I am sorry for the noise. > But it really doesn't matter > (especially for arch/um). I will use the _irqsave variant for v4. I am > OK with that. Please do, if it is easy. You are going to send v4 anyway. Best Regards, Petr