Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp680353ybl; Wed, 28 Aug 2019 03:51:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeEEeP7d8h6K2EXWw+x/nTKonR20LN4oNnQ4jg5uKY1dRbXGc9VtE07ufNA+a0ZT0zWtJg X-Received: by 2002:a17:90a:23c5:: with SMTP id g63mr3587975pje.124.1566989469200; Wed, 28 Aug 2019 03:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566989469; cv=none; d=google.com; s=arc-20160816; b=VV+T0NQ1b/pX2XxBk+R7w7XaWhxljtJTxKDquS3bQYARQ5b7PmwTHFMYbzeCHxOFMh bB6bN53b+Fm2puiAYKZolhHZMUHAhSJYeVOaXE/QnmL7D9Sy0Dmx8dqRuExHNZ0zDQK0 2g5aVHriQvK1abAjheXj3q+XWLguQ3Guarw9gYpBkEG4z+jc+rH8FhwISjOQtzNlY6WT C8DcL/7Pz1ItrbaYjx1BR2mE+lqKdBGRlM5BIrSMrWjT6Ky0unbrVVp5aFNIIZRs8Fu7 cOoxZTc4T8+4cBC5I05mF0rpdg5+i2TE+1DL8LG59USEeOhA1sr6H4M4lM2jyrPhOeCO xPGw== 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:dkim-signature; bh=ZZ7Dmd81LPIbnGwgo7W/Mphut/qFhqHN/H9wiGjZxXE=; b=sDDUdXhWwd7PQmrFwPirQihKwu3so0GUvZa7Cf1S0mWLoye1grwnqMUxIbBe/Gqo1x HjRws+rx4o67e7h0K79xmW4t3mPIClzfZ4VwPyG5ytR1MqC3QBn3QS1TaDf+jI2hIkld wvvsPdJ/rmb2lcL/Yi+AIOPsz/Mc4IMS2dMuBj5QKX/ttGjz0JNL9TqtXMf8auAzBRY/ HS5FVpb+aDuesoEVVAuH+JvHZ+/gsXvpc610ydX9TvGH+qreeXqGSMis/dkWdXA8W17v YoANG5infaM05DFRBNbLmntlyOVrs5t2j5WGTqaJvvXhCIdOt2q7EPiPqYuz+mKgcxh6 TEoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i40dmLIc; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 16si2067006pfc.213.2019.08.28.03.50.52; Wed, 28 Aug 2019 03:51:09 -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=@kernel.org header.s=default header.b=i40dmLIc; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726394AbfH1KuC (ORCPT + 99 others); Wed, 28 Aug 2019 06:50:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:55992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726232AbfH1KuC (ORCPT ); Wed, 28 Aug 2019 06:50:02 -0400 Received: from linux-8ccs (ip5f5adbee.dynamic.kabel-deutschland.de [95.90.219.238]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0AA242173E; Wed, 28 Aug 2019 10:49:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566989401; bh=He3MdEl4k4wvBwy2BRtUix0E0BXxfd11sG2nGJHSlno=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=i40dmLIc4hNolwteO8/CrjM9Cpmu93uXZsAOD1MxRqDqkwMajOhi3Dh0Ac1J5QGbq LszHHQ0TpbI6YImDsJdcJH+2MQ+nkwnpo8Rh7e8htHxd79vlrmg8Y4hcNYyhaKnSc2 TcnnzjJhpv8JAIXkqv1vRtuz4HQ/xogZe5mhW1hk= Date: Wed, 28 Aug 2019 12:49:51 +0200 From: Jessica Yu To: Matthias Maennich 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 Subject: Re: [PATCH v3 06/11] export: allow definition default namespaces in Makefiles or sources Message-ID: <20190828104951.GC25048@linux-8ccs> References: <20190813121733.52480-1-maennich@google.com> <20190821114955.12788-1-maennich@google.com> <20190821114955.12788-7-maennich@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190821114955.12788-7-maennich@google.com> X-OS: Linux linux-8ccs 4.12.14-lp150.12.61-default x86_64 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 +++ 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? >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 >