Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1403302lqp; Fri, 22 Mar 2024 13:54:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUdOrnLYyIc92OEH1hsgL0CssDDQZT8Nae47wI8Hjt5qpzlZEeHzHOhZ14PWp07cGv22yFl9qx9sHA45q5CPMs6cDolo85eiHSGbSXPHQ== X-Google-Smtp-Source: AGHT+IFQc8YjcX95XLGBzP2lffaP/KGcrqHaaqs1Ix3eP9RWVvgco28bXlH1bNzqHPo43CQevVfo X-Received: by 2002:a05:6512:20d2:b0:513:d381:65d6 with SMTP id u18-20020a05651220d200b00513d38165d6mr374614lfr.17.1711140868693; Fri, 22 Mar 2024 13:54:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711140868; cv=pass; d=google.com; s=arc-20160816; b=gDm1VZ3iLfmcKI97pBVpAgjvhHYJ8NAyNyQue/GF56162vBA+6dbad0Q7L+zvs+NTr nqVOoG/5Kemugt9GmdzmnVADnpy3aFoauZ8X7yzkWS/nKou9pXFaYT4yXwZK6Eq5NM0A J8w1dEkBWponF3yW+Zzqu+4sm5xprrAOfJafJjJ+H1kPLCPel0XP4m1OmYjOLffRMw5n T225FeLJriOKkIrbLn0WTCnOlXMOTjtGj/wlU4JPuRt6BHM+yIJvkYWYS1sMmpC5R2yD SPMFPSOhvkio4NZTpZLZoKl2SEe/1dLH+EhYvcjyGVGzl2v6B1kZx+Qh5ZgU/JMYgkMl rJUg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=JUvde+vJOWlMCi43uwRr3KT9dfStRwrN3Ih9yU0tQWg=; fh=M5PdMV5KLTjTyQMP6s7BuLWX8ldhL/A5C4zn3g7yIxo=; b=026v+WBLnlEzv5U3o8ghshj8eob5iJdM30o66eTDVa+NRjTmzLOgTWrdRr515p7CCK k5URV6p7bMnLzoRsaiHTlZoNjHn8kHsVYbUxixIHdirR7/rKWEf2heSi9a5GPiCo6QB+ GOwusRsI4f0CK8uWYXk8ubtMTBZ7AzUUdADKlXj28wBYh97zRaNoWWOJrlTYE227aso+ Is/OOxsOO6L7BORi9KGil+B3BGwLLx5Fnp0pdJqh4XRXSAnexLlAZM5H1bAct11dRJPN hqQJIwSgFJVS1lb8kgiTRjWGzje31777Jh8U+4e45qlTFfMblTEUSFqmW0jUVgnftLiH SosA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-112022-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112022-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id j22-20020a1709062a1600b00a46cefa2094si174858eje.311.2024.03.22.13.54.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 13:54:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112022-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-112022-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112022-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6BD7B1F2330D for ; Fri, 22 Mar 2024 20:54:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B812F7FBB1; Fri, 22 Mar 2024 20:54:19 +0000 (UTC) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE95B56B78; Fri, 22 Mar 2024 20:54:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711140859; cv=none; b=RkJfMRHl1w/xA6Ogx4GpfP7aLtRQZRQ0DngbXQNiee9pFXDRaCTjjA8uNisJqoCPsnsvDWWfWukYDi8NHbNpE0jaelSDqM2+mTs2td1EeRJZbS0Sk89K5dQvRsDzmLEIw8jPUZeK7XjQgI0KnOKBNlimBNYLRRaBiz9bYSHEZUA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711140859; c=relaxed/simple; bh=qJ5FgNKO8igPyIl3IbFJ2DLkLzL3Nfy3AtmFj3UX4GQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=uU3gVB/7OWprbiQpHGUqN73xWAECkKULWbnPuXAyLnHeOs6Kbwh9s2mnzOzznaP5GAetF0dlaIkREA9jFVNE6nOBPZoX1qmjaf8oQVd7rrH6+y8RTOo4u/o/fmvdWWWNJ+3vI57ns9JdUNZLAz4XRtrB9X4vKyOibHSxhM23cN8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-29ddfada0d0so1520615a91.3; Fri, 22 Mar 2024 13:54:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711140857; x=1711745657; 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=JUvde+vJOWlMCi43uwRr3KT9dfStRwrN3Ih9yU0tQWg=; b=NA/Kko/KKb+aFSYpsdiSiQ5Zgaap+NWSbOslY5rkqTFV6tUM9iNrf1+1OOOUTdMGTS 1pbilpuUK4fW8krpUrm/eYbyPr7lCF1yAYtP+72f0oN5wZwA2vFo6UGnbtyfbLPuUnvr PJNWN5yVDj7aad0Pl1+L3/Q7OcqspYfO8osTNuyOmsyIAFQwiMPRGMVQChUTuNwjIwMb zoCuwPNOA7ZZdyMPSWlHeXCL1dF3FbxFpIuGy49dpZ508LtxEAU+nJ76nmAEasAFiij3 RCsmxRCZj01//PMZ22wSpgEZ9QkuUyiXa1YMvvNoj/bhMtlJJ4vOaGYX7gxodAMk1MKm 1IPA== X-Forwarded-Encrypted: i=1; AJvYcCUoP9Dj02RAIDN4f9w+bsrTDphvCCazjDyv5UxIefEtK/K7uHCS4eMMDM1UZUmPCneh0crdfF6mTUpfzxyKB8h1f3ThKSIgHIb6dBcHmey+1VKx3pkBNwvyR/LuLbpqWNfZ5AWtfbVcITaxE8qxzzKqk88nMiT2yHq/pg2VoKmCm5mZ4Q== X-Gm-Message-State: AOJu0YzWKIsejpOrYtYEMP6Bcr3JLs3EvLnjwHbpaKrIJ22cqcFdl4XJ PrgdSO+wYrHEd5q9ccECKD95u6FZua/Jq/WT9OwDsJgxqtVdo4+Cgfaplub7Wj8NZXWGH6AvbRH 8XqCHP+aPCb49a4jP3ezS6z6Gou4= X-Received: by 2002:a17:90a:dc02:b0:29f:6a6f:c42 with SMTP id i2-20020a17090adc0200b0029f6a6f0c42mr741135pjv.13.1711140857003; Fri, 22 Mar 2024 13:54:17 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240321160300.1635121-1-irogers@google.com> <20240321160300.1635121-5-irogers@google.com> In-Reply-To: From: Namhyung Kim Date: Fri, 22 Mar 2024 13:54:06 -0700 Message-ID: Subject: Re: [PATCH v2 04/13] perf dsos: Add dsos__for_each_dso To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , James Clark , Athira Rajeev , Colin Ian King , =?UTF-8?Q?Ahelenia_Ziemia=C5=84ska?= , Leo Yan , Song Liu , Miguel Ojeda , Liam Howlett , Ilkka Koskinen , Ben Gainey , K Prateek Nayak , Kan Liang , Yanteng Si , Ravi Bangoria , Sun Haiyong , Changbin Du , Masami Hiramatsu , zhaimingbing , Paran Lee , Li Dong , elfring@users.sourceforge.net, Andi Kleen , Markus Elfring , Chengen Du , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 22, 2024 at 1:43=E2=80=AFPM Namhyung Kim = wrote: > > Hi Ian, > > On Thu, Mar 21, 2024 at 9:03=E2=80=AFAM Ian Rogers w= rote: > > > > To better abstract the dsos internals, add dsos__for_each_dso that > > does a callback on each dso. This also means the read lock can be > > correctly held. > > > > Signed-off-by: Ian Rogers > > --- [SNIP] > > diff --git a/tools/perf/util/dsos.c b/tools/perf/util/dsos.c > > index d269e09005a7..d43f64939b12 100644 > > --- a/tools/perf/util/dsos.c > > +++ b/tools/perf/util/dsos.c > > @@ -433,3 +433,19 @@ struct dso *dsos__find_kernel_dso(struct dsos *dso= s) > > up_read(&dsos->lock); > > return res; > > } > > + > > +int dsos__for_each_dso(struct dsos *dsos, int (*cb)(struct dso *dso, v= oid *data), void *data) > > +{ > > + struct dso *dso; > > + > > + down_read(&dsos->lock); > > + list_for_each_entry(dso, &dsos->head, node) { > > + int err; > > + > > + err =3D cb(dso, data); > > + if (err) > > + return err; > > Please break and return the error to release the lock. Hmm.. I saw this code was replaced by the next patch. Then probably it'd be ok to leave it. Thanks, Namhyung > > > + } > > + up_read(&dsos->lock); > > + return 0; > > +}