Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2268035pxu; Mon, 7 Dec 2020 01:54:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJy001MEG+/E4vQPKt+zRcOeTwTcsFrjAZVw0uk5UpD1d6pKV+JFA2LMme0UeEUbZjWrgtVb X-Received: by 2002:a17:906:90d6:: with SMTP id v22mr18275811ejw.88.1607334869679; Mon, 07 Dec 2020 01:54:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607334869; cv=none; d=google.com; s=arc-20160816; b=G0rsmIKZntFSFWxfKpGJvi/WtpZ8IHdvq5HHZeZJfahZ3DRUBpTcX2XPZEAIidd/TD U78wyYYVgGuvG5ccChVJSjX7yC71zM9xb8egTJUi+1zswaRSGAbTe8fRRokMnBKZ7v38 U/KRQnepO5AA4slnPJaHQfk/qYPBQg5mtdGL8pkQjDNmyLo2E0pz1UG9wTDjLgHtgYpE GB/mJ0TIEpYT2GDOofnMnT2v+VluYxiS84gjRQqSlMk0vq6R7yucEOp9Ax37i8zpVVdL edBeIrfHhjNhhqFTC1SdimkGqobBK7E7zKtZS2F9n052+EDSfd2WoJCIKJBRhcNI5hri wXtQ== 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=5oB5c9ZsUdrU98e8x3Xd8C+cSkMMOcaStdQxfT8FnL0=; b=UVfwbTb+8hQ6i/qM0por8fh+j7xpJvepLrI175rlVAWllQFZwdCa+wtDzCiojQDe97 P4g7urE8FHq6k3qXGILVu8QBuB+vgHKJg91/ltsbipNVB0gI2hK1oDvz+A4hu3w87wV1 xGzC/h7hG0WF8U62mVZz1Z6CuhYAXbKR++iK885x2tE0dMNiMCLjb07HBpHVyIZg3WuV tE5Bob6P4Zt2DAspSoqCOOqLR3ijGpLDYKxJLTeghJd3OTCV3c9PZBJHY1U6FHW5ezT5 iFULmBswofClXpV5m6KoIYL8c9L2v0DB7GEpc81eCmaNo+qP1P3grlORPX651UFmYVw9 J9ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="f/t4KZsg"; 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 bj25si3406419ejb.456.2020.12.07.01.54.07; Mon, 07 Dec 2020 01:54:29 -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="f/t4KZsg"; 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 S1726438AbgLGJut (ORCPT + 99 others); Mon, 7 Dec 2020 04:50:49 -0500 Received: from mx2.suse.de ([195.135.220.15]:36182 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726129AbgLGJut (ORCPT ); Mon, 7 Dec 2020 04:50:49 -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=1607334602; 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=5oB5c9ZsUdrU98e8x3Xd8C+cSkMMOcaStdQxfT8FnL0=; b=f/t4KZsgZqgxxnGy6WIxWfe+ftoS+YA/Y6QHcmjaGWFn8FDf7lhXTOxrXNM+EwIM3SbC7o rpSQY7W59X1sTv0cRZKNZNyYfUpPXjGPbRpFKTigv6ccamsukt3IySGh1w+QqAfjq91077 0guvtOTYo3cp9ZAX1yFkqBsRjY/5ib0= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C2D93AD7C; Mon, 7 Dec 2020 09:50:02 +0000 (UTC) Date: Mon, 7 Dec 2020 10:50:02 +0100 From: Petr Mladek To: Sergey Senozhatsky Cc: John Ogness , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat 2020-12-05 13:39:53, Sergey Senozhatsky wrote: > On (20/12/04 17:19), Petr Mladek wrote: > [..] > > > --- 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(). > > All semaphore functions, including down_trylock(), acquire > semaphore spin_lock; This has a very easy solution. The patch adds a code that counts recursion level. We just must not call console_trylock() when being inside a recursive printk. printk_safe() has two functions: 1. It allows to store messages a lockless way. This is obsoleted by the lockless ringbuffer. 2. It prevents calling consoles. We could move this check into vprintk_store(). We already have there similar check for printk_deferred(). > and then some call into the scheduler > (or other kernel core functions) under semaphore's spin_lock. > For instance > > up() > raw_spin_lock_irqsave(&sem->lock) > __up() > wake_up_process() > try_to_wake_up() This problem is partly solved by printk_deferred(). In each case, printk_safe() does not help here. I still do _not_ see a reason to keep printk_safe()! Best Regards, Petr