Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4833575ybg; Tue, 29 Oct 2019 13:06:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxomLJ+oOAuBk0C4o3NZXRw1mpDbAnagCtM+U/odvgJM6iCr+59cYuF+fMhTnTYUBaBbjgM X-Received: by 2002:a17:906:5490:: with SMTP id r16mr5197371ejo.308.1572379606513; Tue, 29 Oct 2019 13:06:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572379606; cv=none; d=google.com; s=arc-20160816; b=N5T6efoXUm9eWE6RhcSjxZ4nrmXSUXHyCnZTN6bzRzS6n4EBkWBcU0cfOiCsLLoTLt AYamedPRaWSkl88OjL3S3TcAkfdHWpoSXIfoeBdjIR1M6Ui7jK+RYbVgxTetiSR7iYpU 5AQbew6ofDwpg1zABCgkYHuNBmoi+mfQocQph9hXCyxdu3AI7nQEiNV/mvzbtBVyVieF yXL/7js1EGd+Z2qlHANAEWkXotcMYQpHBPC1FYgxAKvE2z89yglX6AHctc3CgJSargqR E94wFOTlMKL/bHmWb87Dg0L1NIIP8alDAyFC3kSWcmwxPeBE3JpuSeOVRIkFu1Jbw8e2 NAcw== 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=U4HB54/mtH727ar9qXqd6NfANvP47c0Z4dbRlR2ugWI=; b=Bpxk/IKowCA/G4oHlvCHS0XvSao04EOvKt2+vyYPlqIf8XStFJPhXBp/mJDY3crPTT tabO4N/+jCj6SSoCXUU8qk397QVqKSB9qnb2+eXKg8IlvvLAG0xUxooZxhu++C/zS9HB R/rzmSVlHOBHeeS867wiW7j1xzXze1QcSxRS03ARS2Fz+POoYtZN7ASO1n4EMtn2NVgn xBfUqXq39bMIdpmQc4cHXrtSAjhYPBN+1kAsX6kyTL72TTzdBd2IVQ/jXS0W2L8SzRjQ MHKbwPWJdhUixZMJ2XRm8PYRZtnIvyQuPdUk6l4rPtXPRA+ruRwaCDq3sd10Ne262joP 1t6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="T/l34ni9"; 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 v19si9339804ejx.308.2019.10.29.13.06.22; Tue, 29 Oct 2019 13:06:46 -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="T/l34ni9"; 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 S1728729AbfJ2TTc (ORCPT + 99 others); Tue, 29 Oct 2019 15:19:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:50858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725839AbfJ2TTc (ORCPT ); Tue, 29 Oct 2019 15:19:32 -0400 Received: from linux-8ccs (unknown [92.117.159.222]) (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 7090220659; Tue, 29 Oct 2019 19:19:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572376771; bh=yMFBENXBzPYHJDxwTp9VyBRameOLEOvTCdOceGJIy8Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=T/l34ni9ZBUJCqv9+ALck3bG73n6eZygSioJ5tSqUXR2QBr6j7VbsJOULaHjNZ0iZ WM6omtRNjDPj5HR9dRpiI1/6XvTJcA7tBrMveGr0m9Ua8PxtjjlyY56z8JrHBQTkUS Vgz+4h+3Q2TyYE0b2i3nHJXRBjJjQONQ9inI2+vU= Date: Tue, 29 Oct 2019 20:19:25 +0100 From: Jessica Yu To: Rasmus Villemoes Cc: Masahiro Yamada , Matthias Maennich , Greg Kroah-Hartman , Joel Fernandes , Martijn Coenen , Will Deacon , Will Deacon , linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/7] module: avoid code duplication in include/linux/export.h Message-ID: <20191029191925.GA19316@linux-8ccs> References: <20190927093603.9140-1-yamada.masahiro@socionext.com> <20190927093603.9140-5-yamada.masahiro@socionext.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-OS: Linux linux-8ccs 4.12.14-lp150.12.28-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 +++ Rasmus Villemoes [27/09/19 13:07 +0200]: >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") FWIW, I've just tinkered with this, and unfortunately the strings don't get deduplicated for kernel modules :-( Apparently ld does not do the deduplication for SHF_MERGE|SHF_STRINGS sections for relocatable files (ld -r), which kernel modules are. See: https://sourceware.org/ml/binutils/2009-07/msg00291.html But, the strings do get deduplicated for vmlinux. Not sure if we can find a workaround for modules or if the benefit is significant enough if it only for vmlinux. Thanks, Jessica