Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2875068pxj; Mon, 14 Jun 2021 09:06:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJze2Nq6LComBPyi3pzYycyYF+DzK9IH+4dUpzoIItYfLfETyIJkisXlmya/ecvNTWPZVlDK X-Received: by 2002:a05:6402:12d8:: with SMTP id k24mr18022965edx.47.1623686766179; Mon, 14 Jun 2021 09:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623686766; cv=none; d=google.com; s=arc-20160816; b=eU9REEfERlINqpkkrC4vzWDfOi/fBybEe6iAF1gEWCqJnC5102fD8qMtIlHkV/EAxd 8pDzlPSOr5e4iE/aqtsuP6zAo46382aaUcAsLrRGDw8E0yFsV5m2AeC5nx+iyUl2B5hk 5iSLtjyJo0Nu5CiIlzF4ERHDbE4nMZaXjg5Q0xXZiC5ZvUgHVtMvs2gYX8B7pw4UECIP HxSgcIT5vzcOIMUkhmnuZgLy3cquYDbp8n+X/Z3rXJEvSStlG03VZAHykAKUXP9nCkjB I+RW28s4Im25HcH4EZaI/Esh4oQuECEwSH2cdRRB43xP0gjVk33RrwXaYVdAaRhAJaFz RywQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=3MqGDvp9ypUCvhlLUOO4ezsTJgglqtbS6x/EUZzU8+Q=; b=RTLMHQ7x0vN00sU6B+pOuPKZ/+lx7bKzCE7OaMHTR/WZ0aPjmKdWIjQk79jNaBnGNk hcFvfwEx1a0G38umPTPNJqqLNbzmzzA9OLLir8GQAdXGdZ5T5jQO6HmAPOmtdGA3IYFM FHtRxs+xXEfEb/qB+svbIu/aCIhCYynUfsLEe4JLIDRNro63eYfYzPCr9aqEIRof8Fv3 EnD0LurCLnvRyBvMoa97R009Orkx4mTRKJISTsFY5LnMyhhlLYpSUYqbloULEenklNIa +d2gvxFUCEKhxUqsfARyxrkPSnVXxDdWsKsOPJzCYEAVBWOfhCzyaYZu7V2EgEpAeME4 BNIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Fy7Y+Deo; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e26si100830ejt.561.2021.06.14.09.05.43; Mon, 14 Jun 2021 09:06:06 -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=@google.com header.s=20161025 header.b=Fy7Y+Deo; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233640AbhFNQFe (ORCPT + 99 others); Mon, 14 Jun 2021 12:05:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233135AbhFNQFd (ORCPT ); Mon, 14 Jun 2021 12:05:33 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB7BDC061574 for ; Mon, 14 Jun 2021 09:03:15 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id r198so21924548lff.11 for ; Mon, 14 Jun 2021 09:03:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3MqGDvp9ypUCvhlLUOO4ezsTJgglqtbS6x/EUZzU8+Q=; b=Fy7Y+DeoKvsZICPPwA01TqMBiH2RFRKDNCaiYWD2UTBYSxZ4pdeg1d/ChfVV734TmQ DT17igrzvRDC6rSUoqpPatzrJNeyqYGImyCufJH3ofLDeNrnxly9mav9aZJLyg1UVkoB 1qO7A8Pp7Sw0Yt1+gn+KVxTl9wtq5gPrdjAgo7p8Dw6cP35cf73qe5IC2SZlU4EN6JST e57ab6dbcs/ksdm+WbwRkuTpfFsQSuzRLgI1XcClxOzoNJYFUWWYmvcoi9U0nWAQ/FND HDaz4KI7R9lqXlsABdzH8orcCS5kRcK7Gl62H7bYrC+WblskggwIu+lBaRzzUoj/M9As nNVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3MqGDvp9ypUCvhlLUOO4ezsTJgglqtbS6x/EUZzU8+Q=; b=WubQvHu9CQGewFLE35bcsRDJpNUe7Qknzt8JMyld6HXNm6xaLN98EA9uVJS7m0d35c aIuFWU7jEfZltz6UFJ11b8HHvF3tme03s11EC7nIwDItMq1O+VLX1pL+beDWzTugTpbw g86cRjInJbVF4jBU1hDwG5L1ocn+OfPj5bgZuuzMU1zqGyUe/fNrDUDM0X/k0xB2TGDx SBB1T+nh4C1AO8GjWDpqtJXsSTuGlWXDg75tVcCD7P2fU026AUn0iCU5J9qeMfIwaqEx twNUCqr1kCMSKceussh827XDct0LQjekYe9fxXfw83DlV/o7BQQm0Gim78kzECkIynGS K0xQ== X-Gm-Message-State: AOAM532R/qffr/J6MBoczPBkKvc9IDbCvBSuXPwb7DAPtWBdaBqe39Xu rzvjg7LnPH45N52/UJ1pbW2J+yVjR0PCCg/kTEbnZw== X-Received: by 2002:ac2:5cd6:: with SMTP id f22mr13208808lfq.73.1623686592188; Mon, 14 Jun 2021 09:03:12 -0700 (PDT) MIME-Version: 1.0 References: <20210612202505.GG68208@worktop.programming.kicks-ass.net> <202106140817.F584D2F@keescook> <20210614154639.GB68749@worktop.programming.kicks-ass.net> In-Reply-To: <20210614154639.GB68749@worktop.programming.kicks-ass.net> From: Nick Desaulniers Date: Mon, 14 Jun 2021 09:03:00 -0700 Message-ID: Subject: Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure To: Peter Zijlstra Cc: Kees Cook , Marco Elver , Bill Wendling , Jonathan Corbet , Masahiro Yamada , Linux Doc Mailing List , LKML , Linux Kbuild mailing list , clang-built-linux , Andrew Morton , Nathan Chancellor , Sami Tolvanen , Fangrui Song , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Andrey Konovalov , Dmitry Vyukov , Johannes Berg , oberpar@linux.vnet.ibm.com, linux-toolchains@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 14, 2021 at 8:46 AM Peter Zijlstra wrote: > > On Mon, Jun 14, 2021 at 08:26:01AM -0700, Kees Cook wrote: > > > 2. Like (1) but also keep GCOV, given proper support for attribute > > > no_instrument_function would probably fix it (?). > > > > > > 3. Keep GCOV (and KCOV of course). Somehow extract PGO profiles from KCOV. > > > > > > 4. Somehow extract PGO profiles from GCOV, or modify kernel/gcov to do so. > > > > If there *is* a way to "combine" these, I don't think it makes sense > > to do it now. PGO has users (and is expanding[1]), and trying to > > optimize the design before even landing the first version seems like a > > needless obstruction, and to likely not address currently undiscovered > > requirements. > > Even if that were so (and I'm not yet convinced), the current proposal > is wedded to llvm-pgo, there is no way gcc-pgo could reuse any of this > code afaict, which then means they have to create yet another variant. Similar to GCOV, the runtime support for exporting such data is heavily compiler (and compiler version) specific, as is the data format for compilers to consume. We were able to reuse most of the runtime code between GCC and Clang support in GCOV; I don't see why we couldn't do a similar factoring of the runtime code being added to the kernel here, should anyone care to pursue implementing PGO with GCC. Having an implementation is a great starting point for folks looking to extend support or to understand how to support PGO in such a bare metal environment (one that doesn't dynamically link against traditional compiler runtimes). -- Thanks, ~Nick Desaulniers