Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2678491pxj; Mon, 14 Jun 2021 04:46:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDa/btLmWbOnDlYQ+AYlRpKyUn3QQe8hX33KK73upj89M2RoxP2ig+f2KqQPg9WPlfceMQ X-Received: by 2002:a17:906:7fc5:: with SMTP id r5mr15338878ejs.474.1623671203047; Mon, 14 Jun 2021 04:46:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623671203; cv=none; d=google.com; s=arc-20160816; b=gVb0yzGUrdaozI2IA7Fr8z1fI3uNmS5q7Sh1f29TOxtmZNESAKKUZtMgYplg9vx8RP cwbSvbSerZ1P6MJX0h/z1HGZhjAR5M5nMCKEYQbQYZc1hqj4fbYTomjd089H5oSFbroR +LIL2u/mKjpQcvbop4pZK5YhWhQZGW6OUp58aXLP067VcfqZUaaOnDUwI48YGgprwn5y FcxJZvGanBT2YN1hMo3UZ/uODJBG5NWUTY7ZYZSkl+9kjHqtEGLf6yTpMWBUzVKjj57s nkSGq1Y1c7AUrmdyEddVlG2jl+8JwC94Pz2GNw7FFshavKteaoa3Y9Bqf3ymMfVNvhxk KeDg== 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=HI8uNQ2N0M5Hhpj6WC1Izp202Fz3OsRq4lT6L+ArKG8=; b=CAd6EeZW0JBREyn8Bvx/hGs++QSukejxdnRRgnQnyL8qrlp/C5o3VCaMszDsIS5s8g i/BmisVJlCFlye3ULTvb8X0mEFV65GGigkBdn17Z8jUePXL9qNqX4JnBHQ72JYDsFjd5 mUKSO+MUM9rCn72UN7b843o53107jvG6WDgRZw5jLCKFCLHwYaY6y4HueIDkPx9AgnSV lA/guvq1jqgFIDjgixkpcTdX3j7gzwRtIpKTTFTQSzzogOAUjIMQ9S/DRER9sLF7W9sf GgXlX7Pi0rz2oJAMpieQFIUc0iVx0hDTrlYhgUXRPrnXXc4PfMGGHe/jqgdSbw06ZNE/ xzvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="k74Pd/aw"; 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 v9si6902647edc.545.2021.06.14.04.46.19; Mon, 14 Jun 2021 04:46:43 -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="k74Pd/aw"; 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 S234711AbhFNLrb (ORCPT + 99 others); Mon, 14 Jun 2021 07:47:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236033AbhFNLqz (ORCPT ); Mon, 14 Jun 2021 07:46:55 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 854F1C0611C3 for ; Mon, 14 Jun 2021 04:43:37 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id my49so16188594ejc.7 for ; Mon, 14 Jun 2021 04:43:37 -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=HI8uNQ2N0M5Hhpj6WC1Izp202Fz3OsRq4lT6L+ArKG8=; b=k74Pd/awWzo+0vIQa3vSWB4GiHFuz2x/5raEEABcmoRr9iSqr6PUuB8vVwmmfk8LRJ dyow7EEnasjGh9+H2SOieqWJRNloMZvc2+yaoqoC+dZybwRaxiFK2X89V8/rRWMnIohO 0jhjfzxCifMikqa5PogKCoVU9vHX1I7WdevNRGgKFWyThzuj0cxfFHOSmImqCBmRLoPL ifOSiwTzvkd2A+zaEfi0t+XTo1bfwzUmTKaWl5UOyrxKMVWgDy/e8tXJ0ZrgFuSiHA1W /wKnnSaDdBBi6pvxr7CqZE4dh3VqXl1V6DVXS+3MMrzzG6bAcvaB7bud1S1tuwAu+MsW jo6A== 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=HI8uNQ2N0M5Hhpj6WC1Izp202Fz3OsRq4lT6L+ArKG8=; b=iudBedC2QL6wVpE0jGuCP7lp+FSULxIbfcgka8P53+vBoLktgWt2UXBG7cu3/oEN8S EsejYhiSJGFAq6+cGONLFRFfKYRNSbr73VjHGqQFpoIsKRiOx0MxBh4ji5ft/pPexAsV cBl2YmVtRGfZxxyoiDn7SAl9yjzC1q7Ycl/ijAPXmxRN0H2++tFGmD4DVlKijasvlimB BRpGVPgkk/UYRdDZe9n1fuZkz6pSCt8xVF7siwpgt84J0Hw428r1b75xAhqPZf/zB7fA IfCJPVExPTtcoEVBP7KmZYZQbCB+tX94Br/X2aim3pg4ORDfX/UeESrDaBnlCpV+pWjC vueA== X-Gm-Message-State: AOAM530eOY/oBYnxSff9omSu4gHxiJuaX/KKJR6G4dsQ6+rhQnZmhRbq KKZeKsRtmYkWk5sf2MF1vbKw5ijO6HVn/DLdjFpS X-Received: by 2002:a17:906:7188:: with SMTP id h8mr15017910ejk.529.1623671015979; Mon, 14 Jun 2021 04:43:35 -0700 (PDT) MIME-Version: 1.0 References: <20210111081821.3041587-1-morbo@google.com> <20210407211704.367039-1-morbo@google.com> <20210612202505.GG68208@worktop.programming.kicks-ass.net> In-Reply-To: From: Bill Wendling Date: Mon, 14 Jun 2021 04:43:24 -0700 Message-ID: Subject: Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure To: Peter Zijlstra Cc: Kees Cook , Jonathan Corbet , Masahiro Yamada , Linux Doc Mailing List , LKML , Linux Kbuild mailing list , clang-built-linux , Andrew Morton , Nathan Chancellor , Nick Desaulniers , Sami Tolvanen , Fangrui Song , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , andreyknvl@gmail.com, dvyukov@google.com, elver@google.com, johannes.berg@intel.com, 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 3:45 AM Peter Zijlstra wrote: > On Mon, Jun 14, 2021 at 02:39:41AM -0700, Bill Wendling wrote: > > On Mon, Jun 14, 2021 at 2:01 AM Peter Zijlstra wrote: > > > I understand that the compilers actually generates radically different > > > instrumentation for the various cases, but essentially they're all > > > collecting (function/branch) arcs. > > > > > That's true, but there's no one format for profiling data that's > > usable between all compilers. I'm not even sure there's a good way to > > translate between, say, gcov and llvm's format. To make matters more > > complicated, each compiler's format is tightly coupled to a specific > > version of that compiler. And depending on *how* the data is collected > > (e.g. sampling or instrumentation), it may not give us the full > > benefit of FDO/PGO. > > I'm thinking that something simple like: > > struct arc { > u64 from; > u64 to; > u64 nr; > u64 cntrs[0]; > }; > > goes a very long way. Stick a header on that says how large cntrs[] is, > and some other data (like load offset and whatnot) and you should be > good. > > Combine that with the executable image (say /proc/kcore) to recover > what's @from (call, jmp or conditional branch) and I'm thinking one > ought to be able to construct lots of useful data. > > I've also been led to believe that the KCOV data format is not in fact > dependent on which toolchain is used. > Awesome! I await your RFC on both the gcc and clang mailing lists. -bw > > > I'm thinking it might be about time to build _one_ infrastructure for > > > that and define a kernel arc format and call it a day. > > > > > That may be nice, but it's a rather large request. > > Given GCOV just died, perhaps you can look at what KCOV does and see if > that can be extended to do as you want. KCOV is actively used and > we actually tripped over all the fun little noinstr bugs at the time.