Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1437865ybb; Fri, 20 Mar 2020 21:29:06 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtXPOt9icXL4XG2VZ40DIwHEOuWxtDsc3v4cyseqAkpjk87BhOAbFfuhG2V/9o1ZOR/oRfb X-Received: by 2002:aca:4986:: with SMTP id w128mr9037207oia.46.1584764946645; Fri, 20 Mar 2020 21:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584764946; cv=none; d=google.com; s=arc-20160816; b=fTFZcPMZ/Po/o98KzmqtdoSuQ7LeiYTHwwjZUtKnUteHg4msjIhSkmKg7E96z2QhUh SN0wg0e8XmlyeIyPbVMUXg3KG0xnfm7hNIO/PLMnwq6pd+vx0cDTEYyTOtw1CmUlxAu+ EbGzD3RMJcvEmqjf/0jHU23XKzWX5W3098V0O91AlrmgbHMJdmCtsYjBSK7G5C5ZMkqk ox33KQLIyY1gtDcjXeZvrlt6kO1poXXmZ3OzPPaKnttXNvIpzWtW6WLAXOAvXWpqUivX hVHtkSHvWMrEXkAqKIgX7LRyYZDh5CfqqMgNaizrbnuwy7f8MdoI2hBzj+WGP1Y7pUmk M3Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=JPjvRjB9mS6/mLTE7KSZUdyp+PxTNmulH6mUWSEICho=; b=ioIXudEpRAGs5rafiWSqzoYZSctHrXVP4eGA6YeJ2SnqGfrIz7O20mqGJoKT1Sg5MB UEbpbGIrNi6CqkEfK/0Cw0xmNhyprFd/DgmB3PCEOham7AZ582E4oBWnBobthVjDzPHe xrnCB5nfygRLEjEcykZIG8ZZmSPDbm0SqdqkOZlV0QVu7Opvv+gfC6IKYTQ/F3MiX28Y 11cA6R73Zn4fqCRHBKDCbsJffnfQtUkWfP0VxFatXV8bZT4OOd2j1Yeh0uABqfhgsZCk 21/tjP/05+4uGmFwL3SgIRyDc0WS8WFBIapYvtCGC2I3r2XLIZr2P8rcMN1ZptEb5GAK YqJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hLC2bkd3; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h12si4195392otr.193.2020.03.20.21.28.24; Fri, 20 Mar 2020 21:29:06 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hLC2bkd3; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727046AbgCUEZe (ORCPT + 99 others); Sat, 21 Mar 2020 00:25:34 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:36779 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgCUEZe (ORCPT ); Sat, 21 Mar 2020 00:25:34 -0400 Received: by mail-lf1-f65.google.com with SMTP id s1so6143440lfd.3 for ; Fri, 20 Mar 2020 21:25:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JPjvRjB9mS6/mLTE7KSZUdyp+PxTNmulH6mUWSEICho=; b=hLC2bkd3HN0Vi7czuBirbBPQDScO2DikGIDWVlQ55uWctTNTGqol26EOnbV2A/G4vP qCZ5d7A9s/kFvdUr6KPKS86LuO9B90q0bBdq/vHBoSz5a+5Y/5CylpbQE24FnK4MaXIA RKiAhhXmcFPvrv1YeIdrNqw9jL8Nb43pBSXXO1lAV9+NYPkgbMiD405AJlXBjJg4oB6B yis6E/zjyQa/GwEtQiAlEBwA+2Rg4Hlc+KbIlAnrP+46aICMuig4RUktyEmysapanq8X b6HzkpEavewd5dRhx1Hn8Id3hByl2MZjVPvXQP29DZcdNW3hXObl9kLicMHB7TiSA5Zn iTEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JPjvRjB9mS6/mLTE7KSZUdyp+PxTNmulH6mUWSEICho=; b=qQ+TIgns7xN9u9ZtmaGe0sucApoy5WDrRBpGkxDGxT3y9jW6p8hIpmuKUh8Dd3PfTT 2d15Qz1vw4ScBU5JzNPHzrjZB7ebIsbcjZAsK4BhzUERxuVctDeEywzD/CmGf71jx0BZ gY0EGKkGcEz+AnBSD6DtzD5ERhhetUhkj7+D+TEZRerhX3WxviihO/5v2j7cfLaFfwSz KYOsz4giYXuL38KepFpPPokYQGenGvtwrOpmJ0CDsJtz5nC/A3epjoMRZrLk2vEjPBLL XDkmai+ImJLHUK3HOG5LSTrotWMiYc1rvrwAeJNmGlrq6fNWHVh7rFNIgSN/l54aZB6M yy3Q== X-Gm-Message-State: ANhLgQ0GtS2w/B2UZsH8k6L3+HXLwTC1ETj50QvVQeMan0/FVe5hyBIH hVqBr1WJJOvfKZ8Gg63YBz4ecLkDbbHvq6GrCUY= X-Received: by 2002:ac2:4c13:: with SMTP id t19mr2497635lfq.16.1584764730836; Fri, 20 Mar 2020 21:25:30 -0700 (PDT) MIME-Version: 1.0 References: <1584558186-23373-1-git-send-email-orson.unisoc@gmail.com> <51568376-da8b-3265-ddb3-6ddba74207dc@akamai.com> In-Reply-To: <51568376-da8b-3265-ddb3-6ddba74207dc@akamai.com> From: Orson Zhai Date: Sat, 21 Mar 2020 12:25:19 +0800 Message-ID: Subject: Re: [RFC PATCH] dynamic_debug: Add config option of DYNAMIC_DEBUG_CORE To: Jason Baron Cc: Orson Zhai , Andrew Morton , Randy Dunlap , Masahiro Yamada , Shuah Khan , Krzysztof Kozlowski , Masami Hiramatsu , Brendan Higgins , Herbert Xu , Ard Biesheuvel , Andy Shevchenko , David Gow , Mark Rutland , Linux Kernel Mailing List , Android Kernel Team Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jason, On Thu, Mar 19, 2020 at 5:18 AM Jason Baron wrote: > > > > On 3/18/20 3:03 PM, Orson Zhai wrote: > > There is the requirement from new Android that kernel image (GKI) and > > kernel modules are supposed to be built at differnet places. Some people > > want to enable dynamic debug for kernel modules only but not for kernel > > image itself with the consideration of binary size increased or more > > memory being used. > > > > By this patch, dynamic debug is divided into core part (the defination of > > functions) and macro replacement part. We can only have the core part to > > be built-in and do not have to activate the debug output from kenrel image. > > > > Signed-off-by: Orson Zhai > > Hi Orson, > > I think this is a nice feature. Is the idea then that driver can do > something like: > > #if defined(CONFIG_DRIVER_FOO_DEBUG) > #define driver_foo_debug(fmt, ...) \ > dynamic_pr_debug(fmt, ##__VA_ARGS__) > #else > no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) > #enif I am thinking this again. Why don't we add a local macro ( I mean not like the global macro from Kconfig ) just like the DEBUG macro? Say DDEBUG or DYN_DEBUG. We can add this to printk.h to let module owners decide when & which module should be dynamic debugged? #ifdef CONFIG_DYNAMIC_DUBUG || DDEUG ..... Module owner can add this to his module's Makefile, for example: .... ccflags-$(CONFIG_UFS_DEBUG) += -DDDEBUG .... This will enable macro replacement for even a single c file. How do you think about it? Best, -Orson > > And then the Kconfig: > > config DYNAMIC_DRIVER_FOO_DEBUG > bool "Enable dynamic driver foo printk() support" > select DYNAMIC_DEBUG_CORE > > > Or did you have something else in mind? Do you have an example > code for the drivers that you mention? > > Thanks, > > -Jason > > > > --- > > include/linux/dynamic_debug.h | 2 +- > > lib/Kconfig.debug | 18 ++++++++++++++++-- > > lib/Makefile | 2 +- > > 3 files changed, 18 insertions(+), 4 deletions(-) > > > > diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h > > index 4cf02ec..abcd5fd 100644 > > --- a/include/linux/dynamic_debug.h > > +++ b/include/linux/dynamic_debug.h > > @@ -48,7 +48,7 @@ struct _ddebug { > > > > > > > > -#if defined(CONFIG_DYNAMIC_DEBUG) > > +#if defined(CONFIG_DYNAMIC_DEBUG_CORE) > > int ddebug_add_module(struct _ddebug *tab, unsigned int n, > > const char *modname); > > extern int ddebug_remove_module(const char *mod_name); > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > > index 69def4a..78a7256 100644 > > --- a/lib/Kconfig.debug > > +++ b/lib/Kconfig.debug > > @@ -97,8 +97,7 @@ config BOOT_PRINTK_DELAY > > config DYNAMIC_DEBUG > > bool "Enable dynamic printk() support" > > default n > > - depends on PRINTK > > - depends on DEBUG_FS > > + select DYNAMIC_DEBUG_CORE > > help > > > > Compiles debug level messages into the kernel, which would not > > @@ -164,6 +163,21 @@ config DYNAMIC_DEBUG > > See Documentation/admin-guide/dynamic-debug-howto.rst for additional > > information. > > > > +config DYNAMIC_DEBUG_CORE > > + bool "Enable core functions of dynamic debug support" > > + depends on PRINTK > > + depends on DEBUG_FS > > + help > > + Enable this option to build ddebug_* and __dynamic_* routines > > + into kernel. If you want enable whole dynamic debug features, > > + select CONFIG_DYNAMIC_DEBUG directly and this option will be > > + automatically selected. > > + > > + This option is selected when you want to enable dynamic debug > > + for kernel modules only but not for the kernel base. Especailly > > + in the case that kernel modules are built out of the place where > > + kernel base is built. > > + > > config SYMBOLIC_ERRNAME > > bool "Support symbolic error names in printf" > > default y if PRINTK > > diff --git a/lib/Makefile b/lib/Makefile > > index 611872c..2096d83 100644 > > --- a/lib/Makefile > > +++ b/lib/Makefile > > @@ -183,7 +183,7 @@ lib-$(CONFIG_GENERIC_BUG) += bug.o > > > > obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o > > > > -obj-$(CONFIG_DYNAMIC_DEBUG) += dynamic_debug.o > > +obj-$(CONFIG_DYNAMIC_DEBUG_CORE) += dynamic_debug.o > > obj-$(CONFIG_SYMBOLIC_ERRNAME) += errname.o > > > > obj-$(CONFIG_NLATTR) += nlattr.o > >