Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp330770ybm; Thu, 28 May 2020 04:02:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqaRWXC3B6heOqdOjSGsGKomrTivKvrDCWkJphWiy42K01bHyLAZrHgcl9u2D4sHVHY/3T X-Received: by 2002:a17:907:1103:: with SMTP id qu3mr2310564ejb.453.1590663761392; Thu, 28 May 2020 04:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590663761; cv=none; d=google.com; s=arc-20160816; b=xsGHzitmmvBz5wh+rQ8fMrsASbmJYjOsJIwgwpvX7r813CMhxgj4FZQuL5C4rtN9sr 3HYgv7NQKtgzZBv7UNLRJ2asqP2M6m49IQ9gzF+QAThW/bJ4bb8nv0K9pFWe728Yk2NC uofXogsBLlZFjbHeFoZVMvZ2v3Ftad0qfZ0DtXanfQ3V0O5bLdopC6Z9z639PEm+KUjb 9qLKwktEcSyZ/g7fwCI4ey2ZJzVqFyUr0da5Ifgp/nC4EVhAPlMpbvmri0gfBbRH55pa RFC8DUZu0eZBjXAaJcI79CrRFlZe+PI9TL8Yznrap8U7o2yS67NdlCU+LAZ7V1iBzLdo k88g== 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; bh=TpY1r4Wm6EUpwXaSyJMtvE8Qkr7r/daCZOf42YYhxmA=; b=TakCAP1ymlnH6m+uMuH72f7wmTNUxaa8Wpx1/fXFfirelQBPA9hPk9DvB7qOi3+/0g JcmlA6DM3+MY1lu3UiAGrrMDmarG8ZE6+4B9dok/1ZF1WsXNb1wIQiOP0QmwMw+PyVYc XwcnuJn7MZGg/oBHAvMw6R6JQS+sX1vr79zkUSnLFTxyuouuWn0WYkg6axklJZ/I47p6 J4hEMSxHE4FFXM6yeRqJwkrKmacNZaeFfhtMDtVnutkYncRaYt1pQEnK3kJu4EXItylp 3wZWm7R/4J0PldE832pfA2b+CoX6OZppwlGDdZm2LUL7mlo6FusiIvTCdcER4kU7Xp/E +z4w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dh1si3257955edb.78.2020.05.28.04.02.16; Thu, 28 May 2020 04:02:41 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388047AbgE1K7r (ORCPT + 99 others); Thu, 28 May 2020 06:59:47 -0400 Received: from mx2.suse.de ([195.135.220.15]:37710 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387926AbgE1K7q (ORCPT ); Thu, 28 May 2020 06:59:46 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id EFA69AB5C; Thu, 28 May 2020 10:59:43 +0000 (UTC) Date: Thu, 28 May 2020 12:59:43 +0200 From: Petr Mladek To: Tetsuo Handa Cc: Sergey Senozhatsky , Andrew Morton , linux-kernel@vger.kernel.org, Dmitry Vyukov , Ondrej Mosnacek , Steven Rostedt Subject: Re: [PATCH] twist: allow converting pr_devel()/pr_debug() into printk(KERN_DEBUG) Message-ID: <20200528105942.GB11286@linux-b0ei> References: <20200524145034.10697-1-penguin-kernel@I-love.SAKURA.ne.jp> <20200525084218.GC5300@linux-b0ei> <20200525091157.GF755@jagdpanzerIV.localdomain> <20200527083747.GA27273@linux-b0ei> <35d76737-8d23-9fb2-8e55-507109317f44@i-love.sakura.ne.jp> <20200527155504.GD3529@linux-b0ei> 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2020-05-28 08:33:37, Tetsuo Handa wrote: > On 2020/05/28 0:55, Petr Mladek wrote: > >>> Well, it would be possible to call vsprintf() with NULL buffer. It is > >>> normally used to calculate the length of the message before it is > >>> printed. But it also does all the accesses without printing anything. > >> > >> OK. I think that redirecting pr_debug() to vsnprintf(NULL, 0) will be > >> better than modifying dynamic_debug path, for > > > > It might get more complicated if you would actually want to see > > pr_debug() messages for a selected module in the fuzzer. > > I don't expect that automated testing can afford selectively enabling > DYNAMIC_DEBUG_BRANCH(id) conditions. But we could evaluate all arguments > by calling snprintf(NULL, 0) if the condition to call printk() is false. > > > vsprintf(NULL, ) can be called for pr_debug() messages in > > vprintk_store(). It will be again only a single place for > > all printk() wrappers. > > I couldn't catch what you mean. The problem of pr_debug() is that > vprintk_store() might not be called because of > > #define no_printk(fmt, ...) \ > ({ \ > if (0) \ > printk(fmt, ##__VA_ARGS__); \ > 0; \ > }) > > #define pr_debug(fmt, ...) \ > no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) > > or > > #define __dynamic_func_call(id, fmt, func, ...) do { \ > DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ > if (DYNAMIC_DEBUG_BRANCH(id)) \ > func(&id, ##__VA_ARGS__); \ > } while (0) > > #define _dynamic_func_call(fmt, func, ...) \ > __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) > > #define dynamic_pr_debug(fmt, ...) \ > _dynamic_func_call(fmt, __dynamic_pr_debug, \ > pr_fmt(fmt), ##__VA_ARGS__) > > #define pr_debug(fmt, ...) \ > dynamic_pr_debug(fmt, ##__VA_ARGS__) That is exactly the problem. Your current patch [1] adds checks for the CONFIG_TWIST into 15 different locations. This is perfectly fine for testing in linux-next whether this twist is worth the effort. But I do not like this as a long term solution. If the testing shows that it was really helpful and you would want to get this into Linus' tree. Then I would like to do the twist at different level: 1. Add twist into ddebug_add_module() and enable all newly added entries by default. For example, by calling ddebug_exec_query("*:+p", const char *modname) or what is the syntax. This will cause that any pr_devel() variant will always get called. 2. Add twist into vprintk_store(). In the current, implementation it would do: #if TWIST return text_len; #endif return log_output(facility, level, lflags, dict, dictlen, text, text_len); Something similar would need to be done also in printk_safe(). Hot you could ignore this because it would be used only in very few scenarios. In the lock_less variant, we would need to format the message into small buffer on stack to detect the log level from the first few bytes. The approach will cause that pr_devel() message will never get really printed when this TWIST is enabled. But you mention that automatic testing would not do so anyway. [1] https://lore.kernel.org/r/20200528065603.3596-1-penguin-kernel@I-love.SAKURA.ne.jp Best Regards, Petr