Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp2658889rdb; Wed, 6 Sep 2023 10:50:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDYAfEKF3riZwNyC2/ufs394AxPjD24C0q91aqQIh7ZsuVrnilz1jI1AL1kgivuGlJi06R X-Received: by 2002:a05:6a20:9719:b0:135:8a04:9045 with SMTP id hr25-20020a056a20971900b001358a049045mr13553341pzc.1.1694022621537; Wed, 06 Sep 2023 10:50:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694022621; cv=none; d=google.com; s=arc-20160816; b=uv52JSN/mDGwa/FLMv4Qjw4E8e7ADoc1zRTdb1pEh9QYSrl3GZ3TYHzH9fCgGNM0sm QZWnsvKuCH/uik9Mh92kTyCbvw5kYJ1gAM1ya/oyRakAL8ySQTyq0+rCqkQeyHuHn4XI XHynalKXZCBidouoAmfo+g1NxaIWFwmHe/ZSuGlEYFazoEtFVDXuevu3pFJa29CmRPZQ wG95zztIuCwM1gDqtleMRmP1sEHSCag3zesVFNI5SKqP2P0Y7guuUreE2mmI5Di21hJa vnPosni3EM1WwRSxmRlRZ9SkO2ALfhWFSLB9kcYfGIk1iAZKiVf1kj7SIAYrbyr7p97D QZBw== 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=d1wJUll9ioabxkl4x+2FG0kRFuFZjpN4IbncVeRT6e4=; fh=lTfc1vPbz6HhqCgNqJ65khSVBJU/E2WG3eWbAyW2Tnk=; b=QN1U6UsTzc9M6KzzQh+jHq+tpyiKpijWBSipBqDWpPpyXQyONlI3ZfmjrQa8bWNI8X 0Qd9THOKjcfTlvqJbkFTaIwfjtObUr1xOIwFACCbfQLP04aX2v1n8fFLJ1ugbuwJB2Wo KlYz/64xEJ6JU7bNrAyufrIateOBrvZ5lWXoMhMobmQfuvHvXNjpAb7KBCHFT499N6Tf IQvURZo9PKLzUXEuFkGFJH/kd96Twag6sQXbq1U5i6knMMw9HRU6FFQKGox4Pvz9F2f0 77Jzc987opZy3hFqLU3iCNiYs6d98TPtJUyGBTTrDckTXDucjo6Y65f/LcjY4Rlm09os +ZGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WEBkx4RA; 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 q9-20020a056a00088900b0068bea9cb54esi12305728pfj.248.2023.09.06.10.50.06; Wed, 06 Sep 2023 10:50:21 -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=WEBkx4RA; 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 S237590AbjIFQnm (ORCPT + 99 others); Wed, 6 Sep 2023 12:43:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237536AbjIFQnm (ORCPT ); Wed, 6 Sep 2023 12:43:42 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15E651998; Wed, 6 Sep 2023 09:43:39 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C104C433C7; Wed, 6 Sep 2023 16:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694018618; bh=INoTxFTgz1EC0U+ftuMgP49fdpeC/V4RqcR4oqdd0es=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WEBkx4RAkJyL4LqEQegU7rusjMw080VVIc55LQ0pKoAeLPCsFykupQT5k/PP+jVBZ gbK0xLbWWaxUnFeey0QBlpnq93X5eC58nmdCYo08HaJEUqD+6/5+w/KFWOYCqBoHG4 1wRYN8xCNDXJzKZrosJobIaVVsbWDnF1SFGdlKn26HcSxGBgQCm+MlZcW1UCGlt0u1 n+SHe75vkL0cRJNho9gEoZ6AeVCmY3Ad1W4SENYRLBZMbcS4+C3O2Aq/jOwrPS3A3i 7kvXXHo5QjggBOj1EjwdhFjNMs2slofm9BNqD8/DlAz6r5gXTQBdo0nusygMBNdop3 Zyy2B596jbJWA== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 5F355403F4; Wed, 6 Sep 2023 13:43:35 -0300 (-03) Date: Wed, 6 Sep 2023 13:43:35 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Yang Jihong , peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, adrian.hunter@intel.com, kan.liang@linux.intel.com, sandipan.das@amd.com, ravi.bangoria@amd.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [RFC v1 01/16] perf kwork: Fix incorrect and missing free atom in work_push_atom() Message-ID: References: <20230812084917.169338-1-yangjihong1@huawei.com> <20230812084917.169338-2-yangjihong1@huawei.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.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Sun, Sep 03, 2023 at 09:05:06PM -0700, Ian Rogers escreveu: > On Sat, Aug 12, 2023 at 1:52 AM Yang Jihong wrote: > > > > 1. Atoms are managed in page mode and should be released using atom_free() > > instead of free(). > > 2. When the event does not match, the atom needs to free. > > > > Fixes: f98919ec4fcc ("perf kwork: Implement 'report' subcommand") > > Signed-off-by: Yang Jihong > > Reviewed-by: Ian Rogers Thanks, applied locally, will perform some tests and later today probably push publicly, great work! - Arnaldo > > --- > > tools/perf/builtin-kwork.c | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c > > index 14bf7a8429e7..73b5dc099a8a 100644 > > --- a/tools/perf/builtin-kwork.c > > +++ b/tools/perf/builtin-kwork.c > > @@ -406,12 +406,14 @@ static int work_push_atom(struct perf_kwork *kwork, > > > > work = work_findnew(&class->work_root, &key, &kwork->cmp_id); > > if (work == NULL) { > > - free(atom); > > + atom_free(atom); > > Presumably this is fixing a memory-leak. It would be nice if kwork had > perf tests, then our builds with -fsanitize=address would highlight > this kind of issue. Here is a build command I use for this: > make -C tools/perf O=/tmp/perf DEBUG=1 EXTRA_CFLAGS="-O0 -g > -fno-omit-frame-pointer -fsanitize=address" BUILD_BPF_SKEL=1 > NO_LIBTRACEEVENT=1 > > Thanks, > Ian > > > return -1; > > } > > > > - if (!profile_event_match(kwork, work, sample)) > > + if (!profile_event_match(kwork, work, sample)) { > > + atom_free(atom); > > return 0; > > + } > > > > if (dst_type < KWORK_TRACE_MAX) { > > dst_atom = list_last_entry_or_null(&work->atom_list[dst_type], > > -- > > 2.30.GIT > > -- - Arnaldo