Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp686811imw; Thu, 14 Jul 2022 08:58:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tSL1XVAPDrpNDtCIS6JKrCyNy77aAtO1oFakPWdvJmoLiQ4invrhnqpYVOoJF9dUC8kMY2 X-Received: by 2002:a17:90b:1b4f:b0:1f0:e99:ecb0 with SMTP id nv15-20020a17090b1b4f00b001f00e99ecb0mr10747742pjb.204.1657814333107; Thu, 14 Jul 2022 08:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657814333; cv=none; d=google.com; s=arc-20160816; b=pSKhZS9mH7Z+trs079LEuuFSG6fAO6ghL5yTTZTIbTmq1qhSltzsU8pE4oF8Gz6mEq CJhoR7+Wzts8NNO0JMkGPsbv3LSoIC9WrSp4uy2NuWAqVxpo4HPfyY1zNlX3HxYFb6qM wY5kViwr67h+0vxsjxhBFu0McjNo+cCFkWzGTnTUSiquePOq0T7rDl6CrtCq6KMRB8WE cJV9XI+Jwsndl4I8ApVSha0wsORmMa7auM6KxIKDSTm1BonAaLL5ndN3bsHPfofJcdJl roLsXHyzgsqIy3JpeNZGrtzsfwqUtET9ycVjEOOZLIMCTx3VO4LhJFgoNU8TIe3Qn9bL XXmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=XQWaVdLD70toOI+SR3wOUg+mBWXwEMBEZLfRcTC1fD4=; b=bX/Q+KtWAcxTnhnq82iiiM6tlykFsBXV6j5n2ysnvO3zW/w7+98T9hYDwFg/T1QEma q8CnNdjHffG41+Yb1CK8uRxDMxonMV6wKdelqRxxldt3JUPC8AliB4hsvcAm+jV09TkR FA5pbG1mogTfCoFiif+s6/aVFb0ldhQeOK8LhSU5ZVDD1Jevd5PoCZXVLfJ5K7Azcckz 6I4ywu1gOuq6m+iE3J2L1YzFa3D7gIzh6flhgkUmvs7CnbytNrFE3IclFPVydxX+UaH1 fBFcrPcX04a0ACdMb6UjkHjFFf0LDtjfPtdAjQlhTI1ReTTSFBU0u/B4w4+bI0wiP4SG sTQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=eSEpnnGx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j16-20020a056a00131000b0052ae4903fb7si2893843pfu.330.2022.07.14.08.58.37; Thu, 14 Jul 2022 08:58:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=eSEpnnGx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238858AbiGNPo5 (ORCPT + 99 others); Thu, 14 Jul 2022 11:44:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbiGNPo4 (ORCPT ); Thu, 14 Jul 2022 11:44:56 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A982AE4E for ; Thu, 14 Jul 2022 08:44:55 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 8AD5D34825; Thu, 14 Jul 2022 15:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1657813492; 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=XQWaVdLD70toOI+SR3wOUg+mBWXwEMBEZLfRcTC1fD4=; b=eSEpnnGxLoQoppy4ZF4AWBkl01L7v147/n6GDqO20lzvHFLaw0Cq9Ii88MkiKJN333Pfud B8mQQnffJ/UJoZ2iSs4jbM267vhxBEIM5BPZxIZ379oCAoFLiDGJEA8G7VQ35+z79SqnXL mHxg1642pmQlZ1aqcHrqJ4yX1rTrq4w= Received: from suse.cz (pathway.suse.cz [10.100.12.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 3FDCA2C141; Thu, 14 Jul 2022 15:44:52 +0000 (UTC) Date: Thu, 14 Jul 2022 17:44:52 +0200 From: Petr Mladek To: Chris Down Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Sergey Senozhatsky , Steven Rostedt , John Ogness , Geert Uytterhoeven , kernel-team@fb.com Subject: Re: design: was: Re: [RFC PATCH v2] printk: console: Allow each console to have its own loglevel Message-ID: <20220714154452.GB24338@pathway.suse.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2022-07-13 15:49:19, Chris Down wrote: > Petr Mladek writes: > > IMHO, this makes things too complicated. A better solution is to do > > not allow to set any log level below this limit in the first place. > > Hmm, how should we then handle the case that you have set the per-console > loglevel to 3 and minimum_console_loglevel later gets changed to 5? > > We had this problem when designing cgroup v2 as well, for example in cases > where a child requests a higher memory protection than can be afforded by > the parent, or where a child sets a higher memory limit than a parent > specifies. We went back and forth and eventually settled on allowing these, > because the alternatives seemed difficult to reason about or unnecessarily > inflexible. I see. > From the per-console loglevel side, one option is to return ERANGE or EINVAL > on values we know won't be honoured when setting the per-console loglevel. > The problem with that is that it doesn't allow to specify a "desired" limit > in case the external factors (in this case, the minimum loglevel) change. > This is even more difficult to reason about in our case because the minimum > loglevel may be changed dynamically outside of user control. > > Another is to disallow setting the minimum loglevel without first resetting > consoles which are above the value that is desired to be set, but this seems > really cumbersome, and again it doesn't account for cases like panic() and > elsewhere where we blindly change it anyway. > > Maybe you have another idea about how it should work in the case that the > minimum loglevel would take precedence over an existing loglevel? minimum_console_loglevel is currently used only in syslog interface. It is ignored when the levels are set using sysctl. IMHO, the reason is that sysctl might eventually get called even with less privileged user. I would keep this behavior. I mean that a change of minimum_console_loglevel would not affect other values immediately. It will be used to crop the value when anyone wants to change the global loglevel via syslog later. Well, it would make sense to crop the global or per-console loglevels even when they are later changed via the new sysctl or sysfs interface. It would be a limit for less privileged users. Maybe, it is over-engineered. I wonder if anyone really uses the minimum level in practice. > > > + * ``ignore_loglevel``: ``ignore_loglevel`` was specified on the kernel > > > + command line. Restart without it to use other controls. > > > + > > > +* ``enabled`` (r): Whether the console is enabled. > > > +* ``loglevel`` (rw): The local loglevel for this console. This will be in > > > + effect if no other global control overrides it. Look at > > > + ``effective_loglevel`` and ``effective_loglevel_source`` to verify that. > > > > > > +Deprecated > > > +~~~~~~~~~~ > > > + > > > +* ``syslog(SYSLOG_ACTION_CONSOLE_*)``: This sets > > > > Why does it use "_*"? It looks like the entire syslog interface is > > obsolete. But this patch affects only three actions: ON, OFF, LEVEL. > > Not totally sure I know what you mean -- SYSLOG_ACTION_CONSOLE_* limits it > to those, no? > > % git grep -ho 'SYSLOG_ACTION_CONSOLE_[A-Z0-9]\+' | sort -u > SYSLOG_ACTION_CONSOLE_LEVEL > SYSLOG_ACTION_CONSOLE_OFF > SYSLOG_ACTION_CONSOLE_ON I see. I missed that the other SYSLOG_ACTIONs do not have the "_CONSOLE". Forget about it. > > > + ``kernel.force_console_loglevel``. It is unaware of per-console loglevel > > > + semantics and is not recommended. A warning will be emitted if it is used > > > + while local loglevels are in effect. > > > > Do we really want to obsolete it? It might be enough to say > > that it works as force_console_loglevel. > > That's also fine -- my only concern with syslog() is that it's not very > explicit about what will happen to consoles with a per-console loglevel set. > > That said, once this is merged I suppose we can make it more clear in > downstream consumers like `dmesg -n`, so not a big issue either way. :-) Honestly, I consider syslog as a legacy code. It supports only one reader. A better way to read the messages is /dev/kmsg and dmesg uses it be default now. I am not sure if people/admins really use dmesg to change the console loglevel. IMHO, sysctl or sysfs should be the preferred way. I think that it is enough to make the behavior clear in the documentation. Best Regards, Petr