From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthias Maennich Subject: Re: [PATCH v3 06/11] export: allow definition default namespaces in Makefiles or sources Date: Wed, 28 Aug 2019 11:56:27 +0100 Message-ID: <20190828105627.GA41539@google.com> References: <20190813121733.52480-1-maennich@google.com> <20190821114955.12788-1-maennich@google.com> <20190821114955.12788-7-maennich@google.com> <20190828104951.GC25048@linux-8ccs> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Return-path: Content-Disposition: inline In-Reply-To: <20190828104951.GC25048@linux-8ccs> Sender: linux-kernel-owner@vger.kernel.org To: Jessica Yu Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, arnd@arndb.de, geert@linux-m68k.org, gregkh@linuxfoundation.org, hpa@zytor.com, joel@joelfernandes.org, kstewart@linuxfoundation.org, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-modules@vger.kernel.org, linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org, lucas.de.marchi@gmail.com, maco@android.com, maco@google.com, michal.lkml@markovi.net, mingo@redhat.com, oneukum@suse.com, pombredanne@nexb.com, sam@ravnborg.org, sspatil@google.com, stern@rowland.harvard.edu, tglx@linutronix.de, usb-storage@lists.one-eyed-alien.net, x86@kernel.org, yamada.masahiro@socionext.com, Michael Ellerman , Ingo Molnar , Ard Biesheuvel List-Id: linux-arch.vger.kernel.org On Wed, Aug 28, 2019 at 12:49:51PM +0200, Jessica Yu wrote: >+++ Matthias Maennich [21/08/19 12:49 +0100]: >>To avoid excessive usage of EXPORT_SYMBOL_NS(sym, MY_NAMESPACE), where >>MY_NAMESPACE will always be the namespace we are exporting to, allow >>exporting all definitions of EXPORT_SYMBOL() and friends by defining >>DEFAULT_SYMBOL_NAMESPACE. >> >>For example, to export all symbols defined in usb-common into the >>namespace USB_COMMON, add a line like this to drivers/usb/common/Makefile: >> >> ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE=USB_COMMON >> >>That is equivalent to changing all EXPORT_SYMBOL(sym) definitions to >>EXPORT_SYMBOL_NS(sym, USB_COMMON). Subsequently all symbol namespaces >>functionality will apply. >> >>Another way of making use of this feature is to define the namespace >>within source or header files similar to how TRACE_SYSTEM defines are >>used: >> #undef DEFAULT_SYMBOL_NAMESPACE >> #define DEFAULT_SYMBOL_NAMESPACE USB_COMMON >> >>Please note that, as opposed to TRACE_SYSTEM, DEFAULT_SYMBOL_NAMESPACE >>has to be defined before including include/linux/export.h. >> >>If DEFAULT_SYMBOL_NAMESPACE is defined, a symbol can still be exported >>to another namespace by using EXPORT_SYMBOL_NS() and friends with >>explicitly specifying the namespace. > >This changelog provides a good summary of how to use >DEFAULT_SYMBOL_NAMESPACE, I wonder if we should explicitly document >its proper usage somewhere? (along with EXPORT_SYMBOL_NS*) >The EXPORT_SYMBOL API is briefly documented in >Documentation/kernel-hacking/hacking.rst - it might be slightly dated, >but perhaps it'd fit there best? I will add documentation along with the commits. Not only for the macros, but in general to describe the feature. >>Suggested-by: Arnd Bergmann >>Reviewed-by: Martijn Coenen >>Reviewed-by: Greg Kroah-Hartman >>Signed-off-by: Matthias Maennich >>--- >>include/linux/export.h | 6 ++++++ >>1 file changed, 6 insertions(+) >> >>diff --git a/include/linux/export.h b/include/linux/export.h >>index 8e12e05444d1..1fb243abdbc4 100644 >>--- a/include/linux/export.h >>+++ b/include/linux/export.h >>@@ -166,6 +166,12 @@ struct kernel_symbol { >>#define __EXPORT_SYMBOL ___EXPORT_SYMBOL >>#endif >> >>+#ifdef DEFAULT_SYMBOL_NAMESPACE >>+#undef __EXPORT_SYMBOL >>+#define __EXPORT_SYMBOL(sym, sec) \ >>+ __EXPORT_SYMBOL_NS(sym, sec, DEFAULT_SYMBOL_NAMESPACE) >>+#endif >>+ >>#define EXPORT_SYMBOL(sym) __EXPORT_SYMBOL(sym, "") >>#define EXPORT_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_gpl") >>#define EXPORT_SYMBOL_GPL_FUTURE(sym) __EXPORT_SYMBOL(sym, "_gpl_future") >>-- >>2.23.0.rc1.153.gdeed80330f-goog >> From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f65.google.com ([209.85.221.65]:41003 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726315AbfH1K4e (ORCPT ); Wed, 28 Aug 2019 06:56:34 -0400 Received: by mail-wr1-f65.google.com with SMTP id j16so2005853wrr.8 for ; Wed, 28 Aug 2019 03:56:32 -0700 (PDT) Date: Wed, 28 Aug 2019 11:56:27 +0100 From: Matthias Maennich Subject: Re: [PATCH v3 06/11] export: allow definition default namespaces in Makefiles or sources Message-ID: <20190828105627.GA41539@google.com> References: <20190813121733.52480-1-maennich@google.com> <20190821114955.12788-1-maennich@google.com> <20190821114955.12788-7-maennich@google.com> <20190828104951.GC25048@linux-8ccs> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190828104951.GC25048@linux-8ccs> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Jessica Yu Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, arnd@arndb.de, geert@linux-m68k.org, gregkh@linuxfoundation.org, hpa@zytor.com, joel@joelfernandes.org, kstewart@linuxfoundation.org, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-modules@vger.kernel.org, linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org, lucas.de.marchi@gmail.com, maco@android.com, maco@google.com, michal.lkml@markovi.net, mingo@redhat.com, oneukum@suse.com, pombredanne@nexb.com, sam@ravnborg.org, sspatil@google.com, stern@rowland.harvard.edu, tglx@linutronix.de, usb-storage@lists.one-eyed-alien.net, x86@kernel.org, yamada.masahiro@socionext.com, Michael Ellerman , Ingo Molnar , Ard Biesheuvel Message-ID: <20190828105627.62qIxJi6GnKVmlgMqKmPXPcV-JRG5jN73eFNViGG1Os@z> On Wed, Aug 28, 2019 at 12:49:51PM +0200, Jessica Yu wrote: >+++ Matthias Maennich [21/08/19 12:49 +0100]: >>To avoid excessive usage of EXPORT_SYMBOL_NS(sym, MY_NAMESPACE), where >>MY_NAMESPACE will always be the namespace we are exporting to, allow >>exporting all definitions of EXPORT_SYMBOL() and friends by defining >>DEFAULT_SYMBOL_NAMESPACE. >> >>For example, to export all symbols defined in usb-common into the >>namespace USB_COMMON, add a line like this to drivers/usb/common/Makefile: >> >> ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE=USB_COMMON >> >>That is equivalent to changing all EXPORT_SYMBOL(sym) definitions to >>EXPORT_SYMBOL_NS(sym, USB_COMMON). Subsequently all symbol namespaces >>functionality will apply. >> >>Another way of making use of this feature is to define the namespace >>within source or header files similar to how TRACE_SYSTEM defines are >>used: >> #undef DEFAULT_SYMBOL_NAMESPACE >> #define DEFAULT_SYMBOL_NAMESPACE USB_COMMON >> >>Please note that, as opposed to TRACE_SYSTEM, DEFAULT_SYMBOL_NAMESPACE >>has to be defined before including include/linux/export.h. >> >>If DEFAULT_SYMBOL_NAMESPACE is defined, a symbol can still be exported >>to another namespace by using EXPORT_SYMBOL_NS() and friends with >>explicitly specifying the namespace. > >This changelog provides a good summary of how to use >DEFAULT_SYMBOL_NAMESPACE, I wonder if we should explicitly document >its proper usage somewhere? (along with EXPORT_SYMBOL_NS*) >The EXPORT_SYMBOL API is briefly documented in >Documentation/kernel-hacking/hacking.rst - it might be slightly dated, >but perhaps it'd fit there best? I will add documentation along with the commits. Not only for the macros, but in general to describe the feature. >>Suggested-by: Arnd Bergmann >>Reviewed-by: Martijn Coenen >>Reviewed-by: Greg Kroah-Hartman >>Signed-off-by: Matthias Maennich >>--- >>include/linux/export.h | 6 ++++++ >>1 file changed, 6 insertions(+) >> >>diff --git a/include/linux/export.h b/include/linux/export.h >>index 8e12e05444d1..1fb243abdbc4 100644 >>--- a/include/linux/export.h >>+++ b/include/linux/export.h >>@@ -166,6 +166,12 @@ struct kernel_symbol { >>#define __EXPORT_SYMBOL ___EXPORT_SYMBOL >>#endif >> >>+#ifdef DEFAULT_SYMBOL_NAMESPACE >>+#undef __EXPORT_SYMBOL >>+#define __EXPORT_SYMBOL(sym, sec) \ >>+ __EXPORT_SYMBOL_NS(sym, sec, DEFAULT_SYMBOL_NAMESPACE) >>+#endif >>+ >>#define EXPORT_SYMBOL(sym) __EXPORT_SYMBOL(sym, "") >>#define EXPORT_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_gpl") >>#define EXPORT_SYMBOL_GPL_FUTURE(sym) __EXPORT_SYMBOL(sym, "_gpl_future") >>-- >>2.23.0.rc1.153.gdeed80330f-goog >>