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 0C162C433DB for ; Mon, 22 Feb 2021 16:09:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA3A764E74 for ; Mon, 22 Feb 2021 16:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231439AbhBVQJ1 (ORCPT ); Mon, 22 Feb 2021 11:09:27 -0500 Received: from mx2.suse.de ([195.135.220.15]:39558 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231649AbhBVQGE (ORCPT ); Mon, 22 Feb 2021 11:06:04 -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=1614009917; 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=fymWnnsJD9yF0KQNLsNQHmDiy5LI+Jp/eC+pUhdETqg=; b=Mp7Bpn1ZgI/7N6RkHbPs4X/sFZCgDuoQZZUGyqGIpXabF5OX+SFPdoEPKuXIPJ6sQbIx1H 8ql2HRLV0xKd/P8wXFM6yWDZoL4ovfFOUr8VBGPiatlQodPGDTKSCSC2nIIJ1qMhKn/hoB V34fL+EKXysVgBiQx9qfIzMYCuAODsc= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E8B16AFD8; Mon, 22 Feb 2021 16:05:16 +0000 (UTC) Date: Mon, 22 Feb 2021 17:05:16 +0100 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: [PATCH printk-rework 08/14] printk: add syslog_lock Message-ID: References: <20210218081817.28849-1-john.ogness@linutronix.de> <20210218081817.28849-9-john.ogness@linutronix.de> <875z2o15ha.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <875z2o15ha.fsf@jogness.linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 2021-02-19 15:45:21, John Ogness wrote: > On 2021-02-19, Petr Mladek wrote: > >> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > >> index 20c21a25143d..401df370832b 100644 > >> --- a/kernel/printk/printk.c > >> +++ b/kernel/printk/printk.c > >> +/* Return a consistent copy of @syslog_seq. */ > >> +static u64 read_syslog_seq_irq(void) > >> +{ > >> + u64 seq; > >> + > >> + raw_spin_lock_irq(&syslog_lock); > >> + seq = syslog_seq; > >> + raw_spin_unlock_irq(&syslog_lock); > > > > Is there any particular reason to disable interrupts here? > > > > It would make sense only when the lock could be taken in IRQ > > context. Then we would need to always disable interrupts when > > the lock is taken. And if it is taken in IRQ context, we would > > need to safe flags. > > All other instances of locking @syslog_lock are done with interrupts > disabled. And we have: > > register_console() > logbuf_lock_irqsave() > raw_spin_lock(&syslog_lock) I see. We should revisit this after removing logbuf_lock and printk_safe context. > Looking back through history, I found that locking of the "console lock" > in register_console() was changed from spin_lock_irq() to > spin_lock_irqsave() for 2.3.15pre1 [0]. The only reason I can find why > that was done is because sparc64 was regstering its console in a PROM > callback (the comments there: "Pretty sick eh?"). Note that console_lock was a spinlock in 2.3.15.pre1. I see it defined in kernel/printk.c as: spinlock_t console_lock = SPIN_LOCK_UNLOCKED; But it is a sleeping semaphore these days. As a result, register_console(), as it is now, must not be called in an interrupt context. Best Regards, Petr