Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3284203ybn; Fri, 27 Sep 2019 04:08:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqysYL8TGKCxDlOjTpg9BSfYdVzoiW23jH5sdR6pn3BWYIKBEws5q82XRiXClOYna0d+gEPn X-Received: by 2002:a50:cf8b:: with SMTP id h11mr3614056edk.236.1569582534057; Fri, 27 Sep 2019 04:08:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569582534; cv=none; d=google.com; s=arc-20160816; b=gSkdvoSN3ukv8/i7PKfa2lkiHA2HIBxIrd2afQuSvWsFerbySsIEH4LLIh2MPNJxuu 9uMQ67e4LWFqaqO8ZV1uDfyte0Zd1d3CL1OKzGj72eHSQWgDE12N20xYwTcKrnYYHE1C 0zypOIS1sM4l45zOAa3PlFpH2ASmCmCmxmRbacORkGRO7dfZAtOgXJD2Ux7uH5423eqh u6U/oirrvbp9QNqDYNRa5AfwtwFssV1QYo9ocAWAN0hCXs7bWn1uDR/qETh7QKcY9gOt Wzme8lwwJ1QPZOrD+kEignJvIjgK4i4U4PzPPs9R5UvDST1x0KgxwQNvIvkFxX1H52Bn sIeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=3oGUOoJ5SW+DTMVPL3UUtjpNbyCkNbodWu3m4weaNuM=; b=eg0OjLx3QcMCbyXud9wdlyiyyerk41R05MfjxDUOHBXJSpbKHTxt6G2cUDb0MAmYRr XHmL16MKyOkvWZl/o2BoR8ixBs8Q0TmJ74gkD5elgEx/Mz1B+Jcg6lnJw6/1JJAy+lMn GmF8X+p9oGEZVuQjGOeLErJ01Fng/OuRC7gNmOL6HoUQgLfrbncmdvtKbS3ttdTFmAXl GUzHnvjphdyvIYjWuLrIdk9GvzznqXYhnPUeSn+pCwSJNLKS4brF9OpQIt4dXdQNPql1 LdFRxIJC7S+NkZO8txI/KvfyhdFu4CrmzYuNA8UgbHRlHLRYruWSGnrkQz7OFPIYIcxU xv4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=MEkjkBrs; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y20si1269042edo.436.2019.09.27.04.08.28; Fri, 27 Sep 2019 04:08:54 -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=@rasmusvillemoes.dk header.s=google header.b=MEkjkBrs; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726809AbfI0LHk (ORCPT + 99 others); Fri, 27 Sep 2019 07:07:40 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:42525 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbfI0LHk (ORCPT ); Fri, 27 Sep 2019 07:07:40 -0400 Received: by mail-lj1-f193.google.com with SMTP id y23so2059368lje.9 for ; Fri, 27 Sep 2019 04:07:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=3oGUOoJ5SW+DTMVPL3UUtjpNbyCkNbodWu3m4weaNuM=; b=MEkjkBrs2zp8UeloIli/4sMbZayjf5Iv+cPRCAAQKAc5OCQGFgu1WIwzwRoI2QZZZT lqXy7UZOvzGC+5hY7w/kuAO8LPexJQa5xRGo999UZs385hUUFNeDw/1+q6Am+ap03NTJ V7y9eLlvBUF2F+8iySWyNEJm64qOw8aWp6w/Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=3oGUOoJ5SW+DTMVPL3UUtjpNbyCkNbodWu3m4weaNuM=; b=Ez79PeX3hF9W/uiGy64zYzqsR23fyBK+hlV2xrAN5+UHRS9bdN3GVqS+/FyrvwrK1h imVHpC/7QGkLdtlxcM+CAZOUHZQFmmNaRk/jMCPNP+ZNYqbGaiIl6AD9T0z7M2kbR38w WxTM4iwxxgVTFFFv2KGv0sBFAn6nnrTTnL02yuKzv+D7B3iAzpN6VfUaMheqEcZsAnfk dYpnaBJrFtDBWo6cNJXBtf2A5ocIuHaeHNOixPe+mY4AqO0khNhCjDteyluNazwAsLbq kAX72x+j7+VdUF0NLKIYogvJJFpZb9PvBvUFiqVohipHU2x9BnUldKKQtM2w/0j+qpyM 6aZQ== X-Gm-Message-State: APjAAAW0wvyYwCoxwur6ajWJBcRQZoMRNJjONTWXtnFE1FqZf9kPYnsi 3GBPkHv+VKfOvwRfSTg31CA+0jdlXclXMN/K X-Received: by 2002:a2e:9584:: with SMTP id w4mr2509460ljh.145.1569582456181; Fri, 27 Sep 2019 04:07:36 -0700 (PDT) Received: from [172.16.11.28] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id m21sm415265lfh.39.2019.09.27.04.07.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Sep 2019 04:07:35 -0700 (PDT) Subject: Re: [PATCH 4/7] module: avoid code duplication in include/linux/export.h To: Masahiro Yamada , Jessica Yu Cc: Matthias Maennich , Greg Kroah-Hartman , Joel Fernandes , Martijn Coenen , Will Deacon , Will Deacon , linux-kernel@vger.kernel.org References: <20190927093603.9140-1-yamada.masahiro@socionext.com> <20190927093603.9140-5-yamada.masahiro@socionext.com> From: Rasmus Villemoes Message-ID: Date: Fri, 27 Sep 2019 13:07:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190927093603.9140-5-yamada.masahiro@socionext.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/09/2019 11.36, Masahiro Yamada wrote: > include/linux/export.h has lots of code duplication between > EXPORT_SYMBOL and EXPORT_SYMBOL_NS. > > To improve the maintainability and readability, unify the > implementation. > > When the symbol has no namespace, pass the empty string "" to > the 'ns' parameter. > > The drawback of this change is, it grows the code size. > When the symbol has no namespace, sym->namespace was previously > NULL, but it is now am empty string "". So, it increases 1 byte > for every no namespace EXPORT_SYMBOL. > > A typical kernel configuration has 10K exported symbols, so it > increases 10KB in rough estimation. > > I did not come up with a good idea to refactor it without increasing > the code size. Can't we put the "aMS" flags on the __ksymtab_strings section? That would make the empty strings free, and would also deduplicate the USB_STORAGE string. And while almost per definition we don't have exact duplicates among the names of exported symbols, we might have both a foo and __foo, so that could save even more. I don't know if we have it already, but we'd need each arch to tell us what symbol to use for @ in @progbits (e.g. % for arm). It seems most are fine with @, so maybe a generic version could be #ifndef ARCH_SECTION_TYPE_CHAR #define ARCH_SECTION_TYPE_CHAR "@" #endif and then it would be section("__ksymtab_strings,\"aMS\","ARCH_SECTION_TYPE_CHAR"progbits,1") But I don't know if any tooling relies on the strings not being deduplicated. Rasmus