From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752447AbcLHOUV (ORCPT ); Thu, 8 Dec 2016 09:20:21 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34754 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750989AbcLHOUU (ORCPT ); Thu, 8 Dec 2016 09:20:20 -0500 Date: Thu, 8 Dec 2016 23:19:05 +0900 From: Namhyung Kim To: David Ahern Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , Andi Kleen , Minchan Kim Subject: Re: [PATCH 03/10] perf sched timehist: Handle zero sample->tid properly Message-ID: <20161208141905.GA11594@danjae.aot.lge.com> References: <20161206034010.6499-1-namhyung@kernel.org> <20161206034010.6499-4-namhyung@kernel.org> <20161207020629.GB17879@sejong> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20161207020629.GB17879@sejong> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 07, 2016 at 11:06:29AM +0900, Namhyung Kim wrote: > On Mon, Dec 05, 2016 at 07:52:57PM -0800, David Ahern wrote: > > On 12/5/16 7:40 PM, Namhyung Kim wrote: > > > Sometimes samples have tid of 0 but non-0 pid. It ends up having a > > > > Any idea how that happens? > > It seems that an exiting task wakes up its parent and the parent might > call wait(2) concurrently. So at the time of calling last schedule(), > its pid (and tgid) link might be unhashed by the parent and can have 0 > sample->tid and/or sample->pid depending on timing IMHO. Not sure > anything guarantees that the sample tid/pid is preserved during the > event. From a quick look I couldn't find.. I found following line in my data file. $ perf script --time 52460.536907, swapper 0 [000] 52460.536907: sched:sched_switch: pool:3775 [120] x ==> at-spi2-registr:1961 [120] 7f3963 __schedule (/lib/modules/4.8.3-1-ARCH/build/vmlinux) 7f3d7c schedule (/lib/modules/4.8.3-1-ARCH/build/vmlinux) 280b14 do_exit (/lib/modules/4.8.3-1-ARCH/build/vmlinux) 280fa7 [unknown] (/lib/modules/4.8.3-1-ARCH/build/vmlinux) 7f7cf2 entry_SYSCALL_64_fastpath (/lib/modules/4.8.3-1-ARCH/build/vmlinux) ... As you can see task 3775 called schedule() during exit but sample tid was 0. In this case prev_pid is still correct (though it's always pid in the root namespace) since its number was saved in task_struct at the time of creation and not changed. I'll change to check prev_pid for idle task. Thanks, Namhyung