Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3261498lfo; Mon, 23 May 2022 00:14:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHrfd4LVbUVgA0jUHaGBb5CDANeyxUETg1e6UlkjYxk43Z4OFQxZrvZnsGIoXtZAHRrz8r X-Received: by 2002:a05:6a00:1501:b0:510:7ab8:71c8 with SMTP id q1-20020a056a00150100b005107ab871c8mr22249491pfu.63.1653290075833; Mon, 23 May 2022 00:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653290075; cv=none; d=google.com; s=arc-20160816; b=qElN7q8s3DB+Ji3rIxtDP1o8X7fex7aotMLTnRrEu8vFOvk09BBKJZvdt+Kx8s+Scu 19mVydwRVh28Qe4G5DTPBjD+e0oLWaKAFI5SjfMd5clDVTzFcvEb0bYEnmYpFxAbd0NL qwxIUxm3sm9gIvEV7DUBP/Knrf044Vi8kOdeeBvf+uuuq0OcfQ0e5divbgAz00IdfA2N AzO1OjIwH+qtAXuzQYLu/A0GKtiSAiTddLEd7G4S3VmtQJOQRzwvdkPwEdppKQJgKDAN OxTx1nbyzeVBoc3X2zSSRVBM4xJJNGQvczuFswj9AcSjO77cTKQDCVyUm1U7lowSCiMM 3R8Q== 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=nWr11zO2aTcQ3KKIu/HO+725FLZdnOGJGltSVhQW1L0=; b=A/P+9yCcBpS6RFQ8V1yKiUDdAxvi8yy71Se4+57AFZFIJWP/9C8UkK1qxubUPmLJIc 5eXK02agfnhDEl1VDrRT0ifU2YbdqUo8TmD675PYb/02FdAsfIMyhq99pRihTNobAldP wTtt5Y8VeyezDbqT8KuWc1xNU0c0ZKEBp2+BZCB8hvpeLq7/LNM0Tz8vu3bnkTo5VvFl JfpXp6b+S76yHjyLjjLZ4zrRbDdzS7ZxZ6OPsJfnc1NGAdfQ81d2q+PNijVaar5M8OyS Gi2dEf9zbN5RhB5S0E/u4ir/KGaP+Mj6IGbquNVtbrT/QboBNw0ySuVw9JVh6U5VMAoE 3hSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TGGJ08U2; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 7-20020a17090a198700b001dbc6208771si12041566pji.45.2022.05.23.00.14.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:14:35 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TGGJ08U2; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0A1B246B1E; Sun, 22 May 2022 23:32:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344774AbiEUSwF (ORCPT + 99 others); Sat, 21 May 2022 14:52:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344798AbiEUSwA (ORCPT ); Sat, 21 May 2022 14:52:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF4BD5C341 for ; Sat, 21 May 2022 11:51:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 872DE60DDE for ; Sat, 21 May 2022 18:51:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77F2EC385A5; Sat, 21 May 2022 18:51:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653159117; bh=4a11RXV/P0yTS0XIaPt7J8rctdIFw3mOzT4l99BkB0E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TGGJ08U2YoVpVz6bP4IuS3N0lk9D+F6jMSBCYAzPoJGK0bl0vDsEkaNh8kysOALN9 Ee0JDpBIkxnBIPD1Reyf7d1STteYJSsTdGKLq1VYMF1kQPtCBW93zL9TtX2s4O8646 kKj4uHRAWMBSmAr6iWfpWQKzK9Fe+FTqQWIDtZGo= Date: Sat, 21 May 2022 20:51:54 +0200 From: Greg Kroah-Hartman To: Chris Down Cc: linux-kernel@vger.kernel.org, Petr Mladek , Sergey Senozhatsky , Steven Rostedt , John Ogness , Geert Uytterhoeven , kernel-team@fb.com Subject: Re: [RFC PATCH v2] printk: console: Allow each console to have its own loglevel Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Fri, May 20, 2022 at 01:57:19PM +0100, Chris Down wrote: > [Once the goals of this patch are generally agreed upon, it can be split > out further with more detailed changelogs if desired.] > > Consoles can have vastly different latencies and throughputs. For > example, writing a message to the serial console can take on the order > of tens of milliseconds to get the UART to successfully write a message. > While this might be fine for a single, one-off message, this can cause > significant application-level stalls in situations where the kernel > writes large amounts of information to the console. > > This means that while you might want to send at least INFO level > messages to (for example) netconsole, which is relatively fast, you may > only want to send at least WARN level messages to the serial console. > Such an implementation would permit debugging using the serial console > in cases that netconsole doesn't receive messages during particularly > bad system issues, while still keeping the noise low enough to avoid > inducing latency in userspace applications. This patch adds such an > interface, extending the existing console loglevel controls to allow > each console to have its own loglevel. > > One can't just disable the serial console, because one may actually need > it in situations where the machine is in a bad enough state that nothing > is received on netconsole. One also can't just bump the loglevel at > runtime after the issue, because usually the machine is already so > wedged by this point that it isn't responsive to such requests. > > In terms of technical implementation, this patch embeds a device pointer > in the console struct, and registers each console using it so we can > expose attributes in sysfs. > > The lifecycle of this classdev looks like this on registration: > > register_console(con)/printk_late_init() > console_register_device(con) > device_initialize(con->classdev) # refcount++ > device_add(con->classdev) # refcount++ > > At stable state, the refcount is two. > > Console unregistration looks like this: > > [con->classdev refcount drops to 0] > console_classdev_release(con->classdev) > kfree(con->classdev) > > unregister_console(con) > device_unregister(con->classdev) > device_del(con->classdev) # refcount-- > device_remove_class_symlinks() > kernfs_remove_by_name_ns() > kernfs_drain() > kernfs_drain_open_files() # wait for close() > put_device(con->classdev) # refcount-- > > We also deprecate the kernel.printk sysctl as it doesn't know about > per-console loglevels, and is generally pretty confusing. > > For information on the precedence and application of the new controls, > see Documentation/ABI/testing/sysfs-class-console and > Documentation/admin-guide/per-console-loglevel.rst. > > Signed-off-by: Chris Down > --- > Documentation/ABI/testing/sysfs-class-console | 50 +++ > .../admin-guide/kernel-parameters.txt | 18 +- > .../admin-guide/per-console-loglevel.rst | 116 ++++++ > Documentation/admin-guide/serial-console.rst | 17 +- > Documentation/core-api/printk-basics.rst | 34 +- > Documentation/networking/netconsole.rst | 17 + > MAINTAINERS | 3 + > include/linux/console.h | 23 ++ > include/linux/kern_levels.h | 2 + > init/main.c | 2 +- > kernel/printk/console_cmdline.h | 2 + > kernel/printk/printk.c | 352 ++++++++++++++++-- > kernel/printk/sysctl.c | 95 ++++- > 13 files changed, 680 insertions(+), 51 deletions(-) > create mode 100644 Documentation/ABI/testing/sysfs-class-console > create mode 100644 Documentation/admin-guide/per-console-loglevel.rst You forgot what changed from v1 :( Anyway, the driver model interaction looks good to me, nice work, no objections at all. gre gk-h