From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18352C6FD19 for ; Thu, 16 Mar 2023 10:13:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Z27zb+yjFPGIvjiIC9HdX62H2wgOwir7k9JPwxi530U=; b=1zR9a3A3mJzG9b C2W2Jp8UMR4j/oTG4Yyu8+qMcGg9JaYwUeaRbnm6L1gDyFkPLELdyYZlxnG9x2DacouQCyjvf+unx 5x4nFCjVbjFfncR2Xc4YRhnTkdXfxL1RneU6OOw8c94On0DtpPq0JcI23hf4tOjZEr1lvYxMv965M HyxHRRv0u02r2zJ5itGBsm/bKfqeZFLtZDWF5xQmP6u2Wf7nW6zGIp7tQOnLHzYxwgGZtBzIhLwW+ k3FTPMGthEjWOXc7ZRt1dAE8zETlwsfOTSM0dUjvVeEqlcflMRVGzlsMQx56YUPe6LzzXjbYLNH8o /WkKWb/7NDODDuff7GNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pckba-00Fzd4-3C; Thu, 16 Mar 2023 10:13:07 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pckba-00Fzcd-1c for linux-arm-kernel@bombadil.infradead.org; Thu, 16 Mar 2023 10:13:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=IIkuYbXUVOxcLPJTa42oGskx01XDdh0gEPWtumitOKI=; b=ohWFwl2ikTzn4ij+LEgFUO75XU hrednA3KTVzRfuKv6zNuDRQP57bFptDgd2P1aCTwuTpTDgk6TxCB/FTN1dDMxNIzU9LTKYai6SAtJ /wd5uTcqFxqgfaVf2xAjUVkXh3wnEAyn/izyfod+848F5EavhUied2TkBh8RUs6c7RzVErNbGat/5 xeN6BB2IO0bfacntqI7biuLV2F8JewVoSXlUdkU3n3l670UKesLnTPL5cJG6RZj3w/t51v46fTS4+ VRitabnEAajNY9JwPwggQgVTy24JfAmpj+8qTcCZ0vlVUv8o8qfOd+OWm22PBJ3lVM9N4YQleNrHR W8RT8JHA==; Received: from [187.19.239.165] (helo=quaco.ghostprotocols.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1pckbY-002Pk3-1c; Thu, 16 Mar 2023 10:13:05 +0000 Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 3CDB34049F; Thu, 16 Mar 2023 07:13:02 -0300 (-03) Date: Thu, 16 Mar 2023 07:13:02 -0300 From: Arnaldo Carvalho de Melo To: Leo Yan Cc: Namhyung Kim , Jiri Olsa , Ian Rogers , John Garry , James Clark , Adrian Hunter , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v5 11/16] perf kvm: Use histograms list to replace cached list Message-ID: References: <20230315145112.186603-1-leo.yan@linaro.org> <20230315145112.186603-12-leo.yan@linaro.org> <20230316090418.GA2665235@leoy-yangtze.lan> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230316090418.GA2665235@leoy-yangtze.lan> X-Url: http://acmel.wordpress.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Em Thu, Mar 16, 2023 at 05:04:18PM +0800, Leo Yan escreveu: > On Thu, Mar 16, 2023 at 12:42:53AM -0700, Namhyung Kim wrote: > > [...] > > > > static struct kvm_event *find_create_kvm_event(struct perf_kvm_stat *kvm, > > > struct event_key *key, > > > struct perf_sample *sample) > > > { > > > struct kvm_event *event; > > > - struct list_head *head; > > > + struct hist_entry *he; > > > + struct kvm_info *ki; > > > > > > BUG_ON(key->key == INVALID_KEY); > > > > > > - head = &kvm->kvm_events_cache[kvm_events_hash_fn(key->key)]; > > > - list_for_each_entry(event, head, hash_entry) { > > > - if (event->key.key == key->key && event->key.info == key->info) > > > - return event; > > > + ki = zalloc(sizeof(*ki)); > > > + if (!ki) { > > > + pr_err("Failed to allocate kvm info\n"); > > > + return NULL; > > > } > > > > > > - event = kvm_alloc_init_event(kvm, key, sample); > > > - if (!event) > > > + kvm->events_ops->decode_key(kvm, key, ki->name); > > > + he = hists__add_entry_ops(&kvm_hists.hists, &kvm_ev_entry_ops, > > > + &kvm->al, NULL, NULL, NULL, ki, sample, true); > > > > The hists__add_entry{,_ops} can return either a new entry > > or an existing one. I think it'd leak the 'ki' when it returns > > the existing one. You may deep-copy it in hist_entry__init() > > and always free the 'ki' here. > > Thanks for pointing out this, Namhyung. I will fix it. > > @Arnaldo, do you want me to send an appending patch, or will you drop > this patch series from your branch so I send a new patch set? > > > Another thought on this. Lots of fields in the hist_entry are > > not used for kvm. We might split the hist_entry somehow > > so that we can use unnecessary parts only. But that could > > be a future project. :) > > Yeah, I found now hist_entry contains many fields > (branch_info/mem_info/kvm_info/block_info); we can consider to > refactor the struct hist_entry to use an abstract pointer to refer > tool's specific data, this could be easily extend hist_entry to > support more tools. Since I build tested this already and had the other fixes, I'm pushing this out to perf-tools-next (and perf/core for a while, for people not knowing about the new nbranch names) and you can continue from there, ok? - Arnaldo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel