Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1317630rdb; Wed, 6 Dec 2023 15:29:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IGxUKZRbrlmlAtAAwkvx42uYatp3tE7mHByXhqTIPAG8aYtR+kf61tocpqHZzGwDTmDGzPd X-Received: by 2002:a05:6a20:1605:b0:18f:97c:8259 with SMTP id l5-20020a056a20160500b0018f097c8259mr1786341pzj.99.1701905366409; Wed, 06 Dec 2023 15:29:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701905366; cv=none; d=google.com; s=arc-20160816; b=jghOC0mPrKWyWD4lG3m0VrUukd0+YK2kFZYfYsZv20AMyO/Gvwj9rSYPy+JY8oBH6t 3lRP5P5b91KNiLjcJkBCfGYOzGLiYOZMwkYYy2WtTLqfjF0vVREdmyNn//DEvnpTyWeE AvriNsq9rONN7E2g/BoHc/z4WubEO01nVU7qqZ5gVqA73W3OIhyFM534q2RB+suG+INT AA+UYgdkOM8z4tgtGHWpW+fPCHczdiywr6XQ5mCwK/g4dTClKX98Qi5rmlAWvzl7+Pq2 Vlvjz5MbuOMihGcntpegT/6+flQKw1j3EXdAGbYJBTAOAcrFeCY6/DNbEp7qUtrqoNE2 QhiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=cMyxDYpYdGVS1iOMrG0zbYmZLRYHYZE/F0CfAEDnOOw=; fh=zt+aMtm74o2VDnWd+fyn50LeDgsHvuUMqskurVhx6uc=; b=QBztK1jmHcbFIU/WNcRqssm2n+HVZCtMtmIrXozRQatFFxftMFHfN54lkFDav+M1ds UQ9vyiIVTZcgtgvNu+LPLXaGGn6bxqWhAi1MhbgaLi4Z/LC3Cus2jIUApiAHFsqHEOP0 epLvVcclNAzCOGhaAIm6aHYf/jkSBmHcD/BwFcRuiHADtlAemdTS9vKbSdnf05Td+A+C 8YKAtAo/r0Wo7e33WPh41pppHC+NahYe9+aBuTfgauza+XKRJT7cej5TAAZo0Ntbe4Ob pGagg4waOIJQSEWJY2l5dtF+46RAavKlS6toRrBIkxHXetF1UlTQ9BPCyj2WxSX8JhV6 Lr4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YELjP8tv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id d15-20020a056a00198f00b006cdfe417ca3si106247pfl.283.2023.12.06.15.29.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 15:29:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YELjP8tv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 508B583B008B; Wed, 6 Dec 2023 15:29:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379647AbjLFX3H (ORCPT + 99 others); Wed, 6 Dec 2023 18:29:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229636AbjLFX3G (ORCPT ); Wed, 6 Dec 2023 18:29:06 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22D08B9 for ; Wed, 6 Dec 2023 15:29:12 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-50bf1de91c6so606e87.1 for ; Wed, 06 Dec 2023 15:29:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701905350; x=1702510150; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=cMyxDYpYdGVS1iOMrG0zbYmZLRYHYZE/F0CfAEDnOOw=; b=YELjP8tviiaFZ42uQYTYo2Ul9TjOi6tOFQ8YZUF0z5YUaA9/wbmtl9sBb+kDUKY3Vf XbyofOKWczVx/JkcdBXQSkY6phd/zVHgYUsmipqNSTPDZjUPxNlMSAV3lrAA57Si1j9y 5QWLu1E6ns0d5l64XdUkNohH+VeYrm2dBPUIMLHFQG4Y0joETGNpc/7aijCHH+yqeA7k EJHIl7hkj+sUxyWmfkKQNrV2qqWLydzy13wYbABK8V5jW6++F7SQNlMX7EJpGf5cbc73 Z8oBZZC/3t+cT6gvYjOKUICkGvnom05B2xuwkLGPeHcflW5JshERWh/k/n6TXOXWkPbs lpyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701905350; x=1702510150; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cMyxDYpYdGVS1iOMrG0zbYmZLRYHYZE/F0CfAEDnOOw=; b=bsPxsFs4IOxpDoe7bWvof/qJslx/RsW1JOrE6niVwI5hOPfuJtzLhYUqLXZUvOYdxT s1Mf/KPMnW2w2q5cSDVnS9YzPpoazvnAFFDP/d3RAHB1le0GFtqx2E2OVtKmF20Ithgi F1vpkjbGWDvlP2TgutYo0gyY0VG9mZKdGHYuZtNNCswDgJ4Ac5l0RkRTxvaKwAL/keRb mWySIZIZLPoVOs239n9bUY4ZmDubbicd5vzSLb7XB1KosBbz7EuWKNurxrs7PYpVk8DG 7+wmGNHnMUj2qf2hHYjeiwAVK4nT1QhZbnIfxaUZEQRusbfpo507M/WvanuvQwIJ5yji iw7w== X-Gm-Message-State: AOJu0YzmTnMulg+dMNyVoje5/W+ZLDdMWQJVqmCOF+WmW36rS31g88TE 9fVsCxp5/5DHLuT74a+28EUoKXt5yTCRt0Jga+IS4Q== X-Received: by 2002:a05:6512:534:b0:50b:fc76:42c with SMTP id o20-20020a056512053400b0050bfc76042cmr84976lfc.2.1701905350178; Wed, 06 Dec 2023 15:29:10 -0800 (PST) MIME-Version: 1.0 References: <20231127220902.1315692-1-irogers@google.com> <20231127220902.1315692-17-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Wed, 6 Dec 2023 15:28:58 -0800 Message-ID: Subject: Re: [PATCH v5 16/50] perf maps: Add remove maps function to remove a map based on callback To: Namhyung Kim Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Nick Terrell , Kan Liang , Andi Kleen , Kajol Jain , Athira Rajeev , Huacai Chen , Masami Hiramatsu , Vincent Whitchurch , "Steinar H. Gunderson" , Liam Howlett , Miguel Ojeda , Colin Ian King , Dmitrii Dolgov <9erthalion6@gmail.com>, Yang Jihong , Ming Wang , James Clark , K Prateek Nayak , Sean Christopherson , Leo Yan , Ravi Bangoria , German Gomez , Changbin Du , Paolo Bonzini , Li Dong , Sandipan Das , liuwenyu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Guilherme Amadio Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 06 Dec 2023 15:29:23 -0800 (PST) On Mon, Dec 4, 2023 at 3:50=E2=80=AFPM Namhyung Kim w= rote: > > On Mon, Nov 27, 2023 at 2:10=E2=80=AFPM Ian Rogers w= rote: > > > > Removing maps wasn't being done under the write lock. Similar to > > maps__for_each_map, iterate the entries but in this case remove the > > entry based on the result of the callback. If an entry was removed > > then maps_by_name also needs updating, so add missed flush. > > > > In dso__load_kcore, the test of map to save would always be false with > > REFCNT_CHECKING because of a missing RC_CHK_ACCESS. > > > > Signed-off-by: Ian Rogers > > Acked-by: Namhyung Kim > > A nitpick below, > > > --- > [SNIP] > > diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c > > index 72f03b875478..30da8a405d11 100644 > > --- a/tools/perf/util/symbol.c > > +++ b/tools/perf/util/symbol.c > > @@ -1239,13 +1239,23 @@ static int kcore_mapfn(u64 start, u64 len, u64 = pgoff, void *data) > > return 0; > > } > > > > +static bool remove_old_maps(struct map *map, void *data) > > +{ > > + const struct map *map_to_save =3D data; > > + > > + /* > > + * We need to preserve eBPF maps even if they are covered by kc= ore, > > + * because we need to access eBPF dso for source data. > > + */ > > + return RC_CHK_ACCESS(map) !=3D RC_CHK_ACCESS(map_to_save) && !_= _map__is_bpf_prog(map); > > RC_CHK_EQUAL(map, map_to_save) ? Done in v6. Thanks, Ian > Thanks, > Namhyung > > > > +} > > + > > static int dso__load_kcore(struct dso *dso, struct map *map, > > const char *kallsyms_filename) > > { > > struct maps *kmaps =3D map__kmaps(map); > > struct kcore_mapfn_data md; > > struct map *replacement_map =3D NULL; > > - struct map_rb_node *old_node, *next; > > struct machine *machine; > > bool is_64_bit; > > int err, fd; > > @@ -1292,17 +1302,7 @@ static int dso__load_kcore(struct dso *dso, stru= ct map *map, > > } > > > > /* Remove old maps */ > > - maps__for_each_entry_safe(kmaps, old_node, next) { > > - struct map *old_map =3D old_node->map; > > - > > - /* > > - * We need to preserve eBPF maps even if they are > > - * covered by kcore, because we need to access > > - * eBPF dso for source data. > > - */ > > - if (old_map !=3D map && !__map__is_bpf_prog(old_map)) > > - maps__remove(kmaps, old_map); > > - } > > + maps__remove_maps(kmaps, remove_old_maps, map); > > machine->trampolines_mapped =3D false; > > > > /* Find the kernel map using the '_stext' symbol */ > > -- > > 2.43.0.rc1.413.gea7ed67945-goog > >