Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp502471pxu; Fri, 4 Dec 2020 08:23:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5c8UzEBevmXZug5mT48vagg5h5dsq7GNB6xXR6ArbUX5ViTbt1Y55MMHeV0f+8mzn0m4D X-Received: by 2002:a17:906:279a:: with SMTP id j26mr4191468ejc.203.1607099038470; Fri, 04 Dec 2020 08:23:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607099038; cv=none; d=google.com; s=arc-20160816; b=NxWb63GgeO9sQqRn7b+3l2W19S/I/1EtXJF/1u8gHFtxKMNH8JI9fLKU43QD1YVy+S dNTqCTGZ3s+2VDKGVPpIJPgOO+RFiZ9xKOhI3PEHajix4PzHIxcHCgf3YkCD2bS4/W5Z mdy0ZUFWBiHyc0eAh0Hlc9ZN6fDv7nbs2XqZu4OeSHXNfJaVRCVXSb48/1X9R3XBaW3h wiWBJp7Dq1DqKQxSrYs/qYDe33SFghUPdN8v0gRWEFtkjQorZsIBE7P8OB782PX0fkT3 UYOvZR6PiiOVJHBh0xmbAO1H0GmrkkikxJkODAxCyt/y884wL/vttO1E59zF/5HJPt/d 1OoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pvBA2QTEG8+DUV0iSoBYtADWus09fWKoB/UzFWsmqN8=; b=MZCkTDpH2+k+l/jECnz3edA0/ufgYnXFGzUGq/hvrmqt4EPwgfaZVlPTCfOOfkY/bi hzMMBubW9KoQrTu3q8wvYR+sNQNknuSx5izb51rTbgnJ3nabqAklQ5VyoLmXjwa6EV0u kA4rs/bjKYaaTM+GJOb8ijInXOjU6qimgNjBgB5vJWlfF3rKIFA174SYrkxHy17U96Xh NPhXlBNvZZK39ziBjvSbWjStMgsM8gy6IQC5gmxrcNxszaRhIGcdLNZ6MOY8J2g2BYh4 5UuA/Dxyt+M4Xzu57JYPEnUfmHJl3XD9/TZlLJj9HzSgcUuG/I6CZoNjDlHkuRkkZwHf qwEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=pP1NiLho; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oi22si1892824ejb.690.2020.12.04.08.23.34; Fri, 04 Dec 2020 08:23:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=pP1NiLho; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727125AbgLDQT6 (ORCPT + 99 others); Fri, 4 Dec 2020 11:19:58 -0500 Received: from mx2.suse.de ([195.135.220.15]:40604 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbgLDQT6 (ORCPT ); Fri, 4 Dec 2020 11:19:58 -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=1607098752; 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=pvBA2QTEG8+DUV0iSoBYtADWus09fWKoB/UzFWsmqN8=; b=pP1NiLhoYJieaoHPa0IAePw45pEfzZ+93mPAex6q3D0lLMeMjuQzPNJDODYXzl+bQ3Kk7C iW9ESl0DUBthsOGRHwtGEAfsvar+vELiZUl8mIrcyhoMUve0ym/LBvpOYvHSJopeUKVaeR 4lzO7nCNKm1k4NsGmLuKy63keTpjVRw= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 0C0DBAC9A; Fri, 4 Dec 2020 16:19:12 +0000 (UTC) Date: Fri, 4 Dec 2020 17:19:11 +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: consoles: 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201201205341.3871-4-john.ogness@linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/internal.h > +++ b/kernel/printk/internal.h > @@ -59,7 +57,7 @@ void defer_console_output(void); > __printf(1, 0) int vprintk_func(const char *fmt, va_list args) { return 0; } > > /* > - * In !PRINTK builds we still export logbuf_lock spin_lock, console_sem > + * In !PRINTK builds we still export console_sem > * semaphore and some of console functions (console_unlock()/etc.), so > * printk-safe must preserve the existing local IRQ guarantees. We should revisit whether it is still needed just for console_sem. Well, I wonder why we need printk_safe at all. > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -2432,7 +2490,6 @@ void console_unlock(void) > size_t len; > > printk_safe_enter_irqsave(flags); Why do we actually need to use the printk_safe context here? There is not longer a risk of deadlock caused by logbuf_lock. All other recursions should be prevented by console_trylock() in printk(). Do I miss anything? Note that we still need to disable interrupts around console_lock_spinning_enable(); console_lock_spinning_disable_and_check(); to make sure that printk() could busy wait for passing the console lock. > - raw_spin_lock(&logbuf_lock); > skip: > if (!prb_read_valid(prb, console_seq, &r)) > break; Best Regards, Petr