Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4826552rwl; Mon, 10 Apr 2023 18:06:24 -0700 (PDT) X-Google-Smtp-Source: AKy350ZNdKZEPicberPFFPDntGnnXy2JOlAaIrqAV1hyJSBO4dXTrsEKPM0KFdgxoKTC4AmURBiB X-Received: by 2002:a17:906:5293:b0:94a:4847:1d73 with SMTP id c19-20020a170906529300b0094a48471d73mr756936ejm.57.1681175184300; Mon, 10 Apr 2023 18:06:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681175184; cv=none; d=google.com; s=arc-20160816; b=T6KA6M+zVpBQOP463lLpOKgC/bnoDV6ZVdRhNNmJIkqyDemDNvVDD39tZZDD9tBfMB x+5WdpUkp4DS6Q7Zmtu/6z5ehe3+C5XyksAVBJYQJWCLO75swYVeBbGVs5lEiLeyoLIp A2qx1L3MZSeAv/uCQrL6EN1NG1UCaTg9Et5a6APyZ7LUje2qZtxFaRpECEpIgYBXGY8A E4sBEuY+ma2/J1DRDj9F2KjXTMgAL0xhtb9BQ0n1ql4AVPU64AEpLizo/6gab1CGNu0i I1rAbTPR94WCjGnBs5HhQ3I3nEgCz8Gx4BRKGtfJDArSS8wazo18EqiWPgDya+XlfvCq oKxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=JcmEg4Vg1NWXmIaGaXpUcSo6TLTnJgcsRmhRnDmRy64=; b=lREvi8NQ4pWbQBIeCFniDgeX2ChusTRnbv+GcPhAvmW7ocJrgen5zzUL3L9y55hhA5 Jqe+F58UAmR2BGVJJrkiNUUPYC/fGzPm069EX6jTQvfBDvkINpRAWMS/Rawu/BhLCWGT plBafDzBJJou7GhEqD1Za1j5o/EXr6WXDjn8cIhLnqc8W6gzhTTOGGCL0KoxtctkN7/8 ERJ1HCQDC7YD94NqqxRelAupG7hCWiSla8rEjZcGI26ESWQQM/KHl6UGigUAZV6XVmlC 8C3yDZI4BjJFAfim/9HGo8Yr7aN2N2rspeSvxLrn1ip+z/kFZTnRsJ0wjOuhUL3PxDKY iZLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TzyxS4Vi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c25-20020aa7d619000000b00504b2a6ace0si1810455edr.335.2023.04.10.18.05.59; Mon, 10 Apr 2023 18:06:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TzyxS4Vi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229833AbjDKBCf (ORCPT + 99 others); Mon, 10 Apr 2023 21:02:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbjDKBCd (ORCPT ); Mon, 10 Apr 2023 21:02:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A39F5272A; Mon, 10 Apr 2023 18:02:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 30CA66160D; Tue, 11 Apr 2023 01:02:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09BD5C433D2; Tue, 11 Apr 2023 01:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681174948; bh=09CCZjy87xxOe0DkfHZpMCRVWG3qG7BLPcmM01KF3pM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TzyxS4VixjI9lOtPrfkEoO3fajNs9bsmroJxpuSjXsga5CB9YSzF5K3lxz/mb4Ig3 DsB4rCR1LYHDax46EaDukpgWsUNb9WSgCaBpDm1z3nXu5FekVBGniP8vn402S2Id3K KsMPytgESLrO66OHVwiIcjmT67AkS0HjaDlGskMAVQy3GjB+ik0fD0FH4he02oVRdM fgZ+vXw5U7BukpGJCVriR0ThDMpfYl3ojpHVdp6sMrdELUmuMdoMdCYrgZZ6DFgJSI 6716nhnhdPPQDD+yk+qWQdGPigTiAgKTFvKN3Ff6tMD6rIUl1/OWxz/EAgZF/gHUm6 TjhWRoZye+6ww== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id B49BE40080; Mon, 10 Apr 2023 22:02:25 -0300 (-03) Date: Mon, 10 Apr 2023 22:02:25 -0300 From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Florian Fischer , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] perf evsel: Avoid segv if delete is called on NULL Message-ID: References: <20230410205659.3131608-1-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, Apr 10, 2023 at 04:20:57PM -0700, Namhyung Kim escreveu: > Hi Ian, > > On Mon, Apr 10, 2023 at 1:57 PM Ian Rogers wrote: > > > > Seen in "perf stat --bpf-counters --for-each-cgroup test" running in a > > container: > > > > libbpf: Failed to bump RLIMIT_MEMLOCK (err = -1), you might need to do it explicitly! > > libbpf: Error in bpf_object__probe_loading():Operation not permitted(1). Couldn't load trivial BPF program. Make sure your kernel supports BPF (CONFIG_BPF_SYSCALL=y) and/or that RLIMIT_MEMLOCK is set to big enough value. > > libbpf: failed to load object 'bperf_cgroup_bpf' > > libbpf: failed to load BPF skeleton 'bperf_cgroup_bpf': -1 > > Failed to load cgroup skeleton > > > > #0 0x55f28a650981 in list_empty tools/include/linux/list.h:189 > > #1 0x55f28a6593b4 in evsel__exit util/evsel.c:1518 > > #2 0x55f28a6596af in evsel__delete util/evsel.c:1544 > > #3 0x55f28a89d166 in bperf_cgrp__destroy util/bpf_counter_cgroup.c:283 > > #4 0x55f28a899e9a in bpf_counter__destroy util/bpf_counter.c:816 > > #5 0x55f28a659455 in evsel__exit util/evsel.c:1520 > > #6 0x55f28a6596af in evsel__delete util/evsel.c:1544 > > #7 0x55f28a640d4d in evlist__purge util/evlist.c:148 > > #8 0x55f28a640ea6 in evlist__delete util/evlist.c:169 > > #9 0x55f28a4efbf2 in cmd_stat tools/perf/builtin-stat.c:2598 > > #10 0x55f28a6050c2 in run_builtin tools/perf/perf.c:330 > > #11 0x55f28a605633 in handle_internal_command tools/perf/perf.c:384 > > #12 0x55f28a6059fb in run_argv tools/perf/perf.c:428 > > #13 0x55f28a6061d3 in main tools/perf/perf.c:562 > > > > Signed-off-by: Ian Rogers > > Acked-by: Namhyung Kim Thanks, applied. - Arnaldo > In addition to this, I think bperf code should clear the evsel->bpf_skel > at the end of the bpf_counter__destroy() to avoid confusion with the > bpf_filter as they share the fields in a union. > > Thanks, > Namhyung > > > > --- > > tools/perf/util/evsel.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > > index dc3faf005c3b..fe3ce765a4f3 100644 > > --- a/tools/perf/util/evsel.c > > +++ b/tools/perf/util/evsel.c > > @@ -1541,6 +1541,9 @@ void evsel__exit(struct evsel *evsel) > > > > void evsel__delete(struct evsel *evsel) > > { > > + if (!evsel) > > + return; > > + > > evsel__exit(evsel); > > free(evsel); > > } > > -- > > 2.40.0.577.gac1e443424-goog > > -- - Arnaldo