Received: by 10.223.164.221 with SMTP id h29csp187055wrb; Fri, 3 Nov 2017 07:34:27 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Tp7K/YaJTVd+jZEGjw+BP8gtoki1YwyNG+1IZC5HE3Qsz7tPvh4o7Q9G+5skdrdIvFk2jT X-Received: by 10.99.142.196 with SMTP id k187mr7156537pge.384.1509719667281; Fri, 03 Nov 2017 07:34:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509719667; cv=none; d=google.com; s=arc-20160816; b=uL3KpK89bVJ4YJ1Gq3om6/9uxtVUBBx/Rd556QprMwhz/lG8WwYk24+lfo1dd+Hxvx Y0MTkF2L+JSmUS3lbafQF3FpjFELBMdx/FqAGb3FtksMhjOE1Mc5ZCINtFreJJRKYTVY eKdr226Q9LUJsC5+rpvZQS8F7PDr2TfKwa++DioBGBql8/4R0lvx0Hz0UFskjvvIQ+qF VlVdiR+w5AJgMj6mevATECidwZNhXOnvbIORsvRdFTVxc/b/6PPCk+PMsVkIqOO0sZxE E6vU7OpJz3N08JuiqtGuPA3UAMhV/S5z3B4eRiaJMjT2tnumNMzCue6QlRfpCQmido8U IUCQ== 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=zhLUiYUnywKs4Asijtv2DZa1sXj8j/CWemIAIeROmkU=; b=g5ghtX+kas4rIzXsgU6aN+hrnh8WdyIpXO9lwOmQkDL5D62FQSZ2BR19S+Mda3LTtB VvnnQNcIzlCf/gyapLMsZp/Yy3zwtfTSvdFwhuY304t5qusKN7GBGgyTXIzNaGgmYD6/ gPFLl5hNrXDKyMx51aGFZPKD7XwD/2/sOKSP/YB6d+U3TrR7PMtyxYiPq2eMTITXkLHn ReDPu3MSdupP3IS71xl4mHatlQ3YXowCzGVI5u8S+epuxGoY6/n1saqyAoONi3JW+J06 Vxfl4LQk1APH5ZJEatbXNbksinIWfQpbnlEIMqaIAFPNyZ2GxNo837oggQmXMBTmeT1Z NUJQ== 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 k9si6319806pgs.704.2017.11.03.07.34.14; Fri, 03 Nov 2017 07:34:27 -0700 (PDT) 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 S1754539AbdKCOcY (ORCPT + 95 others); Fri, 3 Nov 2017 10:32:24 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60756 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751623AbdKCOcX (ORCPT ); Fri, 3 Nov 2017 10:32:23 -0400 Received: from localhost (LFbn-1-12253-150.w90-92.abo.wanadoo.fr [90.92.67.150]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1817F93C; Fri, 3 Nov 2017 14:32:21 +0000 (UTC) Date: Fri, 3 Nov 2017 15:32:34 +0100 From: Kroah-Hartman To: Petr Mladek Cc: Calvin Owens , 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: <20171103143234.GA7801@kroah.com> References: <08c1dc1a96afd6b6aecc5ff3c7c0e62c36670893.1506644730.git.calvinowens@fb.com> <20171103142114.GG31148@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171103142114.GG31148@pathway.suse.cz> 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 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. > 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. That is if you _really_ feel you need sysfs interaction with the console layer (hint, I am not yet convinced...) > > }; > > > > /* > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > > index 3f1675e..488bda3 100644 > > --- a/kernel/printk/printk.c > > +++ b/kernel/printk/printk.c > > @@ -105,6 +105,8 @@ enum devkmsg_log_masks { > > > > static unsigned int __read_mostly devkmsg_log = DEVKMSG_LOG_MASK_DEFAULT; > > > > +static struct kobject *consoles_dir_kobj; > > > > static int __control_devkmsg(char *str) > > { > > if (!str) > > @@ -2371,6 +2373,82 @@ static int __init keep_bootcon_setup(char *str) > > > > early_param("keep_bootcon", keep_bootcon_setup); > > > > +static ssize_t loglevel_show(struct kobject *kobj, struct kobj_attribute *attr, > > + char *buf) > > +{ > > + struct console *con; > > + ssize_t ret = -ENODEV; > > + > > This might deserve a comment. Something like: > > /* > * Find the related struct console a safe way. The kobject > * desctruction is asynchronous. > */ > > + console_lock(); > > + for_each_console(con) { > > + if (con->kobj == kobj) { You are doing something wrong, go from kobj to your console directly, the fact that you can not do that here is a _huge_ hint that your structure is not correct. Hint, it's not correct at all :) Please cc: me on stuff like this if you want a review, and as you are adding a random new sysfs root directory, please always cc: me on that so I can talk you out of it... thanks, greg k-h From 1583055091010432897@xxx Fri Nov 03 14:23:01 +0000 2017 X-GM-THRID: 1579832740601012796 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread