From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EA01C433DB for ; Fri, 22 Jan 2021 01:30:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1BFDA23381 for ; Fri, 22 Jan 2021 01:30:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726507AbhAVBao (ORCPT ); Thu, 21 Jan 2021 20:30:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726110AbhAVBaf (ORCPT ); Thu, 21 Jan 2021 20:30:35 -0500 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8491C061756 for ; Thu, 21 Jan 2021 17:29:52 -0800 (PST) Received: by mail-pf1-x42e.google.com with SMTP id o20so2671873pfu.0 for ; Thu, 21 Jan 2021 17:29:52 -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=xevnePlqkoJPc/gVx/RFwj12UYNRMR5SpPrBczxYlwU=; b=FAaMN6AyqXOw4wBmmhNtwxoT6KGu6JihNZn+M+CLJmuNa/lpE8D88XnxfKOLemwyHz TI5aKcgt1SVzfkXaJs/3nWef0FXiHqTH70dPrea3jrhHlNnnI5380+pLqgQN+d8AFjGz ZyIHY70PZX052b4pCrh19ltUyBOszpEr5+ocfkRMZ/mV1a6Cx2MyXMG1wDEFkfm2rLvn 8LsP51l5ke7HdGwWcRlanQ2FPrAPNyt1E2l664oclu4QV/nAhkkJBkVav18vjoZa4jk9 dXZNVYxEWXhgxwuZrbF7yZIlGYcqVVbkbQg0J3Ck36wlk07OaYx+GO5Ry5J0kB7ngJ5g XQFQ== 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=xevnePlqkoJPc/gVx/RFwj12UYNRMR5SpPrBczxYlwU=; b=AEj88+c/+jsYQ2wSqie8CReOvp3/SEZwVJH7qoZCNONxh754RrhBssT9CYo+tW5jLJ poTiF4KA7aHnffXB5bgniB1YVQNgy2bmxKhrN6CKfx1tbG+J2kXy4At2z2w2W2Ap2r+0 lF7PgX00JOW2miQBzdxW8NPGZURTKDNq8yybVmi2qMBLLR/0XJa2DNw4G6WJmjQQq9yQ kxsBULrgfGqY0HDXSqB6Z6uw6M4ANrYvrt3/3FjaZjuLNpbQ7szuLsV5NjsVBSaUdnMP BVHgPjKCFgIbFg9TMM+PfwHi503Ro7qfi/lrqJ6CAuDwQnTAbH0YcmXbIZvKU+UBZzI0 mMrg== X-Gm-Message-State: AOAM530fnkGix7FSIF+SCyV8xE1kIao+U1cZIMXXi0I2a6yDTwOUquDx vOFYvAs9HIDSR+auz9V/GEk/3yiAOvJXhdMzMxgfJg== X-Google-Smtp-Source: ABdhPJxkOo4l83vnl92ZQpYM5r+6B7BNXCAyHRCfWpPglFoyIk3UZ0hV69WA4xzR5J+LTI0hFIEBeIyGLnH/r3vR7dM= X-Received: by 2002:a62:838d:0:b029:1ba:9b85:2eac with SMTP id h135-20020a62838d0000b02901ba9b852eacmr2251542pfe.36.1611278991948; Thu, 21 Jan 2021 17:29:51 -0800 (PST) MIME-Version: 1.0 References: <20210116094357.3620352-1-morbo@google.com> <20210121082451.2240540-1-morbo@google.com> In-Reply-To: <20210121082451.2240540-1-morbo@google.com> From: Nick Desaulniers Date: Thu, 21 Jan 2021 17:29:40 -0800 Message-ID: Subject: Re: [PATCH v6] 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 Thu, Jan 21, 2021 at 12:24 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 > Tested-by: Nick Desaulniers > --- > 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. > v6: - Add better documentation about the locking scheme and other things. > - Rename macros to better match the same macros in LLVM's source code. This is a major win for readability and comparing it against LLVM's compiler-rt implementation! Thank you for doing that. It looks like it addresses most of my concerns. I'm not against following up on little details in subsequent patches on top. However Sedat is right about the small issue that v6 doesn't compile. If you were to roll his fixup into a v7 I'd be happy to sign off on it at this point. -- Thanks, ~Nick Desaulniers