Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp921344pxf; Wed, 7 Apr 2021 15:07:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJfIoz+lBtKzAdX1RPnThJSUsbk1FbMhcmSSzH7cqE3Ug4pInnXrtGzv3/G/RZmLGxJ2qd X-Received: by 2002:a63:d841:: with SMTP id k1mr5232494pgj.440.1617833231889; Wed, 07 Apr 2021 15:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617833231; cv=none; d=google.com; s=arc-20160816; b=uB8obGymRrEV1Bs1aPEVGZHoD+n5zVQKqK47FwtIWV7+UTZW8ko9ATiNYGPrkmckxl JbT0tFZ/Gu/SL0IxwenU+rv8SjMEK7GO6qFFbo0EvfJTF41HNfVRv/d4i4UFR+2arbX3 cDBk+GgE1kaLB7Pzx2SJX7APNaVdGhGbMMuxN/aElaaxQkxUqQhFFB1e4CjHIA99ddeC 1MKIBNwTyekugo6NDUPwycE2jvhE0ZDYFGrjsTkhL0drYQ7CIHklM4a4xE62kCTZ0krI 8fRC/gnoSO9UDwWkwzYDzyBTJAmoGnovrBFzS6urs/NX0N3b5btqG522KgrA3LATpwfK 6t2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Zupj7uPahNplY1UQVoMGkmaTQjWt4OgWRC3KsLSujrc=; b=cnSjFI3sQHIruRehmFPfF/15ulmcoeVCU5Oj0K32uRs8dZPVVZnUBIudQhNepqvetf Iyf5WwBGkkpKZRl6Cl2R5D+q6wcR1xxGFd1hK8Jfgp50nemZhDbsIDGvG3AhvDlMpQvQ pU82mVRhvDjyQbUlOzn9ys88spML/AO9SjzDthX/z10bTtyUN+4b897YqUIJrXFZMLw7 4ylwUe/4T2JjahplZaKUmxLwuWMizUe6JuPVksjXTzUMW/MvNmyMps/mwuw7F/WdhYfU KkTGCvZPqM7j05TOpvB0DEW85dZj6UUj8wpjPF4eb0jhMZqL93FPJdSIPlAzWD0A1R0a OSJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=M9YSVBjf; 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 k12si26175520pgp.381.2021.04.07.15.06.59; Wed, 07 Apr 2021 15:07:11 -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=M9YSVBjf; 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 S232649AbhDGVXA (ORCPT + 99 others); Wed, 7 Apr 2021 17:23:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232202AbhDGVW7 (ORCPT ); Wed, 7 Apr 2021 17:22:59 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CAC2C061762 for ; Wed, 7 Apr 2021 14:22:49 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id l76so13987776pga.6 for ; Wed, 07 Apr 2021 14:22:49 -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=Zupj7uPahNplY1UQVoMGkmaTQjWt4OgWRC3KsLSujrc=; b=M9YSVBjfkZmUSxtRGAEOxpmgFxdTViW/Siw3rNeLMFHDSM6e3hN8ysP/2240zDxxDi T39zUKyY0vtGxkZkCB4+bVGjB1JAVYTKNRcUTK6MJPCXyrOzKqsAcJlHnP7Y1ova1y0O st/zEdrQliXXXomA7KmkLKClIcIhYnk+UrSJM= 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=Zupj7uPahNplY1UQVoMGkmaTQjWt4OgWRC3KsLSujrc=; b=MVM0ACDHxDEFL3Z+og29piMzXVcLxGbi41VUEgdT3T7Laxe6xQ399r/KREde8N0WT8 yARj206L/ChJ0yi4m23Iq7XysxwVxxThoPBR4lFY5olYTonLQIMM5vXXk/PWH96SzTB9 nA88E0lu3UUdKCj3eJdWAkWbD/dywHSarNhJ0vFv1AOHe/K4e/1A60ZBEbk8CxR82e0Y XoIOGFaWzAL99G/EP1B/Jr5sgPvzfjD/zdZDTcLNaaCF6MJcK5+dXPfxy/YfNTX4WgTa Ziu8MP6MFnl+z+jCR8hmlOA/tf/UfsVNtNiytmHHhfoqlZComFQbFrI1IU4V5mj8MU6L /pGQ== X-Gm-Message-State: AOAM530nsDiU9xq4u2I9ZkMz9WPkMOteXZCCRyA5TEJ0/aL99h0Io88X yEMPZBkTsB66Eg4I+N0isqiPow== X-Received: by 2002:a63:df56:: with SMTP id h22mr5123694pgj.84.1617830568995; Wed, 07 Apr 2021 14:22:48 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id l191sm6209304pfd.36.2021.04.07.14.22.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Apr 2021 14:22:48 -0700 (PDT) Date: Wed, 7 Apr 2021 14:22:47 -0700 From: Kees Cook To: Bill Wendling , Masahiro Yamada Cc: Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com, Andrew Morton , Nathan Chancellor , Nick Desaulniers , Sami Tolvanen , Fangrui Song Subject: Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure Message-ID: <202104071419.AA35EEAF@keescook> References: <20210111081821.3041587-1-morbo@google.com> <20210407211704.367039-1-morbo@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210407211704.367039-1-morbo@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 07, 2021 at 02:17:04PM -0700, 'Bill Wendling' via Clang Built Linux wrote: > From: Sami Tolvanen > > Enable the use of clang's Profile-Guided Optimization[1]. To generate a > profile, the kernel is instrumented with PGO counters, a representative > workload is run, and the raw profile data is collected from > /sys/kernel/debug/pgo/profraw. > > The raw profile data must be processed by clang's "llvm-profdata" tool > before it can be used during recompilation: > > $ cp /sys/kernel/debug/pgo/profraw vmlinux.profraw > $ llvm-profdata merge --output=vmlinux.profdata vmlinux.profraw > > Multiple raw profiles may be merged during this step. > > The data can now be used by the compiler: > > $ make LLVM=1 KCFLAGS=-fprofile-use=vmlinux.profdata ... > > This initial submission is restricted to x86, as that's the platform we > know works. This restriction can be lifted once other platforms have > been verified to work with PGO. > > Note that this method of profiling the kernel is clang-native, unlike > the clang support in kernel/gcov. > > [1] https://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization > > Signed-off-by: Sami Tolvanen > Co-developed-by: Bill Wendling > Signed-off-by: Bill Wendling > Tested-by: Nick Desaulniers > Reviewed-by: Nick Desaulniers > Reviewed-by: Fangrui Song Thanks for sending this again! I'm looking forward to using it. Masahiro and Andrew, unless one of you would prefer to take this in your tree, I figure I can snag it to send to Linus. Anyone else have feedback? Thanks! -Kees -- Kees Cook