Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2843285pxv; Sun, 27 Jun 2021 10:31:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsegxlzlrRoxNIKvzZyzBSCckCHPjRKfmEjqfHNkSsTen2lM0A5FxYNG3aYqzIsvRRoBUk X-Received: by 2002:a05:6402:30a8:: with SMTP id df8mr28012495edb.7.1624815076904; Sun, 27 Jun 2021 10:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624815076; cv=none; d=google.com; s=arc-20160816; b=UPkSF3/acEHYMXa8x9lM0hMuUEdHMi+5cGUfHVdOeqMAhEhsD67pRCvMk1OZkBa67L 96sJv4Wa9U9JHBfMC0cc2cN2lT6/Yv7a8yWydThXvBWUHcSETc5tp7jsIDeGB0cmWFrn BHPci8X+XiVHhJM1iOWc93rPFNuAcL6sx6529XGUeOU2rOoD1+0I0W1JHHJcrWTqjKFA m/10tljEItyskIzPnmDzU6SKKybgmSlYz3zUvCZJUkJombkUeU1mpwEuEkT4VxxhZXnZ u30Oi/VgWaa+3ZvhoMM3N2AmKs/KOKdCOMV1fxklmqaB2ho1xRYySYaFqfConb1PFmwL jwww== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6yKxLMKBG+NPE2J5wfdFrFJq5rwPKVdeNp6vqQqN9Cs=; b=NWfL0+kSjrik9e1e86OSYgK+BQCNfrI0TrPICVJ2JsqaKFf5Y6TtYOonYWIx9d8H1x GVKb8WIN/OWV5089iHtXv2Jri4BxJVfkEAKDlFfHAzflsJkFCMEEVmyvbOmRZXLR5S8P v28eaBM66c1uv7CyX94/PfeqFS+5x5H3j4kw83PlXXt1a0G+oCQax1eRhkrM3qvGMcVb fCwmnrmjxG4OZhozq0jHcUicytZEakuL8ez6o3WztWh2eJxcEgCXTcnvrfeNxvz1cT5W JzawzlNrw+aWGamRhw8MoQ8zubR8QFpKeZ5G0u/cVaWvUOmvDrB8CjOgta2Gn+zSLCbM tsBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IpgKLvLu; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d7si11005933ejo.175.2021.06.27.10.30.51; Sun, 27 Jun 2021 10:31:16 -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=@redhat.com header.s=mimecast20190719 header.b=IpgKLvLu; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231375AbhF0Rb7 (ORCPT + 99 others); Sun, 27 Jun 2021 13:31:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43210 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230321AbhF0Rb6 (ORCPT ); Sun, 27 Jun 2021 13:31:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624814973; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6yKxLMKBG+NPE2J5wfdFrFJq5rwPKVdeNp6vqQqN9Cs=; b=IpgKLvLuAr4N1J0RGg0+a1fXFQCkrMCimDTVDe06ScqLtYy/wHMWosgTkYBqafuBIanX0G tCx4HDahBVBvoPLwQZhMnes8mDVfX/ZwIrTtHjjVbINnfO4nme4ClRNjkyiMIT/TudeAgb fLjmlDFrgCOK1BOvqhX0YExVM+dSNjI= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-379-cgj-LZ2fMsGciwjPwjzHwg-1; Sun, 27 Jun 2021 13:29:31 -0400 X-MC-Unique: cgj-LZ2fMsGciwjPwjzHwg-1 Received: by mail-ed1-f69.google.com with SMTP id r6-20020a05640216c6b0290394ed90b605so7969921edx.20 for ; Sun, 27 Jun 2021 10:29:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6yKxLMKBG+NPE2J5wfdFrFJq5rwPKVdeNp6vqQqN9Cs=; b=j/wwrqWGbysKJIuPJCvtXfVUU67HWeJFQozsQMd+KNOmojuXLb2HON61cQH2481557 HKP3Y9pQSZ9R6CA135CDcW+v/YIfobK4MKFXWnLU29qYLbL8YlBaAweBVEXdgPKcaBDQ InxtmEzuoZJep9Jha4z0ONWwaFcRX7Y2gDr1wc8lTqpyix69nZyhYLL8QCJHKA4hrzu2 NZKFR7JxspeKTChbWoUURnpM95lQYwAT4E6635cpFTlRw9s7klQI4ubimIJ34XBuw0Vw H9+CjNC3WJFicmddkAiXUIL4ktw9917odMUddBl+vyvlLOqGWY8mZlhJGgTbO+ENHU2L d4yw== X-Gm-Message-State: AOAM531qZP0NMB++9XVPxD8oOimKIP5Ro4GGj4lL69ALTVZRPobgZpwQ T3J4/Mw3eRiiyH//dQ04/yI2baqY9vV0AKDUkk4P387B9EDa+eY6s9aGHpgr3+ezitPpFPUhPNs tv1dCS9ycpKVssgu69ZSeO1sl X-Received: by 2002:a17:907:9841:: with SMTP id jj1mr20621575ejc.94.1624814970496; Sun, 27 Jun 2021 10:29:30 -0700 (PDT) X-Received: by 2002:a17:907:9841:: with SMTP id jj1mr20621568ejc.94.1624814970373; Sun, 27 Jun 2021 10:29:30 -0700 (PDT) Received: from krava ([5.171.209.125]) by smtp.gmail.com with ESMTPSA id f5sm5703703ejj.45.2021.06.27.10.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jun 2021 10:29:29 -0700 (PDT) Date: Sun, 27 Jun 2021 19:29:26 +0200 From: Jiri Olsa To: Riccardo Mancini Cc: Ian Rogers , Arnaldo Carvalho de Melo , Namhyung Kim , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Adrian Hunter , Kan Liang , Leo Yan , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] perf session: add missing evlist__delete when deleting a session Message-ID: References: <20210624231926.212208-1-rickyman7@gmail.com> <4725ef2249540b6876daea3714a38a6be59223e6.camel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4725ef2249540b6876daea3714a38a6be59223e6.camel@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 25, 2021 at 05:45:59PM +0200, Riccardo Mancini wrote: > Hi, > > thank you both for your comments. > > On Fri, 2021-06-25 at 13:54 +0200, Jiri Olsa wrote: > > On Thu, Jun 24, 2021 at 10:39:34PM -0700, Ian Rogers wrote: > > > On Thu, Jun 24, 2021 at 4:20 PM Riccardo Mancini > > > wrote: > > > > > > > > ASan reports a memory leak caused by evlist not being deleted on exit in > > > > perf-report, perf-script and perf-data. > > > > The problem is caused by evlist->session not being deleted, which is > > > > allocated in perf_session__read_header, called in perf_session__new if > > > > perf_data is in read mode. > > > > In case of write mode, the session->evlist is filled by the caller. > > > > This patch solves the problem by calling evlist__delete in > > > > perf_session__delete if perf_data is in read mode. > > > > ugh, I'm surprised we did not free that.. and can't find > > in git log we ever did ;-) I briefly check commands using > > sessions and looks like it's correct > > > > Acked-by: Jiri Olsa > > > > > > > > Acked-by: Ian Rogers > > > > > > It is messy that in read mode the session owns the evlist, but > > > otherwise not. Imo, it'd be nice to make the ownership unconditional. > > > > yep, would be nice > > I think the root problem is that perf_session__new has different behaviours > depending on perf_data and perf_tool and that it probably does too many things > for a __new function. > If we split it into multiple functions and then, say, we create two helpers > perf_session__init_read and perf_session__init_write, with the corresponding > perf_session__fini_read and perf_session__fini_write, then the conditional > ownership won't be a big problem due to having these two cases clearly > separated. > What do you think? yes, interesting idea, let's see how the code looks like ;-) thanks, jirka