Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1635744yba; Sun, 21 Apr 2019 11:29:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDxDvMKyg/GU2EJbwQM9gyJqt5bU6tqKiY/ZDvFbt49SuokNwWmp0tL804SkubXj3ffJg1 X-Received: by 2002:a17:902:31a4:: with SMTP id x33mr15794879plb.24.1555871392719; Sun, 21 Apr 2019 11:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555871392; cv=none; d=google.com; s=arc-20160816; b=b0XMg+UTFknV5VaSJnFiG6UgrD46YOP8XuA1d/rT270WKYKo91WPRZFab6EEkc2wNe 90jUyAeKqCIUKHM76XSmMU4uzEXyEbxeXCCYNqipWTRUq8UKG29GXZOl30CbqbJMk3h8 GC0rZj+TjYY/vV2QbVZbwa9BLUGsTAEEIyD20l0OJkEhQeQEEd4bld+usxt/c08kKo3c RAaePSSS0KJWycsh5gZRMbRxgf8RyxbRctkmsmxKAbu2IpOgyMH59xe7iJeqeOLMgLIs KnFQIVnw7VkfYgkpdRw2L2BvmaA13xOImxAiPOhd7Eh89Q89oboz7vQ6HvbvdmX1fiCV fy0g== 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=7ArCPFqYwX7UMiHzjad2PhTqbe1uWNJioXFBsHyNJRk=; b=zPLJl0jq4bdpMyiEQd8SFHACGlaXsb7phF1wgowJZ+zrjMSQIlBatVcc8jR3aqycPi PMKWz/ZpPbscyKXb/my7uj/iwF3YKKhgj4JVuOndYyGcXsP1lDbga9Ims+7pOlkJpsno vExIx79UiNPCFxQkpx0Mbr3+iKo3XPR80Pqp52BNsV9Q/bUbqgx9kCZZ9i5gwfcwGH58 wLb4AXEV9ebne9NpnwIflBmvzsAUyKBPg3gHxfgqNHO0AAy8Vg+Y8SDl1Pq4S4arDkbl GiL204/usqJFrxVo4WBRooY6jSYu4NW8HghuDVEsmK1cYx9M6UxKH/OZ9KCczoWPQBXG HKYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=OpcivUCi; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si11137088ply.311.2019.04.21.11.29.37; Sun, 21 Apr 2019 11:29:52 -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=fail header.i=@gmail.com header.s=20161025 header.b=OpcivUCi; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726170AbfDUS2s (ORCPT + 99 others); Sun, 21 Apr 2019 14:28:48 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33750 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725767AbfDUS2s (ORCPT ); Sun, 21 Apr 2019 14:28:48 -0400 Received: by mail-wr1-f65.google.com with SMTP id a3so3770900wrx.0 for ; Sun, 21 Apr 2019 11:28:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=7ArCPFqYwX7UMiHzjad2PhTqbe1uWNJioXFBsHyNJRk=; b=OpcivUCi/Wgy5zYTevEE0SLf/70N+pW36kOqpQDp0bsl76vAdS21olCg+GAOyr2xn5 VsEAx6SX3lfTFuKkHtXFBYm3g5SDeLaPU3unA73Ff6O+Xbsd/N2mVLcSOexwVf2qPH1m BGPTUsomKzaBxZd+JUHmKHLfW9JsIkHCGoDaYuEnWOZkDA26LFhqXedjj3NH+3NRqJNh 5UprNxVxsyg3wTnA78UGMNQI5584SB7hyuqxFCOm1YxtLF69iGiPZCqdWB4PHabZxIo2 yVQLDpncphVbBe967W3ph0Q4pAGMYwHq2g39+NfnG5mlajE0NC0jE5BkgQzDFq5nI4Ar 3mEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=7ArCPFqYwX7UMiHzjad2PhTqbe1uWNJioXFBsHyNJRk=; b=sFZX0WQTV4OSq+dDXfo4PMyI2bdFPlPDvWO2wI/ulCgBxEFmT4FHcgnMCTotNl9dRN cYTTMeHgqz3uhfwTR16HrnMW+8pPgijN91vEwAPmXWFRYPHXMPmIryTYt0QdykrEgiIo yWHjP0KoGRhfwaCFplB8vobf4j98M5JNZ9TSqlm09oN82A0UOA63hZ7E3M98bKhf86St wE0Ic6krNdOikQd5RVCu65b3/7DsbbVnEw0NYRqsmjtqvebwrZ7JxUzRNjpuzAujCIIb bPeUcapsh8MEw7MjqJ5ZfeCpQkeFA5v63vomVaeXXE6yyco9K+42Abvtu2By7cfm1kKb vjsg== X-Gm-Message-State: APjAAAUkJWEm3NfY6zNYgX9ALmH2PR3/2e+scAG6frw667duEWJWjnxC OWZjIUylJuI43+DXBCLI3uI= X-Received: by 2002:a5d:6150:: with SMTP id y16mr10561106wrt.13.1555871325743; Sun, 21 Apr 2019 11:28:45 -0700 (PDT) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id y125sm16675618wmc.39.2019.04.21.11.28.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 21 Apr 2019 11:28:45 -0700 (PDT) Date: Sun, 21 Apr 2019 20:28:42 +0200 From: Ingo Molnar To: Alexey Dobriyan Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, linux-kernel@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH] x86_64: uninline TASK_SIZE Message-ID: <20190421182842.GD35603@gmail.com> References: <20190421160600.GA31092@avx2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190421160600.GA31092@avx2> 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 * 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