Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1774044yba; Sun, 21 Apr 2019 15:03:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyo9mdcQNxl74XrEZiFQY2I9ISpSEkPu95+hlNiavg/pqL8I5RdZzk5jqER19VZZpG5ND7 X-Received: by 2002:a63:f707:: with SMTP id x7mr15575950pgh.343.1555884222118; Sun, 21 Apr 2019 15:03:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555884222; cv=none; d=google.com; s=arc-20160816; b=eibA/MiEiVVOFjL26pHEDyUUOvr4MG7kClEQrjFCO2KInw4DmqCBwM7BZFzHDhJyxO Wgrwt0XYn5GdU1T4IypIJtO/mFFOXt8w1Rd18h0phWosTmz3i5oTxCsDm8sBkYfW3loJ V/uSMi7DP6TRP7OxqxxTEuN1YdEeKd7ToGIyJOhjGfySL4EmmmmVO19IBthCps+wv7zo In1o4ucPvmFHbKuC70t5/vAqZF3S+owkUrNT44Ey2PXzP7pHbN66k34cxY9HuzcF8eZU u7mg0bM6mAjJKy3N0kE+8Fe3DoMZO9TgbBY1FyXPFD/Jd/f4CkVHd1horoPq5ucefKje X8TQ== 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=bUDvkW8p4d8qAMbdt57k7N4pO8TXzPEFQPQQh6N7h4I=; b=eGshj2P0r7jibzVX0mp0Byoz1eBr8kXfPpBSc7DXNuvvYmshqmODYQVeOocmgOMo4J KQfOXgE9uGNCPuvDntDF4nF7h82KGr9pMao/gNb/AzBRNyAGZHjQ9c6YW+9DY9PXnwdZ ytJAj5X/mcZRLdO8b8qBjr5ravQw0vNahpfcRj+Qn3684LT2+PhllhDe/RfcO4Ag6s+Z +ywsbZ80PS8h8si0NDsy8zzmkGgiq8flnBbSsMGOI9xJQU3Z5X+W3XQabIW5PvP7MvOn RT8zz1R76aJisANVbHIkKuDsMTDiU6ylzuSqhTvB8xcf7w7c4qpdLouGouoCVaa5X3Vo v4Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=To+XtwAm; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k9si810567pls.343.2019.04.21.15.03.26; Sun, 21 Apr 2019 15:03:42 -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=@gmail.com header.s=20161025 header.b=To+XtwAm; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726474AbfDUVKO (ORCPT + 99 others); Sun, 21 Apr 2019 17:10:14 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53554 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725872AbfDUVKO (ORCPT ); Sun, 21 Apr 2019 17:10:14 -0400 Received: by mail-wm1-f66.google.com with SMTP id q16so12372660wmj.3 for ; Sun, 21 Apr 2019 14:10:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=bUDvkW8p4d8qAMbdt57k7N4pO8TXzPEFQPQQh6N7h4I=; b=To+XtwAmROK17RDbxn8ohi7mfKSQIIXelfowuOyl3SXpYIxLIPtdB5IBre6wNMzmcx /0JodldeWExXXk+bk2au6LW+vC+HuEWInjxj/9R2f6MEoh9A1Lhc4EeCqQ/gvrqmjAjQ aceIGn2b2CgnGYDjwrMomh0fnGL8uDRt3sAItaAQJ84PSPUQg3Gu0/LSaxQzC+Zq3V/U ClTswHQffZy6B0FUKenFIY2jgWpGG82XbFK5Wr2V1DeJVBzVX/MM+uJkvjIl7sLAsdoB R+siri+PJA4iVTXlh4XqWD/In5E+Tnx/tja/dlZddIyP3V5PCcG3m6/InCQTLTD0wzoL CYGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bUDvkW8p4d8qAMbdt57k7N4pO8TXzPEFQPQQh6N7h4I=; b=gOAXOP39uhGe9D3pU/dDZjUHgCsydBzRroC+LtMql2WiUvbdL2Zy1lp8i6zHSS2TwL kAvQEZ8UkSQuKguMJXqzQ1SlK+a5+DoC2cKJc34oUwDQWnJDUEgi139I3fW1k4vJwW47 TyfOUi0knjMg26LceyRAKDEl0UF2O5bUKEChNDMYIBCmTrUOMqAtVpx4qn8W4TDXGWPc DKlqAvMuYLUAPdRWMIMRU+aotD+xO9pNm650mtTzqHuHXRoI59pka7s4Y2+Q4/eRR/Gq 6dqP3bgy45KnfF2JIc8ex2Ij5CgOycrZv+otxDK2jQRUqxkMaNPP5b1sxXzyya/tcfJ2 tvgA== X-Gm-Message-State: APjAAAVB5kEqKEYZyyb7fAF7r5uw3HtFSApbejAsoHnvA7scGPl+T4cN y4PFKspzLKjtoHxal6iBMA== X-Received: by 2002:a05:600c:210e:: with SMTP id u14mr10343007wml.50.1555881011070; Sun, 21 Apr 2019 14:10:11 -0700 (PDT) Received: from avx2 ([46.53.240.200]) by smtp.gmail.com with ESMTPSA id d3sm22241443wmf.46.2019.04.21.14.10.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Apr 2019 14:10:10 -0700 (PDT) Date: Mon, 22 Apr 2019 00:10:07 +0300 From: Alexey Dobriyan To: hpa@zytor.com Cc: Ingo Molnar , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, linux-kernel@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH] x86_64: uninline TASK_SIZE Message-ID: <20190421211007.GA30444@avx2> References: <20190421160600.GA31092@avx2> <20190421182842.GD35603@gmail.com> <8B42CD57-9343-4234-A96D-80337BFFDF0E@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <8B42CD57-9343-4234-A96D-80337BFFDF0E@zytor.com> 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 On Sun, Apr 21, 2019 at 01:07:08PM -0700, hpa@zytor.com wrote: > On April 21, 2019 11:28:42 AM PDT, Ingo Molnar wrote: > > > >* Alexey Dobriyan wrote: > > > >> TASK_SIZE macro is quite deceptive: it looks like a constant but in > >fact > >> compiles to 50+ bytes. > >> > >> Space savings on x86_64 defconfig: > >> > >> add/remove: 1/0 grow/shrink: 3/24 up/down: 77/-2247 (-2170) > >> Function old new delta > >> _task_size - 52 +52 > >> mpol_shared_policy_init 344 363 +19 > >> shmem_get_unmapped_area 92 97 +5 > >> __rseq_handle_notify_resume.cold 34 35 +1 > >> copy_from_user_nmi 123 113 -10 > >> mmap_address_hint_valid 92 56 -36 > >> arch_get_unmapped_area_topdown 471 435 -36 > >> tlb_gather_mmu 164 126 -38 > >> hugetlb_get_unmapped_area 774 736 -38 > >> __create_xol_area 497 458 -39 > >> arch_tlb_gather_mmu 160 120 -40 > >> setup_new_exec 380 336 -44 > >> __x64_sys_mlockall 378 333 -45 > >> __ia32_sys_mlockall 378 333 -45 > >> tlb_flush_mmu 235 189 -46 > >> unmap_page_range 2098 2048 -50 > >> copy_mount_options 518 465 -53 > >> __get_user_pages 1737 1675 -62 > >> get_unmapped_area 270 204 -66 > >> perf_prepare_sample 1176 1098 -78 > >> perf_callchain_user 549 469 -80 > >> mremap_to.isra 545 457 -88 > >> arch_tlb_finish_mmu 394 305 -89 > >> __do_munmap 1039 927 -112 > >> elf_map 527 409 -118 > >> prctl_set_mm 1509 1335 -174 > >> __rseq_handle_notify_resume 1116 906 -210 > >> load_elf_binary 11761 11111 -650 > >> Total: Before=14121337, After=14119167, chg -0.02% > >> > >> Signed-off-by: Alexey Dobriyan > >> --- > >> > >> arch/x86/include/asm/processor.h | 4 ++-- > >> arch/x86/kernel/Makefile | 1 + > >> arch/x86/kernel/task_size_64.c | 9 +++++++++ > >> 3 files changed, 12 insertions(+), 2 deletions(-) > >> > >> --- a/arch/x86/include/asm/processor.h > >> +++ b/arch/x86/include/asm/processor.h > >> @@ -887,8 +887,8 @@ static inline void spin_lock_prefetch(const void > >*x) > >> > >> #define TASK_SIZE_LOW (test_thread_flag(TIF_ADDR32) ? \ > >> IA32_PAGE_OFFSET : DEFAULT_MAP_WINDOW) > >> -#define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \ > >> - IA32_PAGE_OFFSET : TASK_SIZE_MAX) > >> +unsigned long _task_size(void); > >> +#define TASK_SIZE _task_size() > >> #define TASK_SIZE_OF(child) ((test_tsk_thread_flag(child, > >TIF_ADDR32)) ? \ > >> IA32_PAGE_OFFSET : TASK_SIZE_MAX) > >> > >> --- a/arch/x86/kernel/Makefile > >> +++ b/arch/x86/kernel/Makefile > >> @@ -46,6 +46,7 @@ CFLAGS_irq.o := -I$(src)/../include/asm/trace > >> > >> obj-y := process_$(BITS).o signal.o > >> obj-$(CONFIG_COMPAT) += signal_compat.o > >> +obj-$(CONFIG_X86_64) += task_size_64.o > >> obj-y += traps.o idt.o irq.o irq_$(BITS).o dumpstack_$(BITS).o > >> obj-y += time.o ioport.o dumpstack.o nmi.o > >> obj-$(CONFIG_MODIFY_LDT_SYSCALL) += ldt.o > >> new file mode 100644 > >> --- /dev/null > >> +++ b/arch/x86/kernel/task_size_64.c > >> @@ -0,0 +1,9 @@ > >> +#include > >> +#include > >> +#include > >> + > >> +unsigned long _task_size(void) > >> +{ > >> + return test_thread_flag(TIF_ADDR32) ? IA32_PAGE_OFFSET : > >TASK_SIZE_MAX; > >> +} > >> +EXPORT_SYMBOL(_task_size); > > > >Good idea - but instead of adding yet another compilation unit, why not > > > >stick _task_size() into arch/x86/kernel/process_64.c, which is the > >canonical place for process management related arch functions? > > > >Thanks, > > > > Ingo > > Better yet... since TIF_ADDR32 isn't something that changes randomly, perhaps this should be a separate variable? Maybe. I only thought about putting every 32-bit related flag under CONFIG_COMPAT to further eradicate bloat (and force everyone else to keep an eye on it, ha-ha).