Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3498416yba; Tue, 16 Apr 2019 12:37:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzN0MQqvlPadFotqKHFFC02qEs6hchdcYMBnBgyMXDAaggzPCTmWS9QdfUnV3F2AAEj3vpw X-Received: by 2002:a17:902:8a4:: with SMTP id 33mr85317285pll.7.1555443465686; Tue, 16 Apr 2019 12:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555443465; cv=none; d=google.com; s=arc-20160816; b=YdSNEgMuit15m2fLOah+nrnwWN53a6sSC03sHlSn2hblAw34KE9J/IvSQQmGh0Gqr5 Rz/gSsDskf4w6d9J3l76DaelCNIYFa/UWSFTA21JHR/M4IWgi8Ho2jC89a98L7pNDtY9 sAsaPFk34pv1r1NDxc7KWterd//Hqbn88UpT71roly9sIdSvFSGGUjCOPk1z/vFcTw0Q mO9FKlAXUOCMCx5j1QrAJ1cuN9R6cHOB1iqcxAJ6pIFucyhzke7EQ8lkjYAPpKpmN4eg L8U0uTwJwgYOHzpaF2cKOl10hqBqBEmrM9sd/zgI3dBNeEbCmUPJNWuZG8aIf725lbIW rxlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=mRyeopdXxSK53USmYH1b/Hy8x7B1wPcKegG51sXIj/o=; b=yTYvZimWMOf5MPErhhEvbGvFZbHLYHjPMAtdehKMBiNvgAZp14x0bC1DR/DNNAF8M6 rKLjXgwG6O08WWnhAcOeYOmQnVN4a2Q4VVDw31TriLEXKYal4hnUCZSekrL1k3hEa7mw yrVvKe3enUkmZ34GD6S3yo7XsV2uzL0Sl7E6b32MlZqcPrEPyHsPGu3x7m1LBgwAAwHe kuYwS5sYZNqXQzUK0tLPXjEiY4mM7voAH3Bp8i5YGviODSU5stOU71CmlA9GiUjRU2aG TQ33eOHgziBYsXzaj43hcGAKT5YG4tMau7AP7ZLAlefW2COrfH8NJlOJnUcf5gB45fZL Hq+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cWTlJgAn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si18777212pfr.189.2019.04.16.12.37.29; Tue, 16 Apr 2019 12:37:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cWTlJgAn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729406AbfDPTgv (ORCPT + 99 others); Tue, 16 Apr 2019 15:36:51 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:46094 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbfDPTgu (ORCPT ); Tue, 16 Apr 2019 15:36:50 -0400 Received: by mail-qk1-f194.google.com with SMTP id x18so711275qkf.13 for ; Tue, 16 Apr 2019 12:36:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=mRyeopdXxSK53USmYH1b/Hy8x7B1wPcKegG51sXIj/o=; b=cWTlJgAnXTG40NN/ViJfr2H+2YEoekaq6mdbBumSEs4yDmfTE/nangww0P1dw8Pqe8 OVYm2DgO1E+xAYw/6lYp59KmsRzo2ZB64/YjE2jtIYq8SdV2sEFLHEfsSCR3i7OO8QPS JIetCKLDAT6jPwALOfNudnKOrPCl56uDadhS5KK0cm1bpDNgvY6SCTOBE8nm6fCeHj1F GKiThbwRBCCKnSLjz91jNlkZtRuvZVFtOtsYrX33xPSNc2aaNZ96C8eZdesJk4fE8Rkw 2zkF5DSvogW2Vb8geERwm9NepRNgFscVYOXnumuC/yE1I60fvQ8311FwWHkL3ilDRseL 2sxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=mRyeopdXxSK53USmYH1b/Hy8x7B1wPcKegG51sXIj/o=; b=F4IF7D86ArkveQGGCOjH50z3quNQLVBzje78aXq1s/5zD+b0AcScNqoZ4PRA0zrdwJ o0j26Kd6MxR3E4dQ1oC2P+fC2aasU6LkoLezurSyTMluZTeDCyVPVUIY/mt2rxdTBPTg fGF3BGkvKkiMSp9o5N0cutFHCoaw9odM3BVSeN+4Bj19S71xUTAh8jUJir5UJMkP4vrV tnL4iifiOa5dTPIu3iW41n5AZNP1S4rRn9Q7aUM1TxKB3k4LOKKcscPWjPAI3zDM783E EjQb/K6niFY7UWuIMAhaWk87jebQDGV5O7T1YL/gw4YMetrAxoots/axyr2JIesf+Jee QZMQ== X-Gm-Message-State: APjAAAXFZVRt3AEFjKjfcGZNUcwsaXKRTfpZ/l8r2GV+yiPjFnHl4CRf 2dzoOOgJ3u9Ze883XZTTp4o= X-Received: by 2002:a37:64a:: with SMTP id 71mr61675858qkg.41.1555443409877; Tue, 16 Apr 2019 12:36:49 -0700 (PDT) Received: from quaco.ghostprotocols.net (179-240-182-11.3g.claro.net.br. [179.240.182.11]) by smtp.gmail.com with ESMTPSA id h186sm33447899qke.45.2019.04.16.12.36.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Apr 2019 12:36:48 -0700 (PDT) From: Arnaldo Carvalho de Melo X-Google-Original-From: Arnaldo Carvalho de Melo Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 29C054039C; Tue, 16 Apr 2019 16:36:45 -0300 (-03) Date: Tue, 16 Apr 2019 16:36:45 -0300 To: Jiri Olsa Cc: Song Liu , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Andi Kleen , Adrian Hunter , Alexei Starovoitov , Daniel Borkmann , Eric Saint-Etienne Subject: Re: [PATCH 09/12] perf tools: Fix map reference counting Message-ID: <20190416193645.GD9247@kernel.org> References: <20190416160127.30203-1-jolsa@kernel.org> <20190416160127.30203-10-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190416160127.30203-10-jolsa@kernel.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Apr 16, 2019 at 06:01:24PM +0200, Jiri Olsa escreveu: > By calling maps__insert we assume to get 2 references > on the map, which we relese within maps__remove call. > > However if there's already same map name, we currently > don't bump the reference and can crash, like: > > Program received signal SIGABRT, Aborted. > 0x00007ffff75e60f5 in raise () from /lib64/libc.so.6 > > (gdb) bt > #0 0x00007ffff75e60f5 in raise () from /lib64/libc.so.6 > #1 0x00007ffff75d0895 in abort () from /lib64/libc.so.6 > #2 0x00007ffff75d0769 in __assert_fail_base.cold () from /lib64/libc.so.6 > #3 0x00007ffff75de596 in __assert_fail () from /lib64/libc.so.6 > #4 0x00000000004fc006 in refcount_sub_and_test (i=1, r=0x1224e88) at tools/include/linux/refcount.h:131 > #5 refcount_dec_and_test (r=0x1224e88) at tools/include/linux/refcount.h:148 > #6 map__put (map=0x1224df0) at util/map.c:299 > #7 0x00000000004fdb95 in __maps__remove (map=0x1224df0, maps=0xb17d80) at util/map.c:953 > #8 maps__remove (maps=0xb17d80, map=0x1224df0) at util/map.c:959 > #9 0x00000000004f7d8a in map_groups__remove (map=, mg=) at util/map_groups.h:65 > #10 machine__process_ksymbol_unregister (sample=, event=0x7ffff7279670, machine=) at util/machine.c:728 > #11 machine__process_ksymbol (machine=, event=0x7ffff7279670, sample=) at util/machine.c:741 > #12 0x00000000004fffbb in perf_session__deliver_event (session=0xb11390, event=0x7ffff7279670, tool=0x7fffffffc7b0, file_offset=13936) at util/session.c:1362 > #13 0x00000000005039bb in do_flush (show_progress=false, oe=0xb17e80) at util/ordered-events.c:243 > #14 __ordered_events__flush (oe=0xb17e80, how=OE_FLUSH__ROUND, timestamp=) at util/ordered-events.c:322 > #15 0x00000000005005e4 in perf_session__process_user_event (session=session@entry=0xb11390, event=event@entry=0x7ffff72a4af8, > ... > > Adding the map on the list and getting the reference event > if we find the map with same name. Added: Fixes: 1e6285699b30 ("perf symbols: Fix slowness due to -ffunction-section") Ccing Eric Saint-Etienne , the author of the patch that introduced that function. And applied to perf/urgent > Cc: Song Liu > Link: http://lkml.kernel.org/n/tip-38t1ihcy32lvu4xfpm0p7yex@git.kernel.org > Signed-off-by: Jiri Olsa > --- > tools/perf/util/map.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c > index 28d484ef74ae..ee71efb9db62 100644 > --- a/tools/perf/util/map.c > +++ b/tools/perf/util/map.c > @@ -926,10 +926,8 @@ static void __maps__insert_name(struct maps *maps, struct map *map) > rc = strcmp(m->dso->short_name, map->dso->short_name); > if (rc < 0) > p = &(*p)->rb_left; > - else if (rc > 0) > - p = &(*p)->rb_right; > else > - return; > + p = &(*p)->rb_right; > } > rb_link_node(&map->rb_node_name, parent, p); > rb_insert_color(&map->rb_node_name, &maps->names); > -- > 2.17.2 -- - Arnaldo