Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp535897pxu; Fri, 23 Oct 2020 07:21:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGXzz/eyClluZE3njXMd+KCkHote7uz6l3Y57svwScbtA9NQN+Pvw5A3wjABkGKqN5qER6 X-Received: by 2002:a7b:c309:: with SMTP id k9mr2424113wmj.125.1603462863283; Fri, 23 Oct 2020 07:21:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603462863; cv=none; d=google.com; s=arc-20160816; b=wWRMpmFkjInQk1grG+Fu7h78teaTs20so1Ci9b5SYyA3XeCI0rHrO+NrQNhQ7bJEAF zuhIoGqHvlSPhxMRlAdLsu7+lmXhodD9OeX1x7Bg4RRi4Ft4/elT+qvNH39gSKwQTjFg twVbH/aQ7T0RXf1Podc5bLl7NL6HTQIlS/2gYkJAnJZSsQDNnvcpriJaGXLAQ7xED17M n53sb3balE/EsygkuD/+ai0SGzbOz/fjiRUA9SIlx9LncX6sZx5IPncTRsYmoiZveIQL S4T7MZmmLtt8CZynlm2pJqqLDshaD43YJI6ynjcDrX/MS4CSYi7wQqKxrpiKx2DTPFPl 8Qag== 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=oe3+yIOTAgR0wwkfdH91CMvGJPetlip83+UuJt6zEjk=; b=HYmTccxm2GQehDv0vF0ZoNPqBJySnGHU6wsJCcjbgnUwqguMTTClhAchGGOK6Loy6X FYRis3DtiXWQRBimYhNwGbW+pU0dwoqc0wyu8xlNjgEBPrHwuDr4QVUEyUFHmq+77xNd Cpk7MtUT6/gkCKrtcQ8haO/1QtGUI13V1hirJNRs10RRVZ4sSYXW7kyIW+nd4Y7fzjx6 8tdCMOjgzVSa5pEXlqLnSEWRXUck+XTu55z2JGzDznqy5LIiljCdJx4XBlqO/zL7X3Xe Rpf9UADKi7mtLQDjcw3XJqJ9f9V6/GtZuYPiTnjoFguZFut4dhny5knnTltoNuOs/Rla lfhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=W6KCC99d; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i59si804440edd.308.2020.10.23.07.20.40; Fri, 23 Oct 2020 07:21:03 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=W6KCC99d; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S374742AbgJWCtM (ORCPT + 99 others); Thu, 22 Oct 2020 22:49:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S374715AbgJWCtM (ORCPT ); Thu, 22 Oct 2020 22:49:12 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBB74C0613CE; Thu, 22 Oct 2020 19:49:11 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id x7so106468wrl.3; Thu, 22 Oct 2020 19:49:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oe3+yIOTAgR0wwkfdH91CMvGJPetlip83+UuJt6zEjk=; b=W6KCC99dX0bkA1SF942UIAIRhzAYQXVu2Z2ikv0T1+m2cbwFXuEPdTc/O19BU1uvnh 0w6rBG8HsjblEz3EnSiHNO9z4OshTQ0sVE7ARBxjaNXAK0Yma7ja0wmxd1pYq/80JXnq xgEU2l4HYJU4iuHuEG7hBbZIkxb6ozD8lbUUgJGyXYa3jTfN/ZBH+gWDquhjDj60Zj++ dxpW/wivfV0xBbqIsR4GWxa9qZGkDr+o2Kf3tf7OMtTo3GFTm2Cevl71wiI5hY/K5cpq eG6wPXU3/RJT32nf7eal4wpjr1H4VMcfPC1Lr/W6CMT/MERn9X6JJll8wcVxUpEpe/mp 8Ikg== 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=oe3+yIOTAgR0wwkfdH91CMvGJPetlip83+UuJt6zEjk=; b=EtxEgde894N5KPxfHg2RD4FPDJOsGevkgcEHXrDLJLTy5SOGoAgHwVUCkTWfIvHNCV 5gZhdo1QslDg23sfTtFuy+20a2BIPCrT6rTqDRMlcQcAiHtdXvVDjGvgMs1Utuqjf4mR jUSwJHwUAbPxpXLuhKwgs8XcScZgJ1PZegCvKQPm084d0V3EuCBcqh4uGgiNs9p9oKC/ KAfITWiKuqeWhzR0Y3pT3pEiRh6N5Sq5RTlstuntEzz/2gPr7P0P8AImHAFmC84XlCsj ntRpBBHbjxFEpgvfdpMvItmlpoUwOjQ27FyNRJ/CinUvTQmieqd8CjXu057PM0aQAODM 9TvQ== X-Gm-Message-State: AOAM532c0nN2CVO50TcEVRzGUeMWKcD78EWvUxB0yV3K+LZWXw1JwG05 q7dFXvj7KXyLs52nyPdZTnxwnifb2lrSE8iRAaYAiagI4DQ= X-Received: by 2002:adf:a345:: with SMTP id d5mr178051wrb.55.1603421350396; Thu, 22 Oct 2020 19:49:10 -0700 (PDT) MIME-Version: 1.0 References: <20201009064547.62047-1-sivanichkin@yandex-team.ru> <6A368965-ACB4-47CD-902C-0B910F6BEEE9@yandex-team.ru> In-Reply-To: <6A368965-ACB4-47CD-902C-0B910F6BEEE9@yandex-team.ru> From: Namhyung Kim Date: Fri, 23 Oct 2020 11:48:59 +0900 Message-ID: Subject: Re: [PATCH] perf trace: Segfault when trying to trace events by cgroup To: Stanislav Ivanichkin Cc: linux-kernel , Dmitry Monakhov , linux-perf-users Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Tue, Oct 20, 2020 at 5:48 AM Stanislav Ivanichkin wrote: > > Hi, > > +linux-perf-users@ > > Gentle ping for this patch > > Many Thanks > > -- > Stanislav Ivanichkin > > > On 9 Oct 2020, at 09:45, Stanislav Ivanichkin wrote: > > > > # ./perf trace -e sched:sched_switch -G test -a sleep 1 > > perf: Segmentation fault > > Obtained 11 stack frames. > > ./perf(sighandler_dump_stack+0x43) [0x55cfdc636db3] > > /lib/x86_64-linux-gnu/libc.so.6(+0x3efcf) [0x7fd23eecafcf] > > ./perf(parse_cgroups+0x36) [0x55cfdc673f36] > > ./perf(+0x3186ed) [0x55cfdc70d6ed] > > ./perf(parse_options_subcommand+0x629) [0x55cfdc70e999] > > ./perf(cmd_trace+0x9c2) [0x55cfdc5ad6d2] > > ./perf(+0x1e8ae0) [0x55cfdc5ddae0] > > ./perf(+0x1e8ded) [0x55cfdc5ddded] > > ./perf(main+0x370) [0x55cfdc556f00] > > /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe6) [0x7fd23eeadb96] > > ./perf(_start+0x29) [0x55cfdc557389] > > Segmentation fault > > > > It happens because "struct trace" in option->value is passed to > > parse_cgroups function instead of "struct evlist". > > > > Signed-off-by: Stanislav Ivanichkin > > Reviewed-by: Dmitry Monakhov It seems we should add this too: Fixes: 9ea42ba4411ac ("perf trace: Support setting cgroups as targets") > > --- > > tools/perf/builtin-trace.c | 9 ++++++--- > > 1 file changed, 6 insertions(+), 3 deletions(-) > > > > diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c > > index bea461b6f937..cbc4de6840db 100644 > > --- a/tools/perf/builtin-trace.c > > +++ b/tools/perf/builtin-trace.c > > @@ -4651,9 +4651,12 @@ static int trace__parse_cgroups(const struct option *opt, const char *str, int u > > { > > struct trace *trace = opt->value; > > > > - if (!list_empty(&trace->evlist->core.entries)) > > - return parse_cgroups(opt, str, unset); > > - > > + if (!list_empty(&trace->evlist->core.entries)) { > > + struct option o = OPT_CALLBACK('G', "cgroup", &trace->evlist, > > + "name", "monitor event in cgroup name only", > > + parse_cgroups); Just make it simple and clear what parse_cgroups() expects: struct option o = { .value = &trace->evlist, }; Or else, we can change parse_cgroups() to take evlist directly. But it needs to change other callsites too. Either is fine to me. Thanks Namhyung > > + return parse_cgroups(&o, str, unset); > > + } > > trace->cgroup = evlist__findnew_cgroup(trace->evlist, str); > > > > return 0; > > -- > > 2.17.1 > > >