Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2246808pxb; Mon, 11 Jan 2021 05:06:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTEZEv5yA7ht/g0Lj2nj5KYlG8xCCBCCWzU7YKCjy6oU5ov1WXoNrMKHjQNh7ysWnjq2jd X-Received: by 2002:a17:906:3c04:: with SMTP id h4mr10456350ejg.220.1610370397759; Mon, 11 Jan 2021 05:06:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610370397; cv=none; d=google.com; s=arc-20160816; b=dtxdoYoG8k5Et+3GNQDe4s9pVMeGtbPzhHp3R4tXQIk+2pTB1VqUXVb6NDrEOR20jE NgVZsHm5TfuLQ6Ik8nHuJVj+MepRmBEUxfF710I1kSpMwesYaDrM5s1jlkD47lzHmnez +Ux6teZHH8nAr/b2I+6ddirGe8I2osiMvxUFF+tfgeyGtokGPupxyPaax7vQ9/8n2g+B e/8wPZiWG3E0dBrf62+Upk8jijj+uYhPjG8qkCebl12s1pv0Fz6uSlHSdB6Y/vj89yx3 Nh/DGeiIXNNznTtO0dKkCzqC4zIWVt+smei1McK2qFXIG1Y7gYbx5tV90GJE7+GU4U6e v0wg== 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:reply-to :in-reply-to:references:mime-version:dkim-signature; bh=j5tKtkam/Ub1Md37B64s62bHI597iFY5nKOCVt15ZyM=; b=tEkKP7lAwQo6wBsgBhI3FgXiP1dBX+UxYEgsGWQU+dLLwVnVGfIDlEX1PGR7JglQK+ c87QUd8F513V0NWeCYj4NIl4EJVu+PoWFnAyz86Jv0yYXgFao1SXCbqThsFUaG/UIj0Q WEXPsfUbHHOQElMZJURUwkoPOWlF5Ujv4ZzjEDGtblpZVtsT4eiuxhDG4JIlCdFyTzTT VqiIUUahpkrdtTTO8UngevGWIcFGPJIMIEmuJgWyGWuqyMViVduSZQP3qqbweVSFxfAW 2XaBTc8qxXHfTd7YeWhCMQKirJiCQsoN8g9E6UQBlH6GKJFrp2UQ5X/7hbl0I2T+r4vD 6Vfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DQxOQePu; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs24si7079556edb.519.2021.01.11.05.06.13; Mon, 11 Jan 2021 05:06:37 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=DQxOQePu; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728806AbhAKJ61 (ORCPT + 99 others); Mon, 11 Jan 2021 04:58:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728747AbhAKJ61 (ORCPT ); Mon, 11 Jan 2021 04:58:27 -0500 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4283C061786; Mon, 11 Jan 2021 01:57:46 -0800 (PST) Received: by mail-il1-x12a.google.com with SMTP id q5so17717019ilc.10; Mon, 11 Jan 2021 01:57:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=j5tKtkam/Ub1Md37B64s62bHI597iFY5nKOCVt15ZyM=; b=DQxOQePu1f+CNNPICvfkgHa84Fbf8AlNxPNV6ghJ4t2BwGM8JkCbEGbLcNi9CXSRnc MzeK5k+viO8ZKl/v5g+v8flEroGTb4h/QQB24XOCj0u382KRixPxng+uQGYkKtv4Bbko q+MIkVGc/+jj4b9hIOyTJqp1h3Ese30G4/xnU3uOa1rECHMcN72vuQbhfHQxL6TmBNVo EAS1mC8S3+/zfyIepZBcMCTYiiG+FH8H/5FOnxsD/wko9MZcXPQWlWo6q234pcSMPPkK c/dj8jZCRW3zk8vlprQEVwYuP9A7o1SELF4ccP2OZgOihZw0JZATHhyxCwkH4YuNuQQJ kRRg== 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:reply-to :from:date:message-id:subject:to:cc; bh=j5tKtkam/Ub1Md37B64s62bHI597iFY5nKOCVt15ZyM=; b=M8JiJkCkH4IUriz3EAEXWz9Vfwp3fsjZgpyuBpCAc5FMklIk0VaQcza6DVf1NHxMQL OWkzKpkenPApHwnrKPlUlS0CMwcFfSnIkXsNwtfZ5o5L5ioRgplpMCMN9xz25+pTfGWR c0rAJ3FQAdGWO+J/2oRsl3sDqOsnLQLSOYS2aEgydEm8+60hLsJmTFKj62i629d4+Ypp tXDDO21+iD5PxPu8PTaD/2tN0D3Ett5gcyVKMv8TMMsETm7HmkLFlM7XKgvsjE+h5dMp AMgKJyTUskk7qR0fIYk8veVodVgXpKbEItswhPEv9Qq7atp6/+quhVexJK5q6NsSIVO2 izew== X-Gm-Message-State: AOAM5323QclLNWEl2hWJqQXaM9w0+ih+fKoPdtwReBsR28gsl5V4gYdt 0zG2XxWhktyQYJaOgCzN0+oyXocOzGVLqqzPJG3cVRLGC5Y= X-Received: by 2002:a92:c045:: with SMTP id o5mr5291338ilf.10.1610359066132; Mon, 11 Jan 2021 01:57:46 -0800 (PST) MIME-Version: 1.0 References: <20210111081821.3041587-1-morbo@google.com> In-Reply-To: Reply-To: sedat.dilek@gmail.com From: Sedat Dilek Date: Mon, 11 Jan 2021 10:57:35 +0100 Message-ID: Subject: Re: [PATCH] pgo: add clang's Profile Guided Optimization infrastructure To: Bill Wendling Cc: Jonathan Corbet , Masahiro Yamada , linux-doc@vger.kernel.org, LKML , Linux Kbuild mailing list , Clang-Built-Linux ML , Andrew Morton , Nathan Chancellor , Nick Desaulniers , Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 11, 2021 at 10:17 AM Bill Wendling wrote: > > On Mon, Jan 11, 2021 at 12:39 AM Sedat Dilek wrote: > > > > On Mon, Jan 11, 2021 at 9:18 AM '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 be used either by the compiler if LTO isn't enabled: > > > > > > ... -fprofile-use=vmlinux.profdata ... > > > > > > or by LLD if LTO is enabled: > > > > > > ... -lto-cs-profile-file=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 and isn't > > > compatible with clang's gcov support in kernel/gcov. > > > > > > [1] https://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization > > > > > > > Hi Bill and Sami, > > > > I have seen the pull-request in the CBL issue tracker and had some > > questions in mind. > > > > Good you send this. > > > > First of all, I like to fetch any development stuff easily from a Git > > repository. > > The version in the pull-request in the CBL issue tracker is roughly > the same as this patch. (There are some changes, but they aren't > functionality changes.) > > > Can you offer this, please? > > What is the base for your work? > > I hope this is (fresh released) Linux v5.11-rc3. > > > This patch (and the PR on the CBL issue tracker) are from top-of-tree Linux. > > > I myself had some experiences with a PGO + ThinLTO optimized LLVM > > toolchain built with the help of tc-build. > > Here it takes very long to build it. > > > > This means I have some profile-data archived. > > Can I use it? > > > LLVM is more tolerant of "stale" profile data than gcov, so it's > possible that your archived profile data would still work, but I can't > guarantee that it will be better than using new profile data. > > > Is an own PGO + ThinLTO optimized LLVM toolchain pre-requirement for > > this or not? > > That is one of my important questions. > > > Do you mean that the LLVM tools (clang, llc, etc.) are compiled with > PGO + ThinLTO? > Yes. - Sedat -