Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp485954pxa; Fri, 21 Aug 2020 12:21:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKrwcQjKG1pnLPWubzft5fI0Qir9Vbd4aQG46Pi+I2lCLQ2D5sWPVKFhxy6HSBF24ommYr X-Received: by 2002:a17:906:59b:: with SMTP id 27mr4651751ejn.56.1598037702925; Fri, 21 Aug 2020 12:21:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598037702; cv=none; d=google.com; s=arc-20160816; b=lySwnM/oGjtRx0E1gxI0jwvsq7QgJR0AG4woUA2obE8nu1kb5/nGT2j6jUfB2bW8es 8SqE5dP5QGW4HgySfO/go15LuauLNwH9Mi7TXostYxnYqAnZryxrsTwkKv0/9HQTaIqj /9a5pDaiqXMA7xZN/zzJqPdY/9FNpS+vVsKmMf/dDANx4l5RVR1Nv53D28iO2rnB17d/ sDVTA8ulPqOI+uNQaTfvj0e8mo6euXYnvd/Ns3Sk4BdKzZsZUMqAf20Si0LsdWtbLv2B WXUOBUeYa2G1SWz27G3w3kOGuvw3Oo30HJKhqUBPddjghvdUVpMZOHI/N8fk1gdKP5B6 iYNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=iH/eGhwplhANu5ngguYajhAAOM68U/Ap6x/YYMCKQeM=; b=qRx9ajG+fyR97yG234pWOArjZowB9rZCPqEqWeoo+USiaLQZ3Wynh7PkLigKCVKb/k hoPoi0UNBFPLVoerOqBd0qrucxRMNaq8KJUb1/VBs7sd/0KHlqU8D6CEzza3Ynkr4X5y EIIIUvOcSHx79TWrySovV7WYyK53e2XV6gLS0CM/tepFj4UOhsy47VDyIZgP4Oq6OZ0+ jDxe7krEJdY2y2wYFveYTMC98f0Sr2lT4//1SCRCv0g8gKU5YGOkiS59v+NR8E8RW3rd GlQElqvfmoYsuq5NOf97asSUVSFnONlzL/x5l+/HgntHFk2zsOHjmaVsurlv2ovnkSQ3 lHog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=c9nTXlQN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b19si1846705ejk.429.2020.08.21.12.21.19; Fri, 21 Aug 2020 12:21:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=c9nTXlQN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726585AbgHUTSV (ORCPT + 99 others); Fri, 21 Aug 2020 15:18:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726495AbgHUTSN (ORCPT ); Fri, 21 Aug 2020 15:18:13 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42800C061755 for ; Fri, 21 Aug 2020 12:18:12 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id o5so1450422pgb.2 for ; Fri, 21 Aug 2020 12:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=iH/eGhwplhANu5ngguYajhAAOM68U/Ap6x/YYMCKQeM=; b=c9nTXlQNMxlTkjUEBmI7ZJXRVD9/w0VzmwP7XYcrlwJNqIvD9e/4Bg7nhro9mqIRHX W7TkfsuoDy1IphU7AxA4ZmZuKL9yG5AjEURR9d4qU8313miQfcRhOmwz9VC758r41oVz RNirK13ZYv7MZlL30hWsJsl0GdCKhM2nFuYk0= 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; bh=iH/eGhwplhANu5ngguYajhAAOM68U/Ap6x/YYMCKQeM=; b=P+f9ibplQXLDM/9hwwjKUCjlgNQxADyy+qFhD9Trha8wBf8TDjwlezd60qSfwd7ERr ItV4z93UpYeLHtrsMNUwbGhPLB2Psh1y/+C2hC4eLxjdSxSW8b+Gn7a7wJ/bso2ZZeal 7PN18WowQAF2eu8nTSU0PGIggTxfd2WObJ/MliZhZLuhXqD5TogUbbB/0HhBUZjQFEkr EoqeH2JHtaxANQhaE5mnR5XzxyMPknPdaw63sS6nRvyFNfQt990iSNh2xP/+rpEKPK21 kNghvlAZ2jR9GTLlfRlVPa59r5DQIBOTTHtbZTapfrvfmny18fcAXEaudAw2i42IeMIJ YU9A== X-Gm-Message-State: AOAM530F9VrWspLsuMP0rQcr68LJhpnFNV9OxtfiJUcvvTwyLBaIOhlJ 4jTU4ftyQIVr6nu9h9pC5W9c2w== X-Received: by 2002:a05:6a00:22c9:: with SMTP id f9mr3657627pfj.212.1598037492193; Fri, 21 Aug 2020 12:18:12 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id z6sm3413592pfg.68.2020.08.21.12.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 12:18:11 -0700 (PDT) Date: Fri, 21 Aug 2020 12:18:10 -0700 From: Kees Cook To: Arvind Sankar Cc: Andi Kleen , Thomas Gleixner , Will Deacon , Nick Desaulniers , Jian Cai , =?utf-8?B?RsSBbmctcnXDrCBTw7JuZw==?= , Luis Lozano , Manoj Gupta , stable@vger.kernel.org, Catalin Marinas , Mark Rutland , Ard Biesheuvel , Peter Collingbourne , James Morse , Borislav Petkov , Ingo Molnar , Russell King , Masahiro Yamada , Nathan Chancellor , Arnd Bergmann , x86@kernel.org, clang-built-linux@googlegroups.com, linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Michal Marek Subject: Re: [PATCH v5 13/36] vmlinux.lds.h: add PGO and AutoFDO input sections Message-ID: <202008211216.3812BBA0C8@keescook> References: <20200731230820.1742553-1-keescook@chromium.org> <20200731230820.1742553-14-keescook@chromium.org> <20200801035128.GB2800311@rani.riverdale.lan> <20200803190506.GE1299820@tassilo.jf.intel.com> <20200803201525.GA1351390@rani.riverdale.lan> <20200804044532.GC1321588@tassilo.jf.intel.com> <20200804160649.GA2409491@rani.riverdale.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200804160649.GA2409491@rani.riverdale.lan> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 04, 2020 at 12:06:49PM -0400, Arvind Sankar wrote: > On Mon, Aug 03, 2020 at 09:45:32PM -0700, Andi Kleen wrote: > > > Why is that? Both .text and .text.hot have alignment of 2^4 (default > > > function alignment on x86) by default, so it doesn't seem like it should > > > matter for packing density. Avoiding interspersing cold text among > > > > You may lose part of a cache line on each unit boundary. Linux has > > a lot of units, some of them small. All these bytes add up. > > Separating out .text.unlikely, which isn't aligned, slightly _reduces_ > this loss, but not by much -- just over 1K on a defconfig. More > importantly, it moves cold code out of line (~320k on a defconfig), > giving better code density for the hot code. > > For .text and .text.hot, you lose the alignment padding on every > function boundary, not unit boundary, because of the 16-byte alignment. > Whether .text.hot and .text are arranged by translation unit or not > makes no difference. > > With *(.text.hot) *(.text) you get HHTT, with *(.text.hot .text) you get > HTHT, but in both cases the individual chunks are already aligned to 16 > bytes. If .text.hot _had_ different alignment requirements to .text, the > HHTT should actually give better packing in general, I think. Okay, so at the end of the conversation, I think it looks like this patch is correct: it collects the hot, unlikely, etc into their own areas (e.g. HHTTUU is more correct than HTUHTU), so this patch stands as-is. -- Kees Cook