Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754632AbbLJIww (ORCPT ); Thu, 10 Dec 2015 03:52:52 -0500 Received: from mail4.hitachi.co.jp ([133.145.228.5]:46555 "EHLO mail4.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754559AbbLJIwu convert rfc822-to-8bit (ORCPT ); Thu, 10 Dec 2015 03:52:50 -0500 From: =?iso-2022-jp?B?GyRCSj8+PjJtTCYbKEIgLyBISVJBTUFUVRskQiEkGyhCTUFTQU1J?= To: "'Arnaldo Carvalho de Melo'" CC: Peter Zijlstra , Adrian Hunter , "linux-kernel@vger.kernel.org" , "linux-perf-users@vger.kernel.org" , Ingo Molnar , "Namhyung Kim" , Jiri Olsa Subject: RE: [PATCH perf/core 14/22] perf: Fix dso__load_sym to put dso Thread-Topic: [PATCH perf/core 14/22] perf: Fix dso__load_sym to put dso Thread-Index: AQHRMif8EcfXPeDwSk6EbC3w1//0XJ7CHROAgAGB9MA= Date: Thu, 10 Dec 2015 08:52:46 +0000 Message-ID: <50399556C9727B4D88A595C8584AAB375264F788@GSjpTKYDCembx32.service.hitachi.net> References: <20151209021047.10245.8918.stgit@localhost.localdomain> <20151209021118.10245.49869.stgit@localhost.localdomain> <20151209141601.GE15864@kernel.org> In-Reply-To: <20151209141601.GE15864@kernel.org> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.198.219.40] Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1845 Lines: 46 From: Arnaldo Carvalho de Melo [mailto:acme@kernel.org] > >Em Wed, Dec 09, 2015 at 11:11:18AM +0900, Masami Hiramatsu escreveu: >> +++ b/tools/perf/util/symbol-elf.c >> @@ -1045,6 +1045,8 @@ int dso__load_sym(struct dso *dso, struct map *map, >> /* kmaps already got it */ >> map__put(curr_map); >> dsos__add(&map->groups->machine->dsos, curr_dso); >> + /* curr_map and machine->dsos already got it */ >> + dso__put(curr_dso); >> dso__set_loaded(curr_dso, map->type); >> } else >> curr_dso = curr_map->dso; > >Right, to make the code smaller, how about doing it this way, i.e. drop >the reference once we have that curr_dso object with a ref held by >curr_map, if curr_map doesn't get it, then we don't need and will drop >it anyway: But as above code, curr_dso is passed to dsos__add after curr_map is put. Even if the curr_map is hold by kmaps, isn't the kmaps controlled by other pthreads? If no, I'm OK if we move above dsos__add() before map__put() for safety, because curr_dso is held by curr_map at that point. Thank you, > >diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c >index 53f19968bfa2..84d787074152 100644 >--- a/tools/perf/util/symbol-elf.c >+++ b/tools/perf/util/symbol-elf.c >@@ -1026,8 +1026,8 @@ int dso__load_sym(struct dso *dso, struct map *map, > curr_dso->long_name_len = dso->long_name_len; > curr_map = map__new2(start, curr_dso, > map->type); >+ dso__put(curr_dso); > if (curr_map == NULL) { >- dso__put(curr_dso); > goto out_elf_end; > } > if (adjust_kernel_syms) { -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/