Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp848512pxb; Wed, 13 Jan 2021 18:13:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyMvZ3B17bclzuaWEn+Gb+QNiupJ3iuy+IOD7w2LdviVZ2BqiwzfzTqSMMxyh2XSMbPAVg X-Received: by 2002:a17:906:fb1a:: with SMTP id lz26mr3642571ejb.194.1610590433997; Wed, 13 Jan 2021 18:13:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610590433; cv=none; d=google.com; s=arc-20160816; b=WIlMKV75QhM6jOc0gZ9THiw97pofCe/VO/qTiqVh1wsoAipmSNurBUc6rGfa8D1e3g o6dYOroD2ezkSP2unN3605vrMd2AGwtgBSQANCQPHeHpe76RegqvA2zRtSMinqqJpZ7r wdcScEfvkApbgpqAT8x+PNnbdcxul/u3aJTPkVYDuTpdW1Zbko0caz9d914CZj0vTslh oSqYR+nfP6AunGv/xOP6wUwdrBlkyyG3r0P0L8R+icsLJNpgC2crqhfWg3+9H9rTH05E DLbPnU7mtOPvHQ4wQbKPUH7nBZlViYi7MjqaiNhG9YwYZLs9XE+azzgG5EpsuyRStSJE fTMQ== 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=mT4FJ5faHT6kx4m/+VpI3KjNLQvDBDZDe9LTS609qwU=; b=Y/6RXbZFIn6rkPAJSyEYrot5z9R2PF1r507AtNzK0DZoX/p6azyyXYkBv76JjBWGws 0m0URiN/Wua9R0wx13CT5OBnRyIPvDQaELOmyyQO0p3SwN00OA2XdRKIK7oJqc6leN8z Piv8rf+yFM9hoFY1JRL1wIYJYMgWP5yfKDYRpECvOh5TtQqJUG5Okypv10o2Xth2XS0S lkhpufGrzZRMf05vP3QcslCJkez7W5V/U8suOKkmG8479qT/bLF9c1eTeMFd1aRR8hl3 bTpbJHZjZqOPKlsZUluQXtNK0CIDXxOa17BWmQdc2qdwsf0uk0tEdT0q6X7f5Jd1Bv5X 6CpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uT51003C; 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 g13si1890552edk.250.2021.01.13.18.13.30; Wed, 13 Jan 2021 18:13:53 -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=uT51003C; 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 S1726695AbhANCMk (ORCPT + 99 others); Wed, 13 Jan 2021 21:12:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729236AbhAMWAw (ORCPT ); Wed, 13 Jan 2021 17:00:52 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71BE4C061795 for ; Wed, 13 Jan 2021 14:00:11 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id by27so3570393edb.10 for ; Wed, 13 Jan 2021 14:00:11 -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=mT4FJ5faHT6kx4m/+VpI3KjNLQvDBDZDe9LTS609qwU=; b=uT51003CLT7E627tBqLkwWrU1PVJGq2/ZMQqORYgP/O2pHjSbQU/+++0TXmm4i8is6 OARUSIgqWunXkWiEvn7QA6CKb35uF8Ku1QQbQxnLocI54fY87d1EbdIGaxJQgPGPPNpG sKynEK0BQxUKiAsyo3I9mUReOW0Yrn9p14437+A6dsPP1Ah98uXS0jQMFvcovol60ZyS mpErIteohbvU2Vbc+tBEoTDcHUGjD8plBHS/VvZ8bC2qUmYs/Fh4YqJFb8PwkbC7S/Rl h50qDhicSqelFiRP/M/ZqC6YzDMO9fwpdFAwGPpyDIkmBqB7cEsEmSgmsxP3cOFv8Hau BwqA== 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=mT4FJ5faHT6kx4m/+VpI3KjNLQvDBDZDe9LTS609qwU=; b=HeIpPVMvjYsTokl/Gj6mj8MGKCkgrlXbJvbvyliC8VWDITYUKDfD1aDvoUYwElzwug sSfvRduZ48juF9Se2FaoYPva2yKiSVwumAXcSM1H9SpgxQSpzV7IxpGVPO0B2A+5cXXJ dJQEPA6RO+Pn7Y/xzzJ6HagjKriKkPFIbWuLDsFrdAA7vraH4WC/4uYr0aJ+h25u97c6 MHAVwrAzdQ+ApRwsDWzvhNXl7i0NmbEz5IDJUoXIojPC4JyjUqrx0BJPkjH+/CipOQyG lbypkVxs7jrYYQAJobUJmvHDhB647fHx3ss5iXj4x/3M8AcBkKlCVM4ICO6Z5qY4zzp/ axog== X-Gm-Message-State: AOAM533RjyFkPN/TZSUeNpCdvf5XdL2jLYJe4Rfujs4cI6/IKGq8ASXd HEHN1/8pwwC06Tsq0396c/ay6R1anUC1JUwM6ZLv X-Received: by 2002:a05:6402:513:: with SMTP id m19mr3469396edv.244.1610575209296; Wed, 13 Jan 2021 14:00:09 -0800 (PST) MIME-Version: 1.0 References: <20210112053113.4180271-1-morbo@google.com> <20210113061958.886723-1-morbo@google.com> <20210113205547.GA21653@Ryzen-9-3900X.localdomain> In-Reply-To: <20210113205547.GA21653@Ryzen-9-3900X.localdomain> From: Bill Wendling Date: Wed, 13 Jan 2021 13:59:57 -0800 Message-ID: Subject: Re: [PATCH v4] pgo: add clang's Profile Guided Optimization infrastructure To: Nathan Chancellor Cc: Jonathan Corbet , Masahiro Yamada , Linux Doc Mailing List , LKML , Linux Kbuild mailing list , clang-built-linux , Andrew Morton , Nick Desaulniers , Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 13, 2021 at 12:55 PM Nathan Chancellor wrote: > > Hi Bill, > > On Tue, Jan 12, 2021 at 10:19:58PM -0800, 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 > > Change-Id: Ic78e69c682286d3a44c4549a0138578c98138b77 > > Small nit: This should be removed. > Grrr....The git hook keeps adding it in there. :-( > I applied this patch on top of v5.11-rc3, built it with LLVM 12 > (f1d5cbbdee5526bc86eac0a5652b115d9bc158e5 + D94470) with Microsoft's > WSL 5.4 config [1] + CONFIG_PGO_CLANG=y, and ran it on WSL2. > > $ zgrep PGO /proc/config.gz > # Profile Guided Optimization (PGO) (EXPERIMENTAL) > CONFIG_ARCH_SUPPORTS_PGO_CLANG=y > CONFIG_PGO_CLANG=y > # end of Profile Guided Optimization (PGO) (EXPERIMENTAL) > > However, I see an issue with actually using the data: > > $ sudo -s > # mount -t debugfs none /sys/kernel/debug > # cp -a /sys/kernel/debug/pgo/profraw vmlinux.profraw > # chown nathan:nathan vmlinux.profraw > # exit > $ tc-build/build/llvm/stage1/bin/llvm-profdata merge --output=vmlinux.profdata vmlinux.profraw > warning: vmlinux.profraw: Invalid instrumentation profile data (bad magic) > error: No profiles could be merged. > > Am I holding it wrong? :) Note, this is virtualized, I do not have any > "real" x86 hardware that I can afford to test on right now. > > [1]: https://github.com/microsoft/WSL2-Linux-Kernel/raw/linux-msft-wsl-5.4.y/Microsoft/config-wsl > Could you send me the vmlinux.profraw file? (Don't CC this list.) -bw