Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7744142ybi; Thu, 6 Jun 2019 00:28:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxzv+z0Rr1BFTiL+hScDC/2uUCRiH5xMNEqqYfazCHz3gvCMQjqRUBkpryEz6Q9/yFYCTmY X-Received: by 2002:aa7:8d10:: with SMTP id j16mr37986102pfe.204.1559806100851; Thu, 06 Jun 2019 00:28:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559806100; cv=none; d=google.com; s=arc-20160816; b=MdkNxoM41NxwZKfF1y3J94XwRrqf74z4Y7S2rCG/75GUGreLa+GACdx8qE0SqYmBM4 Jrfgf3DwC7zOGRtk28myPJzlphrcjYvCAEGuKVHHXI9Q1nS1kbeV+jSTJiKboaTk1GZP Sn7PNaMHoqNHvIRkSS0J/E74BE9rRqVsbgyG9Uf9RxT0HcELIXosJP9QU7zyJXFm3/Ig Xg0w3mmuH4WY+u4eIs/WHAG63xpMymn/ww8bNa3S9sQruL2J+CmEMzsuRor7e1CrT2CG ADQc24cLUpSmx2VziU8iXcN2sRtH/KIzsjfl9fVImiAqSmKAbjE2mOGjqHqlSCVcQAxA 9J0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=vcocXSb/l4XJeShGlPLyuZdzPVQE5rJavN05ODtICPo=; b=d+So8wFtHqb74HXQQPs7+GyDLKcJowAsgs8Qfn8tZ5yrVFPQY57tm3Pay3HFSgPfRt H3YuJxwViYZlDqX5Z9iFhloQFhgowg21wChThLVPW0fZB8bJXP8uhNqz1qgh0ra3qp01 6s611xjSzVZ7O5K0rVtWK3m9SHfYbhDujNA5suouO8OiJqfFDU92op4thqhC8EJjcIcq ZVxGgSnYcZu2mnJaSS5+tC8aHuSqaSQtzTuPv1Utskqei8j+1cm64/GYMMfh2M5YAX7a c0iTJNbMhVp35U3viBCerAq+uavn6Ipc0AcUWxfFyFHDUNvqOq8mHi2vIxwoQHgTsh7x gyfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v19si989309plo.413.2019.06.06.00.28.04; Thu, 06 Jun 2019 00:28:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726717AbfFFHZW (ORCPT + 99 others); Thu, 6 Jun 2019 03:25:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41484 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726040AbfFFHZV (ORCPT ); Thu, 6 Jun 2019 03:25:21 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 46381330247; Thu, 6 Jun 2019 07:25:20 +0000 (UTC) Received: from krava (unknown [10.43.17.136]) by smtp.corp.redhat.com (Postfix) with SMTP id 0EA3A579A7; Thu, 6 Jun 2019 07:25:16 +0000 (UTC) Date: Thu, 6 Jun 2019 09:25:16 +0200 From: Jiri Olsa To: ufo19890607 Cc: peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, dsahern@gmail.com, namhyung@kernel.org, milian.wolff@kdab.com, arnaldo.melo@gmail.com, yuzhoujian@didichuxing.com, adrian.hunter@intel.com, wangnan0@huawei.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, acme@redhat.com Subject: Re: [PATCH] perf record: Add support to collect callchains from kernel or user space only. Message-ID: <20190606072516.GA28792@krava> References: <1559222962-22891-1-git-send-email-ufo19890607@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1559222962-22891-1-git-send-email-ufo19890607@gmail.com> User-Agent: Mutt/1.11.4 (2019-03-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 06 Jun 2019 07:25:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 30, 2019 at 02:29:22PM +0100, ufo19890607 wrote: > From: yuzhoujian > > One can just record callchains in the kernel or user space with > this new options. We can use it together with "--all-kernel" options. > This two options is used just like print_stack(sys) or print_ustack(usr) > for systemtap. > > Show below is the usage of this new option combined with "--all-kernel" > options. > 1. Configure all used events to run in kernel space and just > collect kernel callchains. > $ perf record -a -g --all-kernel --kernel-callchains > 2. Configure all used events to run in kernel space and just > collect user callchains. > $ perf record -a -g --all-kernel --user-callchains > > Signed-off-by: yuzhoujian Acked-by: Jiri Olsa thanks, jirka > --- > tools/perf/Documentation/perf-record.txt | 6 ++++++ > tools/perf/builtin-record.c | 4 ++++ > tools/perf/perf.h | 2 ++ > tools/perf/util/evsel.c | 4 ++++ > 4 files changed, 16 insertions(+) > > diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt > index de269430720a..b647eb3db0c6 100644 > --- a/tools/perf/Documentation/perf-record.txt > +++ b/tools/perf/Documentation/perf-record.txt > @@ -490,6 +490,12 @@ Configure all used events to run in kernel space. > --all-user:: > Configure all used events to run in user space. > > +--kernel-callchains:: > +Collect callchains from kernel space. > + > +--user-callchains:: > +Collect callchains from user space. > + > --timestamp-filename > Append timestamp to output file name. > > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > index e2c3a585a61e..dca55997934e 100644 > --- a/tools/perf/builtin-record.c > +++ b/tools/perf/builtin-record.c > @@ -2191,6 +2191,10 @@ static struct option __record_options[] = { > OPT_BOOLEAN_FLAG(0, "all-user", &record.opts.all_user, > "Configure all used events to run in user space.", > PARSE_OPT_EXCLUSIVE), > + OPT_BOOLEAN(0, "kernel-callchains", &record.opts.kernel_callchains, > + "collect kernel callchains"), > + OPT_BOOLEAN(0, "user-callchains", &record.opts.user_callchains, > + "collect user callchains"), > OPT_STRING(0, "clang-path", &llvm_param.clang_path, "clang path", > "clang binary to use for compiling BPF scriptlets"), > OPT_STRING(0, "clang-opt", &llvm_param.clang_opt, "clang options", > diff --git a/tools/perf/perf.h b/tools/perf/perf.h > index d59dee61b64d..711e009381ec 100644 > --- a/tools/perf/perf.h > +++ b/tools/perf/perf.h > @@ -61,6 +61,8 @@ struct record_opts { > bool record_switch_events; > bool all_kernel; > bool all_user; > + bool kernel_callchains; > + bool user_callchains; > bool tail_synthesize; > bool overwrite; > bool ignore_missing_thread; > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > index a6f572a40deb..a606b2833e27 100644 > --- a/tools/perf/util/evsel.c > +++ b/tools/perf/util/evsel.c > @@ -680,6 +680,10 @@ static void __perf_evsel__config_callchain(struct perf_evsel *evsel, > > attr->sample_max_stack = param->max_stack; > > + if (opts->kernel_callchains) > + attr->exclude_callchain_user = 1; > + if (opts->user_callchains) > + attr->exclude_callchain_kernel = 1; > if (param->record_mode == CALLCHAIN_LBR) { > if (!opts->branch_stack) { > if (attr->exclude_user) { > -- > 2.14.1 >