All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthias Maennich <maennich@google.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>,
	Jessica Yu <jeyu@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Joel Fernandes <joel@joelfernandes.org>,
	Martijn Coenen <maco@android.com>,
	Will Deacon <will.deacon@arm.com>, Will Deacon <will@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/7] module: avoid code duplication in include/linux/export.h
Date: Fri, 27 Sep 2019 13:36:13 +0100	[thread overview]
Message-ID: <20190927123613.GD259443@google.com> (raw)
In-Reply-To: <f2e28d6b-77c5-5fe2-0bc4-b24955de9954@rasmusvillemoes.dk>

On Fri, Sep 27, 2019 at 01:07:33PM +0200, Rasmus Villemoes wrote:
>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 was not aware of this possibility and I was a bit bothered that I was
not able to deduplicate the namespace strings in the PREL case. So, at
least I tried to avoid having the redundant empty strings in it. If this
approach solves the deduplication problem _and_ reduces the complexity
of the code, I am very much for it. I will only be able to look into
this next week.

>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.

Matthias
Cheers,

>Rasmus

  reply	other threads:[~2019-09-27 12:36 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-27  9:35 [PATCH 0/7] module: various bug-fixes and clean-ups for module namespace Masahiro Yamada
2019-09-27  9:35 ` [PATCH 1/7] modpost: fix broken sym->namespace for external module builds Masahiro Yamada
2019-09-27  9:56   ` Masahiro Yamada
2019-09-27 11:46   ` Matthias Maennich
2019-09-27  9:35 ` [PATCH 2/7] module: swap the order of symbol.namespace Masahiro Yamada
2019-09-27 12:07   ` Matthias Maennich
2019-09-27  9:35 ` [PATCH 3/7] module: rename __kstrtab_ns_* to __kstrtabns_* to avoid symbol conflict Masahiro Yamada
2019-09-27 12:14   ` Matthias Maennich
2019-09-27  9:36 ` [PATCH 4/7] module: avoid code duplication in include/linux/export.h Masahiro Yamada
2019-09-27  9:58   ` Masahiro Yamada
2019-09-27 11:07   ` Rasmus Villemoes
2019-09-27 12:36     ` Matthias Maennich [this message]
2019-10-29 19:19     ` Jessica Yu
2019-10-29 21:11       ` Rasmus Villemoes
2019-10-31 10:13         ` Jessica Yu
2019-10-31 11:03           ` Rasmus Villemoes
2019-10-31 11:26             ` Jessica Yu
2019-09-27  9:36 ` [PATCH 5/7] kbuild: fix build error of 'make nsdeps' in clean tree Masahiro Yamada
2019-09-27 12:44   ` Matthias Maennich
2019-09-27  9:36 ` [PATCH 6/7] nsdeps: fix hashbang of scripts/nsdeps Masahiro Yamada
2019-09-27 13:10   ` Matthias Maennich
2019-09-27  9:36 ` [PATCH 7/7] nsdeps: make generated patches independent of locale Masahiro Yamada
2019-09-27 13:27   ` Matthias Maennich
2019-09-27 15:42     ` Masahiro Yamada
2019-09-27 18:14       ` Greg Kroah-Hartman
2019-09-29  1:18         ` Masahiro Yamada
2019-09-29  1:30           ` Masahiro Yamada
2019-10-01 11:46             ` Matthias Maennich
2019-09-29 10:14           ` Greg Kroah-Hartman
2019-09-27 13:41 ` [PATCH 0/7] module: various bug-fixes and clean-ups for module namespace Matthias Maennich
2019-09-27 15:43   ` Masahiro Yamada
2019-10-02 18:57   ` Jessica Yu
2019-10-02 20:43     ` Matthias Maennich
2019-10-03  1:26     ` Masahiro Yamada
2019-10-03  8:03     ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190927123613.GD259443@google.com \
    --to=maennich@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jeyu@kernel.org \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=maco@android.com \
    --cc=will.deacon@arm.com \
    --cc=will@kernel.org \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.