Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750926AbeAPOnC (ORCPT + 1 other); Tue, 16 Jan 2018 09:43:02 -0500 Received: from mail.kdab.com ([176.9.126.58]:53380 "EHLO mail.kdab.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750796AbeAPOnB (ORCPT ); Tue, 16 Jan 2018 09:43:01 -0500 X-Greylist: delayed 535 seconds by postgrey-1.27 at vger.kernel.org; Tue, 16 Jan 2018 09:43:01 EST From: Milian Wolff To: Cheng Jian Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, xiexiuqi@huawei.com, huawei.libin@huawei.com, wangnan0@huawei.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] perf/trace : Fix repetitious traces of perf on tracepoint Date: Tue, 16 Jan 2018 15:33:58 +0100 Message-ID: <8597218.ZhpRet0H89@milian-kdab2> Organization: KDAB In-Reply-To: <1516106438-4143-1-git-send-email-cj.chengjian@huawei.com> References: <1516106438-4143-1-git-send-email-cj.chengjian@huawei.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart101105823.Xh6oTYfnHe"; micalg="sha256"; protocol="application/pkcs7-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: --nextPart101105823.Xh6oTYfnHe Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" On Tuesday, January 16, 2018 1:40:38 PM CET Cheng Jian wrote: > When i use perf to trace the sched_wakeup_new tracepoint, there is > a bug that output the same event repetitiously. > It can be reproduced by : > > #./test_fork > parent pid : 1059 > child pid : 1060 > #perf record -e sched:sched_wakeup_new -p 1060 > > test_fork is an demo that can generating wakeup_new event, parent > process does nothing but fork a child process, and then they both > quit. > > There are 4 processors in this machine. before this patch, > perf script(perf-1058, parent-1059, child-1060) : > > test_fork 1059 [001] 62.913689: sched:sched_wakeup_new: > comm=test_fork pid=1060 prio=120 target_cpu=002 test_fork 1059 [001] > 62.913698: sched:sched_wakeup_new: comm=test_fork pid=1060 prio=120 > target_cpu=002 test_fork 1059 [001] 62.913705: sched:sched_wakeup_new: > comm=test_fork pid=1060 prio=120 target_cpu=002 > > but ftrace report this event only once : > > test_fork-1059 [002] d... 62.913680: sched_wakeup_new: comm=test_fork > pid=1060 prio=120 target_cpu=002 > > perf script print the same wakeup_new event multiple times. > > These events which trigger this issue all specify a target process. > commit e6dab5ffab59 ("perf/trace: Add ability to set a target task > for events") has designed a method to trace these events. For > example, the sched_wakeup and sched_wakeup_new tracepoint will be > caught when the current task wakeup a target task. > > These events are registered as per cpu most of the time and attached > to the task too, we will get all of them from the perf_event_context > of this task, they will be matched success but are all the same event. > So check the cpu number of this event to avoid matching them multiple > times. > > after this patch, perf script(parent-1040, child-1041): > > test_fork 1040 [002] 36.536079: sched:sched_wakeup_new: comm=test_fork > pid=1041 prio=120 target_cpu=003 > > It will match it only once for tracing task(child-1041). Oh, this sounds awesome. I don't have the setup available to compile a kernel with this patch applied, but I think from the description it solves a long- standing issue with perf's sleep-time profiling. Can someone try this please: https://perf.wiki.kernel.org/index.php/Tutorial#Profiling_sleep_times Use 'sleep 1' as the debuggee. On my system, I get the period multiplied by nproc like you describe: ``` $ perf-sleep-record sleep 1 .. $ perf report --stdio --show-total-period | grep "Event count" .. # Event count (approx.): 8000845488 $ nproc 8 ``` The sleep-record script is available at: https://github.com/milianw/shell-helpers/blob/master/perf-sleep-record I believe your patch also fixes the sched_stat_* tracepoints to be only emitted once per CPU. Can you verify this? I.e. is the period finally correctly calculated and we get a value of roughly 1E9ns == 1s? Thanks -- Milian Wolff | milian.wolff@kdab.com | Senior Software Engineer KDAB (Deutschland) GmbH, a KDAB Group company Tel: +49-30-521325470 KDAB - The Qt, C++ and OpenGL Experts --nextPart101105823.Xh6oTYfnHe Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Trans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