Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp502629rdf; Tue, 21 Nov 2023 08:18:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZc0Dd8+4nMWVu/6WriBan8Z3u6V9BAG6WmjbXeN1lt7HjumPtjLKqjDXhldNlx/yNHFnc X-Received: by 2002:a17:902:7791:b0:1cf:6f62:88e6 with SMTP id o17-20020a170902779100b001cf6f6288e6mr1903197pll.37.1700583496495; Tue, 21 Nov 2023 08:18:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700583496; cv=none; d=google.com; s=arc-20160816; b=cSKeVJxzndAqLcXlL6gtfX6lNmogXb0XqbaFwJvRfRCd6Rp9/Rk9+wLOGh+YVysKcw lz0C6aFO7tK2yCElDZK00QHh2AePdGEZD8tTfs2c/eoxNtgrgIXnZfrEh1bcXTFFemHh 1/Zi4EFH11YGyUzBA9d2we1XJpj1bkVwVp2IxxeJcmM1D35FUVstBDKfKjZbpsmwzV+9 JjiBwQTq0mMmXpF7raHkwRCKRDEWM/wKd1wsAkkKeaejHjbTuhnXBg2LiRAZ6pMli92G +BWYH2SmjHWTKnLpB2iIk49SzNU+FQgYUFO5MtRlAQq14/YwBmHFM/kozW1FayziyzjF y1/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=X7132CXfUB1dIK7Gmp7xy1yfmtHIvsYahpiV3MBz0a0=; fh=oM3c4ktFkzWO+4CGTfNUJbgFzpV36l8F7x4BR+39AQo=; b=Vjz0S6IQfwSKWMV53JjGaNs64IF3CZhWMqYTldD1o7G/cHCpAk0CDYnnM615iYfK42 pTw/V45QU68zDS234iekONdKWLidpfG5mr5DKmDYgN/JMeJBPnDxsD2ePWmpzguKyOEe 28DuO71W1WJ/NdWE/MvsaZFTJy+5Xnqr9E7ucOZrI2OvD8zoH+t51+6dhXqddO5BFaUi LdAIPkKSK69htNe6WEbkylK974qBYKeTrTOD3GwDHAMlfNv7g1nRuz3B55XPtBuNNk4F YRIo0U8zUcmUXOIzYPJVI4nfCnW1XFjzKj+JqXaeVe4Ig5hyA/+bSuir9lGvlNIU6PBv 6MJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="GP/UPil6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id t4-20020a17090340c400b001cc3e45ac2esi7656483pld.19.2023.11.21.08.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 08:18:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="GP/UPil6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E7DD7804A21D; Tue, 21 Nov 2023 08:16:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230202AbjKUQQU (ORCPT + 99 others); Tue, 21 Nov 2023 11:16:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbjKUQQS (ORCPT ); Tue, 21 Nov 2023 11:16:18 -0500 Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AC22194 for ; Tue, 21 Nov 2023 08:16:15 -0800 (PST) Received: by mail-yb1-xb32.google.com with SMTP id 3f1490d57ef6-d9beb865a40so5379676276.1 for ; Tue, 21 Nov 2023 08:16:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700583374; x=1701188174; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=X7132CXfUB1dIK7Gmp7xy1yfmtHIvsYahpiV3MBz0a0=; b=GP/UPil69kydzqFR/hqtFscKDaQbzKReKFtFme1qlG2Yxy+1vPzF6cxPT40968hAn+ Fsa9jfaRM0B7V0mYD1nQljQEW0DXDAgnvdeatlX4az6frMQdM026ofn9PF3GllanBx+o aqX8bTFJ8Qhnrp+37EN1S/XXzjpawnUPb6ldq5c6tU56Ku38wcLmPCWO9Wfyw6boGNTv jju4IOfTwPoeCqgwO39pQFE/HYubslzIHTs6MyZk2BOEIZB7JsCCa6UE60KLyKCl/RvV ALEF6E55HzSHasOBzAjnzehFyHrvjY9RZGH3BuzxvVXMHV4VKZYqfDSaNBsPUyiCEVC/ gPxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700583374; x=1701188174; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=X7132CXfUB1dIK7Gmp7xy1yfmtHIvsYahpiV3MBz0a0=; b=QuNN7g11PaU13YNpq+M+ZgRAevMDO9/7Qd60UCft/msN951JQVBN6QAEBPTMJeRg/4 ztpO7p3f38MpXbpMNUvA6iHyXesMa2xRvbAJq1KomA25mXhtdlR8Yb4ow1aSNIYBzNMB W0RzG3GQqqfLLU/93G6u0XgmJy3epst42BE6xk2A1yKlQXsrb7YyjcmJu+NmpHsnd6uJ UobTlNC81CqhCYzhRr/hN2HxNFDOp8e73oa6MtOGdIqbdFjR6pvpDhSL5tgirwaXH+oA LPrSmkIGbdR04eFPTXQswRddldCLnLHbH98NzgQbtfidVGh/mHQILNOCJkYvmjVEoLsp 2btQ== X-Gm-Message-State: AOJu0Ywh47GoMevP4niJO8OcpwiqQB8zTSN19rqc4RUr8Vuhfyhyiw5E eDYiDO/PvkxBEJfHIyH43qd1oHWaFLV1bw== X-Received: by 2002:a5b:351:0:b0:daf:686c:4919 with SMTP id q17-20020a5b0351000000b00daf686c4919mr10494867ybp.18.1700583374213; Tue, 21 Nov 2023 08:16:14 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:e005:b808:45e:1b60]) by smtp.gmail.com with ESMTPSA id j4-20020a258b84000000b00d9a3fe483cfsm773101ybl.23.2023.11.21.08.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 08:16:13 -0800 (PST) Date: Tue, 21 Nov 2023 08:16:13 -0800 From: Yury Norov To: Will Deacon Cc: linux-kernel@vger.kernel.org, Mark Rutland , linux-arm-kernel@lists.infradead.org, Jan Kara , Mirsad Todorovac , Matthew Wilcox , Rasmus Villemoes , Andy Shevchenko , Maxim Kuvyrkov , Alexey Klimov Subject: Re: [PATCH 07/34] perf/arm: optimize opencoded atomic find_bit() API Message-ID: References: <20231118155105.25678-1-yury.norov@gmail.com> <20231118155105.25678-8-yury.norov@gmail.com> <20231121155344.GB1938@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231121155344.GB1938@willie-the-truck> X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 21 Nov 2023 08:16:30 -0800 (PST) On Tue, Nov 21, 2023 at 03:53:44PM +0000, Will Deacon wrote: > On Sat, Nov 18, 2023 at 07:50:38AM -0800, Yury Norov wrote: > > Switch subsystem to use atomic find_bit() or atomic iterators as > > appropriate. > > > > Signed-off-by: Yury Norov > > --- > > drivers/perf/arm-cci.c | 23 +++++------------------ > > drivers/perf/arm-ccn.c | 10 ++-------- > > drivers/perf/arm_dmc620_pmu.c | 9 ++------- > > drivers/perf/arm_pmuv3.c | 8 ++------ > > 4 files changed, 11 insertions(+), 39 deletions(-) > > > > diff --git a/drivers/perf/arm-cci.c b/drivers/perf/arm-cci.c > > index 61de861eaf91..70fbf9d09d37 100644 > > --- a/drivers/perf/arm-cci.c > > +++ b/drivers/perf/arm-cci.c > > @@ -320,12 +320,8 @@ static int cci400_get_event_idx(struct cci_pmu *cci_pmu, > > return CCI400_PMU_CYCLE_CNTR_IDX; > > } > > > > - for (idx = CCI400_PMU_CNTR0_IDX; idx <= CCI_PMU_CNTR_LAST(cci_pmu); ++idx) > > - if (!test_and_set_bit(idx, hw->used_mask)) > > - return idx; > > - > > - /* No counters available */ > > - return -EAGAIN; > > + idx = find_and_set_bit(hw->used_mask, CCI_PMU_CNTR_LAST(cci_pmu) + 1); > > CCI400_PMU_CNTR0_IDX is defined as 1, so isn't this wrong? You're right. Will fix in v2 > [...] > > > diff --git a/drivers/perf/arm_dmc620_pmu.c b/drivers/perf/arm_dmc620_pmu.c > > index 30cea6859574..e41c84dabc3e 100644 > > --- a/drivers/perf/arm_dmc620_pmu.c > > +++ b/drivers/perf/arm_dmc620_pmu.c > > @@ -303,13 +303,8 @@ static int dmc620_get_event_idx(struct perf_event *event) > > end_idx = DMC620_PMU_MAX_COUNTERS; > > } > > > > - for (idx = start_idx; idx < end_idx; ++idx) { > > - if (!test_and_set_bit(idx, dmc620_pmu->used_mask)) > > - return idx; > > - } > > - > > - /* The counters are all in use. */ > > - return -EAGAIN; > > + idx = find_and_set_next_bit(dmc620_pmu->used_mask, end_idx, start_idx); > > It might just be me, but I'd find this a tonne easier to read if you swapped > the last two arguments around so that the offset came before the limit in > the new function. I personally agree, but we already have find_next_*_bit(addr, nbits, offset) functions, and having atomic versions of the same with different order of arguments will make it even more messy... Thanks, Yury