Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp323823pxb; Thu, 5 Nov 2020 00:32:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2OuW2ZU34irX045Z79nhBF9Me2evY/bflvS3xEMcVkRmf+PlOWz3IxftCme1P+ZEeky0e X-Received: by 2002:a17:906:3e91:: with SMTP id a17mr1235190ejj.82.1604565152788; Thu, 05 Nov 2020 00:32:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604565152; cv=none; d=google.com; s=arc-20160816; b=uxwKRPmSnW/N+dJjRIlzGxLG7DKvCYA89YY/NOlLRswxPwVzgmNQLsQDLNCcRWoLnz Me1BIPVoDtlp3C2a/FbAkLifeKHa5xtdFo+/a9fGls9zXkkwbhaDktxILDS65i56DiMc 19igQVGsLuXI/ubn533OtWPi2WG1mLoRTk8GcFZM36+r38bkUpNt9r4K/mOGkBdrF+zf tQJZy8sT3hRbovWF60XADgCjxc3owozlcfypyl6xuHeQ3GLrw2J7jO8uRKg7NniJ4jfo H11ZCSBBKlBA7Eqo7G7MmS736ioCi6Ewss/ApGSsg0NbL9A2GwxSKlNk5uZ1NR0Bs4Pc RkFA== 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=264wdrikSygrgRX7gnlG58YTkPsCHu6frlnu5l84msg=; b=B8jAg/7ogz9ci+TxBpbVuRDb0Dce1ssCzVmBzieFd7xvG3W9O6hLHw9gDRpRsCWAGA i+1ldHLYPniKoFq2qJUSIey7MF/B3ZG37yGliQHP/t+gWELI+7ZrkKe6HzXOXzMSOsE4 RhWiw9OmQhGL4ns0LAisPpbS9xqOCXCqh6lvATo1uusk5pABAbVWWWF2pGBq3oaF+B/4 zhQk9sx1LQB74IlWt8zX5qzbggxhMoRy7dVBYpv7Hx4oyIchlsgF0RlJVdE9bJBIZrhT lbtx7uBFGY+xV15xfRkHMUhBhSAuyjN0dqW02uq2nmLyOom14CPekFqKAwuDqzSPm4df 6WoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZujLkERm; 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 k16si604242eja.59.2020.11.05.00.32.10; Thu, 05 Nov 2020 00:32:32 -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=ZujLkERm; 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 S1730179AbgKEIaH (ORCPT + 99 others); Thu, 5 Nov 2020 03:30:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725827AbgKEIaG (ORCPT ); Thu, 5 Nov 2020 03:30:06 -0500 Received: from mail-yb1-xb42.google.com (mail-yb1-xb42.google.com [IPv6:2607:f8b0:4864:20::b42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3412FC0613CF for ; Thu, 5 Nov 2020 00:30:06 -0800 (PST) Received: by mail-yb1-xb42.google.com with SMTP id a4so609770ybq.13 for ; Thu, 05 Nov 2020 00:30:06 -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=264wdrikSygrgRX7gnlG58YTkPsCHu6frlnu5l84msg=; b=ZujLkERmMZk6Ns2h42kACmMmDk2/V3/OlDZv0fGlZB2SHvVthIIX0kbWZv89IOpVKE Vxdh4fabAgv6OX/FCklXzAJvy99rFlc8ytr/X7rzNiMnKloi7CeZpkXU2JAvcoJG24Z/ NjPYGZx9Yez4+knY6/2dE7+FLZWtzbFe96+TpMrJK0jk7w74ikDFioQPIbrXSFB9f2TQ eq7eDjPbBKl6UTZFZNjtkjYBxPio03HSjed6aRwVwMofLZ4D3wCsh0nZbkY40yKlaNW6 AublFP/IYeFezCV49NEUdgZWem/4ueZf8kpGwJ675cVJfEGYtcAmyiv3h/UWWQnXUnFk XW4g== 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=264wdrikSygrgRX7gnlG58YTkPsCHu6frlnu5l84msg=; b=BTEa0cXq5lplAFVe8s1tDe8VKIL/tqQp427cer37ZbJh2IJ1QGmYV8cu+c1GM9U+TN Q1wYMdZQjqDnIsrkloMvsJ+hVHqfnyOJ9PGTWYDirQ8rkZCGumAMKdqnJatys3b2dzoh 28hACKY6gAcVeMRLW9k9jWHi7rwvzC4e0NAs4H215Gm5lb7/6bAK9ZBiu8IXVa/8sRJE svKuWvxokbt/ea6l++CiF/mFX18QMV/YCcnKB+Av6UJw3NOytJlVFzPvlP0rBgGgron8 yX6jrDAFHqf8SOb/jtL8XF0bBHHhxxFeeLypVsyZTq/8KTToINYfp4j0sZeiP+ikFuiQ q1Pg== X-Gm-Message-State: AOAM532K1HDkznu03d39++W1nLtjkjTRcdH7cJ9Rr7uifxEXGhqxNJbk ojD+e1deSs9u7agnqz4vdNXzpk9uEU+W/n49gIjjnA== X-Received: by 2002:a25:20d5:: with SMTP id g204mr1900863ybg.136.1604565005158; Thu, 05 Nov 2020 00:30:05 -0800 (PST) MIME-Version: 1.0 References: <20201102145221.309001-1-namhyung@kernel.org> In-Reply-To: <20201102145221.309001-1-namhyung@kernel.org> From: Stephane Eranian Date: Thu, 5 Nov 2020 00:29:54 -0800 Message-ID: Subject: Re: [RFC 0/2] perf/core: Invoke pmu::sched_task callback for cpu events To: Namhyung Kim Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Jiri Olsa , LKML , Andi Kleen , Ian Rogers , Kan Liang , Gabriel Marin Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 2, 2020 at 6:52 AM Namhyung Kim wrote: > > Hello, > > It was reported that system-wide events with precise_ip set have a lot > of unknown symbols on Intel machines. Depending on the system load I > can see more than 30% of total symbols are not resolved (actually > don't have DSO mappings). > > I found that it's only large PEBS is enabled - using call-graph or the > frequency mode will disable it and have valid results. I've verified > it by checking intel_pmu_pebs_sched_task() is called like below: > > # perf probe -a intel_pmu_pebs_sched_task > > # perf stat -a -e probe:intel_pmu_pebs_sched_task \ > > perf record -a -e cycles:ppp -c 100001 sleep 1 > [ perf record: Woken up 1 times to write data ] > [ perf record: Captured and wrote 2.625 MB perf.data (10345 samples) ] > > Performance counter stats for 'system wide': > > 0 probe:intel_pmu_pebs_sched_task > > 2.157533991 seconds time elapsed > > > Looking at the code, I found out that the pmu::sched_task callback was > changed recently that it's called only for task events. So cpu events > with large PEBS didn't flush the buffer and they are attributed to > unrelated tasks later resulted in unresolved symbols. > > This patch reverts it and keeps the optimization for task events. > While at it, I also found the context switch callback was not enabled > for cpu events from the beginning. So I've added it too. With this > applied, I can see the above callbacks are hit as expected and perf > report has valid symbols. > This is a serious bug that impacts many kernel versions as soon as multi-entry PEBS is activated by the kernel in system-wide mode. I remember this was working in the past so it must have been broken by some code refactoring or optimization or extension of sched_task to other features. PEBS must be flushed on context switch in per-cpu mode, otherwise you may report samples in locations that do not belong to the process where they are processed in. PEBS does not tag samples with PID/TID.