From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754107AbaDOJ5h (ORCPT ); Tue, 15 Apr 2014 05:57:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23017 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750938AbaDOJ5f (ORCPT ); Tue, 15 Apr 2014 05:57:35 -0400 Date: Tue, 15 Apr 2014 11:56:58 +0200 From: Jiri Olsa To: David Ahern Cc: linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , Don Zickus , Frederic Weisbecker , Mike Galbraith , Namhyung Kim , Paul Mackerras , Peter Zijlstra , Stephane Eranian Subject: Re: [PATCH 3/5] perf tools: Reference count map_groups objects Message-ID: <20140415095657.GC1700@krava.brq.redhat.com> References: <1397490723-1992-1-git-send-email-jolsa@redhat.com> <1397490723-1992-4-git-send-email-jolsa@redhat.com> <534C193A.2000806@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <534C193A.2000806@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 14, 2014 at 11:22:02AM -0600, David Ahern wrote: > On 4/14/14, 9:52 AM, Jiri Olsa wrote: SNIP > > > >+void map_groups__put(struct map_groups *mg) > >+{ > >+ if (--mg->refcnt == 0) > >+ map_groups__delete(mg); > >+} > >+ > > void map_groups__flush(struct map_groups *mg) > > { > > int type; > >diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h > >index 1073e2d..d6445b2 100644 > >--- a/tools/perf/util/map.h > >+++ b/tools/perf/util/map.h > >@@ -59,11 +59,20 @@ struct map_groups { > > struct rb_root maps[MAP__NR_TYPES]; > > struct list_head removed_maps[MAP__NR_TYPES]; > > struct machine *machine; > >+ int refcnt; > > }; > > > atomic for refcnt? This is part of a libperf; would be good to > support multithreaded users. hum.. I think using atomic type is not enough, we'd need to make map_groups__put/get atomic as well not sure what's the support in user space for that.. will check also not to be negative, but libperf is not thread safe anyway, right? ;-) thanks, jirka