Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1362254rdb; Wed, 6 Dec 2023 17:19:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVeW8VRt7PU8n/BrpVMsJQMzI3noj8xjbOpppBywScOkuwv9jn9efNXJ4cY+pg4LxktB+8 X-Received: by 2002:a17:90b:1650:b0:286:d498:1ad with SMTP id il16-20020a17090b165000b00286d49801admr2211632pjb.3.1701911950399; Wed, 06 Dec 2023 17:19:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701911950; cv=none; d=google.com; s=arc-20160816; b=hDcf5R7UXN7nUw8RbmOHNFsvRQjQYDNH6tYmer2DrCi8Q/D5xyUR5OAF0Teqc5slzZ 9s2WjrkPgeYGeP55rMLLP6vs1mLJtOKvcM48aBYTQkFUTjh3hNAbZ/hUblPOP5G71yia htUHrddzixNGbjm5rHKQUw7DaFy0VheZB8DXt87d1qnMEUqQSp+bVCJCcCiKJXHio3zu a+HXfo5UZt0hFe+QXabAj5UVHqJAMQeeWTwOJ993VJS/M4nrNB//5V5A3/G3mOLV6O7w vzhveECUOvoEiYWrp4wd4W5wZGm6LTx5Xvp5bX6NjJsvGgmqKbGuwe6fvVK2qciVQE0A 6Wiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=/sHbkqXu1fUVSCDOGBtyBTb/TcjN5e6RYI3KdCcTGvc=; fh=Io7x3OacpefNRRNKoYAzVE0aWTDwD7FRzyCdD1e3AN4=; b=sXLCiUAWlSTALNuiHZT3SQYPjNkmp+8I98NIGTy7Z5ae84UFl55w0ZfqgZ0b9GEWIV gmsIRsCHpIipLRlXBP6pCmFT9xFDKNuaReUpvMKtD8FDFA9uYtx+IHfnHDFamJRVB8iB L8MuBPx6lxYMQHa1J5VHxXtJ8M5Od4a3lP/CaxupRqwlZsE6z7UyMeEFQnTE4L/TV/SH Tn7Q4sken7dUJYj4PVnGyNgk6H+8aiJPvJOGdJv1FIWajjheg0wkKRgorsVbgMX8UZ/8 +k0U0WIZN36tbGsucDiZqucsuyZ3eOz9WdUfu+JKHAYBN3tr4bdCcLabQ6GK2U0V49uJ 1sTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lPWCAere; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id q2-20020a17090a304200b002864f8382c2si92195pjl.105.2023.12.06.17.19.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 17:19:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lPWCAere; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id C373180D7731; Wed, 6 Dec 2023 17:19:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442951AbjLGBSj (ORCPT + 99 others); Wed, 6 Dec 2023 20:18:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443021AbjLGBSZ (ORCPT ); Wed, 6 Dec 2023 20:18:25 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2133919B7 for ; Wed, 6 Dec 2023 17:18:02 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5d3911218b3so1880597b3.1 for ; Wed, 06 Dec 2023 17:18:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701911875; x=1702516675; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=/sHbkqXu1fUVSCDOGBtyBTb/TcjN5e6RYI3KdCcTGvc=; b=lPWCAere9A/tqQJb4Z5l4LaSTTwqTXgknJXo8BgtDlT7+pjrDMQuOtG9EKofMJkg1t CtpCTbGz+ViPywB2P82f9qcxD0LG+NQD7/OT2Dkbxqv3+GaoRZ59zUuIIWmiC9kRyLjO TJHlWjqI9UhaCg4VbqqPVqc29zm2Fffa7c1+UjKWqm4er5Xm2WioYzMNKph/AA4BfhoW 3vEyzvguY9SWNLsRJxK+3ApHLIvJ09yWKxX0rrpi8MlGj5Lcvx6GkcxDiO27doaJiN39 yCAj3yQgXayfT5jwXN5dlKJLTSYJOELXp2yZlS7nKzsMgivrB2dpfrvI0YXG5fQrMUcY wtJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701911875; x=1702516675; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/sHbkqXu1fUVSCDOGBtyBTb/TcjN5e6RYI3KdCcTGvc=; b=xSA3QZAworlAr3qNWkebCCCF6BV+Ur/zFP33hBELg+XAxZ1paL9aqzIv7XXPzckwcq gecZJvUKp1jzYxNRQm9vpioYrgcp/2no2EoeDVgonIf68NeD5UFLvp3vKS823VlbrWfh Sc+8nsgwydxG4VPs6k4xm90f5qGStULkE0pp9eX67w+N5gaBqqYfaeHqCG+ZB8qhViF5 sVraaZ3XFVwmjUcoqzNuY26ZLYwpSR15hgNuJgKTmFz1EAWWSbXRYYRZN+kxaN/mbHvp U4Tfs/HviPG3nQtflRQ/GmPaV7QBxCz2q1z7OMmn08TtHD4I3eb+Sbg+9WBC7PxoGity zKhg== X-Gm-Message-State: AOJu0Ywk+rxKwf2Yd95WuSGlSBPR/64QvchAaXjhYlSPl/y00ChGZmrz 5FvFneWNRkLR7MHeBY83TDrSTi3rhIBA X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:35bf:293e:7696:34e9]) (user=irogers job=sendgmr) by 2002:a05:690c:2f89:b0:5d4:263e:c819 with SMTP id ew9-20020a05690c2f8900b005d4263ec819mr25058ywb.8.1701911875437; Wed, 06 Dec 2023 17:17:55 -0800 (PST) Date: Wed, 6 Dec 2023 17:16:46 -0800 In-Reply-To: <20231207011722.1220634-1-irogers@google.com> Message-Id: <20231207011722.1220634-13-irogers@google.com> Mime-Version: 1.0 References: <20231207011722.1220634-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog Subject: [PATCH v6 12/47] perf vdso: Use function to add missing maps lock From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , 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" 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 fry.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 (fry.vger.email [0.0.0.0]); Wed, 06 Dec 2023 17:19:03 -0800 (PST) Switch machine__thread_dso_type from loop macro maps__for_each_entry to maps__for_each_map function that takes a callback. The function holds the maps lock, which should be held during iteration. Signed-off-by: Ian Rogers --- tools/perf/util/vdso.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c index ae3eee69b659..df8963796187 100644 --- a/tools/perf/util/vdso.c +++ b/tools/perf/util/vdso.c @@ -140,23 +140,34 @@ static struct dso *__machine__addnew_vdso(struct machine *machine, const char *s return dso; } +struct machine__thread_dso_type_maps_cb_args { + struct machine *machine; + enum dso_type dso_type; +}; + +static int machine__thread_dso_type_maps_cb(struct map *map, void *data) +{ + struct machine__thread_dso_type_maps_cb_args *args = data; + struct dso *dso = map__dso(map); + + if (!dso || dso->long_name[0] != '/') + return 0; + + args->dso_type = dso__type(dso, args->machine); + return (args->dso_type != DSO__TYPE_UNKNOWN) ? 1 : 0; +} + static enum dso_type machine__thread_dso_type(struct machine *machine, struct thread *thread) { - enum dso_type dso_type = DSO__TYPE_UNKNOWN; - struct map_rb_node *rb_node; - - maps__for_each_entry(thread__maps(thread), rb_node) { - struct dso *dso = map__dso(rb_node->map); + struct machine__thread_dso_type_maps_cb_args args = { + .machine = machine, + .dso_type = DSO__TYPE_UNKNOWN, + }; - if (!dso || dso->long_name[0] != '/') - continue; - dso_type = dso__type(dso, machine); - if (dso_type != DSO__TYPE_UNKNOWN) - break; - } + maps__for_each_map(thread__maps(thread), machine__thread_dso_type_maps_cb, &args); - return dso_type; + return args.dso_type; } #if BITS_PER_LONG == 64 -- 2.43.0.rc2.451.g8631bc7472-goog