From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756192AbbFOV27 (ORCPT ); Mon, 15 Jun 2015 17:28:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45879 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751809AbbFOV2u (ORCPT ); Mon, 15 Jun 2015 17:28:50 -0400 Date: Mon, 15 Jun 2015 23:28:41 +0200 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , lkml , Adrian Hunter , Andi Kleen , David Ahern , Ingo Molnar , Namhyung Kim , Peter Zijlstra , Stephane Eranian Subject: Re: [PATCH 07/30] perf tools: Add reference counting for thread_map object Message-ID: <20150615212841.GA6458@krava.redhat.com> References: <1434269985-521-1-git-send-email-jolsa@kernel.org> <1434269985-521-8-git-send-email-jolsa@kernel.org> <20150615192544.GF5845@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150615192544.GF5845@kernel.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 15, 2015 at 04:25:44PM -0300, Arnaldo Carvalho de Melo wrote: > Em Sun, Jun 14, 2015 at 10:19:22AM +0200, Jiri Olsa escreveu: > > Adding refference counting for thread_map object, so > > it could be easily shared among other objects. > > > > Using thread_map__put instead thread_map__delete and making > > thread_map__delete static. > > > > > +struct thread_map *thread_map__get(struct thread_map *map) > > +{ > > + atomic_inc(&map->refcnt); > > + return map; > > +} > > + > > +void thread_map__put(struct thread_map *map) > > +{ > > + if (map && atomic_dec_and_test(&map->refcnt)) > > + thread_map__delete(map); > > } > > See comment on the other struct being refcounted, get/put should > both accept NULL maps, to avoid having to check it in the users, > just like with free(). ook, will repost with the get function fix thanks, jirka