Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1972618ybl; Thu, 19 Dec 2019 06:06:29 -0800 (PST) X-Google-Smtp-Source: APXvYqyy2WTsn1R6H3qprdViTXR+CZCO4d+jcpmwYbF2aL5rj9YEiXze3aGhnB3CcbUvj+Yy/nRt X-Received: by 2002:a9d:7ccc:: with SMTP id r12mr9478409otn.22.1576764389622; Thu, 19 Dec 2019 06:06:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576764389; cv=none; d=google.com; s=arc-20160816; b=QaXuxqotMfzMtLBDlCu02n2VCkyBKGeQxZ8lN117ljj+gqnreYE4GKjHzBZa9RUaIz yZTXTuS+gzbU1/+AStD/WPznndk96eG5/dJ3HtpUbGlv6J55lRFl6QlTpseBs72LG7kZ iXllmmNF7mqbmjT1huZwgdFlnFIK2NI7fJ9EPUiGcpaOlB54DmJ5KLsz3LJOEXEJPBjv qzirp85XLDPTkFh3xI3kaxf6vgCMZT3t8q0w49qErFSLemPEKa9plvEBrJ+W0ovihAZ+ LcPO0qJYvFtbI8FE22ixohSiP4+ov/fhdQpmJmXStNZglNYo+8UJKhFTUyqOczCM//AC jyig== 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; bh=jL99dR031ePMBi6i9LREHkg92dDFhmsbv8LA5Bcb6/c=; b=T6ncmd1tXl/AXH3qkXVnSf6NFNqPb+VyQULurUwLBs5DdyIpHuJtzGWZAoC6jnxfmy d15qxTWMtT1SBFkv73UJd59axL4FtcgQoUZ4uAdgyNNg+qVuzSFnTY8LCAAPGUWMxjfv sXBIRLgq38bYW+m1tJcI8xCFAdVg44yiPaktRdq3CzESs7oBhhCGPPRIBcRMC11/OJoW 1DK/JaqHOIZc4el0Msj6en0XuCnCPYli9J34kS0cOy3KR48h+Xgac0YxRK5KzBv/YxsU GRGCu0iMgzl0bBms9fNB8X9P3L9whFC++5gkbeYq0HS7cP8hy0ZGIAOH+EM69Pja+MQ5 iG/A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4si3368686oth.3.2019.12.19.06.06.04; Thu, 19 Dec 2019 06:06:29 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726779AbfLSOFA (ORCPT + 99 others); Thu, 19 Dec 2019 09:05:00 -0500 Received: from relay.sw.ru ([185.231.240.75]:53412 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726695AbfLSOFA (ORCPT ); Thu, 19 Dec 2019 09:05:00 -0500 Received: from dhcp-172-16-24-104.sw.ru ([172.16.24.104]) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1ihwQ6-0006RQ-DH; Thu, 19 Dec 2019 17:04:50 +0300 Subject: [Q] ld: Does LTO reorder ro variables in two files? To: Peter Zijlstra , gcc-help@gcc.gnu.org Cc: mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, linux-kernel@vger.kernel.org References: <157675913272.349305.8936736338884044103.stgit@localhost.localdomain> <20191219131242.GK2827@hirez.programming.kicks-ass.net> From: Kirill Tkhai Message-ID: <3db1b1c8-0228-56e4-a04f-e8d24cd1dd51@virtuozzo.com> Date: Thu, 19 Dec 2019 17:04:49 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191219131242.GK2827@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8 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 CC: gcc-help@gcc.gnu.org Hi, gcc guys, this thread starts here: https://lkml.org/lkml/2019/12/19/403 There are two const variables: struct sched_class idle_sched_class and struct sched_class fair_sched_class, which are declared in two files idle.c and fair.c. 1)In Makefile the order is: idle.o fair.o 2)the variables go to the same ro section 3)there is no SORT(.*) keyword in linker script. Is it always true, that after linkage &idle_sched_class < &fair_sched_class? Thanks! Kirill On 19.12.2019 16:12, Peter Zijlstra wrote: > On Thu, Dec 19, 2019 at 03:39:14PM +0300, Kirill Tkhai wrote: >> In kernel/sched/Makefile files, describing different sched classes, already >> go in the order from the lowest priority class to the highest priority class: >> >> idle.o fair.o rt.o deadline.o stop_task.o >> >> The documentation of GNU linker says, that section appears in the order >> they are seen during link time (see [1]): >> >>> Normally, the linker will place files and sections matched by wildcards >>> in the order in which they are seen during the link. You can change this >>> by using the SORT keyword, which appears before a wildcard pattern >>> in parentheses (e.g., SORT(.text*)). >> >> So, we may expect const variables from idle.o will go before ro variables >> from fair.o in RO_DATA section, while ro variables from fair.o will go >> before ro variables from rt.o, etc. >> >> (Also, it looks like the linking order is already used in kernel, e.g. >> in drivers/md/Makefile) >> >> Thus, we may introduce an optimization based on xxx_sched_class addresses >> in these two hot scheduler functions: pick_next_task() and check_preempt_curr(). >> >> One more result of the patch is that size of object file becomes a little >> less (excluding added BUG_ON(), which goes in __init section): >> >> $size kernel/sched/core.o >> text data bss dec hex filename >> before: 66446 18957 676 86079 1503f kernel/sched/core.o >> after: 66398 18957 676 86031 1500f kernel/sched/core.o > > Does LTO preserve this behaviour? I've never quite dared do this exact > optimization.