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 1740CC433FE for ; Mon, 7 Dec 2020 10:02:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF4932310B for ; Mon, 7 Dec 2020 10:02:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726774AbgLGKCS (ORCPT ); Mon, 7 Dec 2020 05:02:18 -0500 Received: from mx2.suse.de ([195.135.220.15]:53970 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726083AbgLGKCS (ORCPT ); Mon, 7 Dec 2020 05:02:18 -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=1607335292; 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=fNtQCj2fjbnzevCdger0bAZFwvYkYL3KGN2+UIjMuPM=; b=upTCCywKTECKFbCIO5K2h5Tfpb8EnOWZCFI+SE1BWi2g8hogBuZmwiLE/VkLo4UdFvpxeK no/3qYkci4abIgmzu4lh7Gbry6ilG7T3Pp1cU/GutVzzeWPL61wWyVqSookcLXd4dLFqk0 S92UrMCzg5W+qhU7vSGJ4ij7lrVTkqE= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2DB7EAC55; Mon, 7 Dec 2020 10:01:32 +0000 (UTC) Date: Mon, 7 Dec 2020 11:01:31 +0100 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: syslog: was: [PATCH next v2 3/3] printk: remove logbuf_lock, add syslog_lock Message-ID: References: <20201201205341.3871-1-john.ogness@linutronix.de> <20201201205341.3871-4-john.ogness@linutronix.de> <87v9demype.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87v9demype.fsf@jogness.linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun 2020-12-06 22:12:21, John Ogness wrote: > On 2020-12-04, Petr Mladek wrote: > > On Tue 2020-12-01 21:59:41, John Ogness wrote: > >> Since the ringbuffer is lockless, there is no need for it to be > >> protected by @logbuf_lock. Remove @logbuf_lock. > >> > >> --- a/kernel/printk/printk.c > >> +++ b/kernel/printk/printk.c > >> @@ -2809,11 +2856,7 @@ void register_console(struct console *newcon) > >> nr_ext_console_drivers++; > >> > >> if (newcon->flags & CON_PRINTBUFFER) { > >> - /* > >> - * console_unlock(); will print out the buffered messages > >> - * for us. > >> - */ > >> - logbuf_lock_irqsave(flags); > >> + spin_lock_irqsave(&syslog_lock, flags); > > > > We should take the lock only around assigning syslog_seq. And add a > > comment that it guarantees atomic update. > > OK. So you just want "exclusive_console = newcon;" moved outside the > critical section. Exactly, I would like to make it clear that it synchronizes only the single assignment. Otherwise, people might get wrong assumption. I know that there is a comment describing the scope of each lock. But people might miss it or do not search for it at all. Best Regards, Petr