Received: by 10.223.164.202 with SMTP id h10csp613057wrb; Thu, 9 Nov 2017 00:04:06 -0800 (PST) X-Google-Smtp-Source: ABhQp+RPw34X9SeBqtgIqmzj+96NYTQfFeGaz8WXFyK52TGEDQwL5DhwjAXnskumDXXCqEyJsERf X-Received: by 10.98.152.147 with SMTP id d19mr3240825pfk.95.1510214646212; Thu, 09 Nov 2017 00:04:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510214646; cv=none; d=google.com; s=arc-20160816; b=GeDvaUMvQ9lnZhzsGC8EmxHY2ypl40jLGR2PVK0gPWs++8MiUxtFdnWEP8R8izWG2+ Ey11+kHhiONGQ3KlcsMv/V1/mIcsI88Li/7U/3SHIkP+Y+dp8ZdoyivBtFChS3BbfFer oPeyf8OvFnsyqSGJHAzO9hDz+DyNFDkd2CrGyDzRVZUQe+DGrfefwiEyR4DZK216ajll IZP3sEiQlZiNk0L1a7DVkYBzzIS/ROSCR2SSmitjZ2jkGn/H07TDfhf32wtNJb7pCLYi 7KNq6VDgMdRq0ywEi5sgtJ8d5qDyOCHdr40HKgdYZXDak3z45oaNGHf8UFVmgYr6OPkk cwZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=knK9FmyoVquR9hULlT+dA7GK5RcIcPllOGjrXhEk78Q=; b=Yk+QT5fgZxB0Rjz6yOXBoJo4S5CcltUVg5ahpb7K8stW3GJGsRLocZIfFDtQPdeT62 er3nVGxiqXLlNf6SmqAApe4VYZDznqP46KrxvZ27eCr15PoretTw5fEthkNmAjlDAP2f XcSN19YMI7TEruhtXp2ucgg5ji2EGWIGzKSZnY62dr+VuttwqpnnTCbBVZJWjXfxk4V2 Xz6Hw5YxphgFrl31gFGx4kXLC/MteQCdH491hxdYMX5EMxy57bzbZQGUh1RO72aqH/+P WgkFArGOzxQlh+Jt9cdoYz4X0PYq7bdRgMdr6QhfBLZnPqCLoznxWtpxLPhJ5TfkFdtJ hzig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4si5757112plb.430.2017.11.09.00.03.55; Thu, 09 Nov 2017 00:04:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753144AbdKIIDM (ORCPT + 81 others); Thu, 9 Nov 2017 03:03:12 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:49878 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752891AbdKIIDK (ORCPT ); Thu, 9 Nov 2017 03:03:10 -0500 Received: from localhost (LFbn-1-12253-150.w90-92.abo.wanadoo.fr [90.92.67.150]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 76A006C; Thu, 9 Nov 2017 08:03:09 +0000 (UTC) Date: Thu, 9 Nov 2017 09:03:21 +0100 From: Kroah-Hartman To: Calvin Owens Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , linux-api@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH 2/3] printk: Add /sys/consoles/ interface Message-ID: <20171109080321.GB17098@kroah.com> References: <08c1dc1a96afd6b6aecc5ff3c7c0e62c36670893.1506644730.git.calvinowens@fb.com> <20171103142114.GG31148@pathway.suse.cz> <20171103143234.GA7801@kroah.com> <519f471b-47dc-3367-f702-119a9d82ba9b@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <519f471b-47dc-3367-f702-119a9d82ba9b@fb.com> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 08, 2017 at 01:32:53PM -0800, Calvin Owens wrote: > On 11/03/2017 07:32 AM, Kroah-Hartman wrote: > > On Fri, Nov 03, 2017 at 03:21:14PM +0100, Petr Mladek wrote: > > > On Thu 2017-09-28 17:43:56, Calvin Owens wrote: > > > > This adds a new sysfs interface that contains a directory for each > > > > console registered on the system. Each directory contains a single > > > > "loglevel" file for reading and setting the per-console loglevel. > > > > > > > > We can let kobject destruction race with console removal: if it does, > > > > loglevel_{show,store}() will safely fail with -ENODEV. This is a little > > > > weird, but avoids embedding the kobject and therefore needing to totally > > > > refactor the way we handle console struct lifetime. > > > > > > It looks like a sane approach. It might be worth a comment in the code. > > > > > > > > > > Documentation/ABI/testing/sysfs-consoles | 13 +++++ > > > > include/linux/console.h | 1 + > > > > kernel/printk/printk.c | 88 ++++++++++++++++++++++++++++++++ > > > > 3 files changed, 102 insertions(+) > > > > create mode 100644 Documentation/ABI/testing/sysfs-consoles > > > > > > > > diff --git a/Documentation/ABI/testing/sysfs-consoles b/Documentation/ABI/testing/sysfs-consoles > > > > new file mode 100644 > > > > index 0000000..6a1593e > > > > --- /dev/null > > > > +++ b/Documentation/ABI/testing/sysfs-consoles > > > > @@ -0,0 +1,13 @@ > > > > +What: /sys/consoles/ > > > > Eeek, what! > > > > > I rather add Greg in CC. I am not 100% sure that the top level > > > directory is the right thing to do. > > > > Neither do I. > > Sure. This is a placeholder I choose arbitrarily pending some real input on > the location, sorry I didn't make that clear. > > > > Alternative might be to hide this under /sys/kernel/consoles/. > > > > No no no. > > > > > > +Date: September 2017 > > > > +KernelVersion: 4.15 > > > > +Contact: Calvin Owens > > > > +Description: The /sys/consoles tree contains a directory for each console > > > > + configured on the system. These directories contain the > > > > + following attributes: > > > > + > > > > + * "loglevel" Set the per-console loglevel: the kernel uses > > > > + max(system_loglevel, perconsole_loglevel) when > > > > + deciding whether to emit a given message. The > > > > + default is 0, which means max() always yields > > > > + the system setting in the kernel.printk sysctl. > > > > > > I would call the attribute "min_loglevel". The name "loglevel" should > > > be reserved for the really used loglevel that depends also on the > > > global loglevel value. > > > > > > > > > > diff --git a/include/linux/console.h b/include/linux/console.h > > > > index a5b5d79..76840be 100644 > > > > --- a/include/linux/console.h > > > > +++ b/include/linux/console.h > > > > @@ -148,6 +148,7 @@ struct console { > > > > void *data; > > > > struct console *next; > > > > int level; > > > > + struct kobject *kobj; > > > > Why are you using "raw" kobjects and not a "real" struct device? This > > is a device, use that interface instead please. > > > > If you need a console 'bus' to place them on, fine, but the virtual bus > > is probably best and simpler to use. > > The problem is that the console corresponds to no actual device (this is what > Petr was getting at in the other mail). A console *may* be associated with a real > TTY device, but this isn't universally true (for example, see netconsole_ext). > > Embedding a device struct in the console structure is problematic for the same > reason embedding a raw kobject is: we'd need to rewrite all the code to deal with > the new refcount/release semantics. That's ok, that is what you _should_ do :) > While that's certainly possible, it ends up being a much bigger thorny change. If > we deal with the "get()/deregister()" race in a safe way, it becomes very simple. > > (If it were as trivial as replacing kfrees with puts and adding release callbacks, > that'd be the obvious way to go, but of course it doesn't end up being that nice...) I agree it's not trivial, but it's the correct change here, don't try to abuse the driver core / kobjects, they will come back to bite you :) > > That is if you _really_ feel you need sysfs interaction with the console > > layer (hint, I am not yet convinced...) > > How would you expose this setting if not via sysfs? All I care about is having the > setting, how exactly userspace pokes it is not at all important :) A per-console log-level? I don't know, how do per-console settings work today, ioctls? "Fixing" consoles properly would be great work to undertake... thanks, greg k-h From 1583535216802341354@xxx Wed Nov 08 21:34:25 +0000 2017 X-GM-THRID: 1579832740601012796 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread