Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3200176pxb; Tue, 19 Jan 2021 17:04:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwopWYu7SCd3lgDj+QeqeDukB8hVDRQt70n7tQB3QrIETcs/3h7KJyoGiQsNJ45asCDgBuw X-Received: by 2002:a05:6402:3553:: with SMTP id f19mr5479720edd.271.1611104688721; Tue, 19 Jan 2021 17:04:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611104688; cv=none; d=google.com; s=arc-20160816; b=w30b+1G6YJG+4rSwq7DZg/pAOOeLGSR5UWNwrN9fdt6iyb+eawnlVhgqUGwd/rLWuP oFYg2e2q5NyTzpxZqJNE3FWE8WZwQOSYhlmzP8NPilQP84hEwkYly0tZnccPIvRnUxX9 pX0dcgJtVykJUEfIxyAnTazjaY2mUV0v9WjZM42wxPB1lJH2kg0mO6I5qN/PdzvtCZPB abj1Eax7xvT1ARUJ+NcQwf7Lt/fkQgJZeappG2e0LPwTPDHKfpdyGlPC0R/fh81S/gZX m4MwUL+3hAc/kYtgC2nTwTlFfXbu/UW2u1jg3tyb77aF+HN9rgF8SajxhjQ50i8hOFuC lVbg== 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=2ijWFqCFik7AEqDTngTlHLoNVrHEGUc429TyhF79LIQ=; b=VGqHuVORTGy7E9kD6Sne3xMbxa6lYG4kG40ibMKQvhHa59OW+pRrLcymGAgoM7MbfS gHzRn/fNuIBbpPFRFE7cM/gaa5ZEHWE7VZ+n4Jt42Hw9BCol61/F5IqqpNanBXXD30nj yLa+IUKc0XHXuMAqJ4/e4vz6oDOIFzDFydyqkuXsAO7SWAeorNtYP+xYP1VJVn2WWoPq vuq8ysGynNGC8eXJGdxPm/ldLcu7hZcTk0ByWd5M5R3UhUnVuTKHQrYyDruCwU29r3hw HYAYpC8KDcAeOdViKXARZ6OTb78YwKMlM4fl6QoOOdA8rrqSDoIsVKaypZtTZVuxKjvC gu+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XwWSQ6Yx; 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 rl7si136673ejb.506.2021.01.19.17.04.25; Tue, 19 Jan 2021 17:04:48 -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=@google.com header.s=20161025 header.b=XwWSQ6Yx; 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 S1727287AbhATBDe (ORCPT + 99 others); Tue, 19 Jan 2021 20:03:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727016AbhATBD3 (ORCPT ); Tue, 19 Jan 2021 20:03:29 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6BFFC061575 for ; Tue, 19 Jan 2021 17:02:48 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id j12so1072195pjy.5 for ; Tue, 19 Jan 2021 17:02:48 -0800 (PST) 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=2ijWFqCFik7AEqDTngTlHLoNVrHEGUc429TyhF79LIQ=; b=XwWSQ6YxMKSzHmONRcdMjeTrCU3nawwN1QwjYEutC9XmpcEdEYone0ZC91cDkkDEUh 6mKJo0SNJOXpA2FA6tBClNjguod31Xyr5E9hSOUL4mh7WF7EUsd1KdBwQqruBXNlES5w JD+jvf6GOtHscsAWlqUjtu3RBDgpGx7szPZKjwYLcf5y/i4G56Y+rsavpOJb0eBRhQBm YajWuokO+ZJ8KoCuPFfdti+7cxqyiuO+lzbsN/HNsAWzw0Cuf10FGGF464ci6xg5Ubsd Dv/kwEqRFCMxI2hqTyM0R/+hOsCD2mm2DHyZFjMgJmJX8zTfNiaDY+FQHhowUz2yfx83 w8SA== 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=2ijWFqCFik7AEqDTngTlHLoNVrHEGUc429TyhF79LIQ=; b=Tk+Frq1jKlFVwVk7WNl4/JvqCCmAIzsIliVvr3SkPBXyEiKSJ38AsaLAuCeqX9vhAl 4PJzRFEMn1rGcZOLZzUACVBMdtjfW3GI5GTGL0TZIhsh29FQGtTNDghU5TPsI5r5KXKR vdW1/yZyA4VAY4K59eWLYug2NNrtT2M5XUa+FsGosm4lH7PDTTqiL1umMmwPnc6qSwzs 7VilHYHrYYwG2X87tJN2TAK7NIhiMifN1OXl3DhzoJVVPlKydN/YMlS/AnwaKoeMk+3F O5uAmYge4TYuDS/HCOJNH6gm1BOLAASsMUHMwdAGzUSkMGg+jPcFVgqH89yeB5fv7ole 5Q8w== X-Gm-Message-State: AOAM5317sWhzU0KhVLlxh9ztD6Pbnq/+63YPGZWjXJ//EaQsT7kEG/77 8qYC/k9aw6ptN5hzrVj+XoRl7HwlAdi6t0NQMb8PSQ== X-Received: by 2002:a17:90a:6ba4:: with SMTP id w33mr2729981pjj.32.1611104568023; Tue, 19 Jan 2021 17:02:48 -0800 (PST) MIME-Version: 1.0 References: <20210113061958.886723-1-morbo@google.com> <20210116094357.3620352-1-morbo@google.com> In-Reply-To: <20210116094357.3620352-1-morbo@google.com> From: Nick Desaulniers Date: Tue, 19 Jan 2021 17:02:36 -0800 Message-ID: Subject: Re: [PATCH v5] pgo: add clang's Profile Guided Optimization infrastructure To: Bill Wendling Cc: Jonathan Corbet , Masahiro Yamada , Linux Doc Mailing List , LKML , Linux Kbuild mailing list , clang-built-linux , Andrew Morton , Nathan Chancellor , Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 16, 2021 at 1:44 AM Bill Wendling 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 > --- > v2: - Added "__llvm_profile_instrument_memop" based on Nathan Chancellor's > testing. > - Corrected documentation, re PGO flags when using LTO, based on Fangrui > Song's comments. > v3: - Added change log section based on Sedat Dilek's comments. > v4: - Remove non-x86 Makfile changes and se "hweight64" instead of using our > own popcount implementation, based on Nick Desaulniers's comment. > v5: - Correct padding calculation, discovered by Nathan Chancellor. Specifically for v5: Tested-by: Nick Desaulniers If anything changes drastically, please drop that and I'll retest it; otherwise for changes to the commit message or docs, feel free to carry it forward. I'll try to provide code review by EOW, assuming we can stop regressing LLVM so I can focus. (Ha!) -- Thanks, ~Nick Desaulniers