Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp380794pxb; Fri, 15 Jan 2021 16:06:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXGmEWt5DhWqwqgiqE8NmOeDRQ1UYIExOkTEs8BLtWQ6J5P15A6dZkA/czxFAIl8To0mim X-Received: by 2002:a50:dacd:: with SMTP id s13mr11753247edj.173.1610755583604; Fri, 15 Jan 2021 16:06:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610755583; cv=none; d=google.com; s=arc-20160816; b=tVqEPIrzdxAzPteiVcryz7D2CdVVDvzDtXMln13NrtE4LJAjmejCLWGt6Ou+Te0j0o fCZpPTHCDV6Xyd3q2X8z7w7Eql5lNdsGsRdNRFOt8tzi6ZFZs5CTZkTGxCQSVWTqL+zi 6+uAkFgYA9W08KzgF2+NqsYwRESCM5S1I7Kzx8fTsxHBv2h86vk12tLPfSNSSXHmn/Nk 9IB3H8Px52ueGd6h21qlcdmlcqHr56VivgqHsWkn/l7ncy3GRsUQhtF/RHe7tfBAa8zj LLbBgYtE6LL00Z/RNQqhAz0CoKqQRWccx1DpQgfajBF6q6OdlR16YDP5Dm4N/AfKyAs4 LgmA== 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=FY8VpQNfhIxBmUN0CCall3v72xLkiHt1IqHsb3quwR4=; b=ktBilbFuD8Qbn3ySKyXeU95TOZQ5Mo0iySpFNZ35iw3XW8HfRvYA9qHFlpW0/HtRYp IcvMDxPdIfUA/MH8ubJRKeKRZ4uuMxQC7VJLLdLHctuexSaW9S+bkOwM9wnbUDX4IaHF DpRnJ8jXlWjDZ5MFBWTDXQiqidpm9uIW4oHymBCJGkgTjgZ5sBMM6mWtCm3b63AOoZ0+ 5wYf04/0Xt1znh+z1J0e9qd9Qx1JTFUaDoIHpY2D5nS7UegX5TMP1wz9NSR0VaAD4PYH 870D/eE2Bbdalz9rBC64Nf9FhbGAI7Q7Lkt3ACAfTFshQ7eyG4tFr1XdeGPE6uxVczCa qXgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=luKEj3Uo; 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 d12si4393977edh.221.2021.01.15.16.06.00; Fri, 15 Jan 2021 16:06:23 -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=luKEj3Uo; 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 S1728621AbhAPACo (ORCPT + 99 others); Fri, 15 Jan 2021 19:02:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725863AbhAPACo (ORCPT ); Fri, 15 Jan 2021 19:02:44 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F6A0C061794 for ; Fri, 15 Jan 2021 16:02:03 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id l23so6144598pjg.1 for ; Fri, 15 Jan 2021 16:02:03 -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=FY8VpQNfhIxBmUN0CCall3v72xLkiHt1IqHsb3quwR4=; b=luKEj3UoOFPuOKbYwRLoqFsDstinvsZbmPyy851wXrrnY6L+VRXyETTqdGgw5hGxLP q82oal/qKPyYEtADP0J+9+aBTHtWcStqg7f1d2isGuDnoxu5PU5w2R93MXCZlyflx7l7 2o23TrL3joPsXdxh4adFBgmxw8KI6tA70dzTICQIh6Z6okR/z0pWkGEKOZgja4fDXYdG DyEQN0FCTeWyAWBEferv1Qib1rPFv4dHvg3qKJ+/zKLnUD9LMAW64+23msX/mrMix17s vqPEIc6shaHkKBmGEJoepfmcUzY6UCsQYw68cMqc890Tb5k1Xwy/ExMW6A4K+8uwTgVs azuA== 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=FY8VpQNfhIxBmUN0CCall3v72xLkiHt1IqHsb3quwR4=; b=nb4HYxLyozBbOEBxoiDWuRa1k5UxCreMYYtxKwiN5GjimpzzgaUuQpctXShacurRV6 VchK2pg96EhtM8lFbZ8NlFkTIJEMdWAUs7kRyd70lrf/AueW1ueP1xsK8/AWVBzEqIz8 9nBLWH11zyGxArOzxlGn/1AOKFWeaabOvAe9uCOHasD81rC25mJgqopipXnAXibsHoF2 98HZh1yurNpqXpSbURKCPw1mxNot+P2fRy30zYRwR1rmdHrY0HYSYsBjmZdRS+2MOCun w7XkvukGNpOQ/upQhlk7KLKY5iW/l9KrHFOpDNzQemvh+NOaOWYeFpPZmcVJTb50RnaI 5B5Q== X-Gm-Message-State: AOAM531iSczJtfnFRxDi0bMTnNCzF2dW6toXqQtJOTHxLw3UnkWqEI9v SbvtfPUqcTqVsmv8JT8ZBZOVNdogw3Vpf7wHEk8PmQ== X-Received: by 2002:a17:90a:6ba4:: with SMTP id w33mr13549703pjj.32.1610755322387; Fri, 15 Jan 2021 16:02:02 -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: From: Nick Desaulniers Date: Fri, 15 Jan 2021 16:01:51 -0800 Message-ID: Subject: Re: [PATCH v4] 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 , Sami Tolvanen , Nathan Chancellor , Linus Torvalds 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 8:07 PM Nick Desaulniers wrote: > > On Wed, Jan 13, 2021 at 12:55 PM Nathan Chancellor > wrote: > > > > 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. > > Same. > > I think the magic calculation in this patch may differ from upstream > llvm: https://github.com/llvm/llvm-project/blob/49142991a685bd427d7e877c29c77371dfb7634c/llvm/include/llvm/ProfileData/SampleProf.h#L96-L101 Err...it looks like it was the padding calculation. With that fixed up, we can query the profile data to get insights on the most heavily called functions. Here's what my top 20 are (reset, then watch 10 minutes worth of cat videos on youtube while running `find /` and sleeping at my desk). Anything curious stand out to anyone? $ llvm-profdata show -topn=20 /tmp/vmlinux.profraw Instrumentation level: IR entry_first = 0 Total functions: 48970 Maximum function count: 62070879 Maximum internal block count: 83221158 Top 20 functions with the largest internal block counts: drivers/tty/n_tty.c:n_tty_write, max count = 83221158 rcu_read_unlock_strict, max count = 62070879 _cond_resched, max count = 25486882 rcu_all_qs, max count = 25451477 drivers/cpuidle/poll_state.c:poll_idle, max count = 23618576 _raw_spin_unlock_irqrestore, max count = 18874121 drivers/cpuidle/governors/menu.c:menu_select, max count = 18721624 _raw_spin_lock_irqsave, max count = 18509161 memchr, max count = 15525452 _raw_spin_lock, max count = 15484254 __mod_memcg_state, max count = 14604619 __mod_memcg_lruvec_state, max count = 14602783 fs/ext4/hash.c:str2hashbuf_signed, max count = 14098424 __mod_lruvec_state, max count = 12527154 __mod_node_page_state, max count = 12525172 native_sched_clock, max count = 8904692 sched_clock_cpu, max count = 8895832 sched_clock, max count = 8894627 kernel/entry/common.c:exit_to_user_mode_prepare, max count = 8289031 fpregs_assert_state_consistent, max count = 8287198 -- Thanks, ~Nick Desaulniers