Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2678258pxj; Mon, 14 Jun 2021 04:46:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYWQrWMWnwvKp1g8/yJIvgub5wftnswb053gqDJnONQBy3EWOpA4ytD9IBQNp+ahDjlwJ1 X-Received: by 2002:a05:6402:1d38:: with SMTP id dh24mr16799198edb.18.1623671174340; Mon, 14 Jun 2021 04:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623671174; cv=none; d=google.com; s=arc-20160816; b=sKg2rAXUqUTYUmdXF6u1JDyKyWVJRSr7jKYyboB0AYVajzqZ+zOWzqbGLsNCCAx/ms p2LCccbLACs4CEwCyz/O/juF76P9w6ypWLRIp3DjQSrIadyE5GbIgPaUhPp18aiSzVXl BT24Edtky0pdHUP86Z+/S3Mal3BngQ1cEJbEvG/xvUcrAmCGBVexfUJDCc//fPlQNBaN 1dGZZVocG8meD7GFrxaPS8eF9HaRUkWFafig+iK5IKVVRvFP6d8GrrwD95QX3PBx/A8Y BQTjwf/Rz53X0iI4EYMS1qgqOXzjeR9dPTUsz+JeUe+Rj8tGgWP4BGMjMVIzLowqM60B DQrw== 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=7Khk9VJiAZEUo5jow78IwItFdk7LfK4jmTWSp67zs44=; b=ejydhgfzKcBG7ovcWewhyFFFXFu4lGVqAjTXcWX2kXGTF+0F7SUrECnYVDivrUIND3 +I63BdA9qgZ4E72J5E0moDFvJUUcuHBNs4UZgVWpwCd70bOQYSPZr9dNXrUzE5BDbXod yryHiC37s3XpHk3kXUgVedi8+o5tbXt05tWCqiXkvFKfPcGzQDg7sW1+Wn4KzokYxQkZ G6tpCSKQsL4+hLBlBxlg5HrDxAFIp46fRCQwiczbaciPSEuuFLxoacDIFSL3zkWcdJe0 pIMu8Kn5vMvu27qiHdoxixooYHbvarwmY/C0XTIy7lUUeHVwVegdmfEcN9KoqAr4wVIt px4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GOcz1YcH; 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 q11si11066210ejs.90.2021.06.14.04.45.51; Mon, 14 Jun 2021 04:46:14 -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=GOcz1YcH; 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 S236109AbhFNLrB (ORCPT + 99 others); Mon, 14 Jun 2021 07:47:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232901AbhFNLqA (ORCPT ); Mon, 14 Jun 2021 07:46:00 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E5BAC061787 for ; Mon, 14 Jun 2021 04:41:16 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id u24so46048662edy.11 for ; Mon, 14 Jun 2021 04:41: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=7Khk9VJiAZEUo5jow78IwItFdk7LfK4jmTWSp67zs44=; b=GOcz1YcHwn9vgKrtti2m3vYVfzrDbyOPJ4rqWNtz5qRjBuNylB9OmfA+OA851kfhOd BF0XxYRjtjYnmPF/YS37wERJomtTZfzB38tGS+6n+pCpdSFhxJnUSVgm82ewx33tcdl/ vLLvnBF5Ve1MG1pM2zXwRHRAFPwIJJfrFgR5Ygjx6MBdMiwxgX3Q8B1LvMsRjkTz8CTQ MOmBG+TPI2AFgOJCaehq32t79EG7CBA18uQa3bal0btKG6YYTbLhtNhO4N2210c8cNY4 ufxqnAg7dCaNM+TcVX0XYjw+moDzfHkRWqFuPWM2YQJd+0dSMcUq3qlTsgsy6D/FE1B3 8eyw== 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=7Khk9VJiAZEUo5jow78IwItFdk7LfK4jmTWSp67zs44=; b=jy3ZHpIeeXi0QRrRDkCr0BNVrnHdCXO7skPV3goeNp08NUiiOLuDld5dufUzs6WtGr Qie/SIBG51mbwu1H38YLg1z0OJqFkr/xXO4Xb2jzzVtOxdxsIeEiZ2h/udO3xSF4n25r 9qkB6teVaWVUxkx/BDvCynLH0JR37P9Lv3OQ0xmwI1wEYJEAUkOducHtJr6PjwFp2h5x TNRJP6ePx+ik19dWRQ0CUfAR13hzbrp+JSRfxKumX+kTttab3XQOSgXlq7kDTyzs/jlf XPKqrEmfY6IqccjJYIIxOQZS3AEdPFnpsdIkfEGEoghf90pZZEFDaprDAIqY/oJKNFW1 HrQw== X-Gm-Message-State: AOAM531/V5OPuLYPEv76Xr/pN/lhVQgzVZCUKfSx+OrzdP79XbPjhEzh UU8KrNBucE8/ReLXNHnzccx+4KUWXfqgssIqx1+U X-Received: by 2002:aa7:dc42:: with SMTP id g2mr16365775edu.362.1623670873184; Mon, 14 Jun 2021 04:41:13 -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:41:01 -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: > > > > Because having GCOV, KCOV and PGO all do essentially the same thing > > > differently, makes heaps of sense? > > > > > It does when you're dealing with one toolchain without access to another. > > Here's a sekrit, don't tell anyone, but you can get a free copy of GCC > right here: > > https://gcc.gnu.org/ > > We also have this linux-toolchains list (Cc'ed now) that contains folks > from both sides. > Your sarcasm is not useful. > > > 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. > > > > 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.