From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 75A90C61D85 for ; Tue, 21 Nov 2023 16:16:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KmCtaRYNJfhOASZL5d2G5G5Vh/L8Fr2g4HKG6CubNSQ=; b=CGnzkzEr0pvgIQ GQjui88mwSO7yTRjsjcte3/Ut1naaQt05qilRtcKggkpX0O+qMy4tBoo+WcorWUqCL5fA+SuQ01nr 4qD01u5SYnkBdH5bvVwFOLdRYMKXfWSE9rsC5Y1T6FywxwpoBhhbiAdyW40BADrI1Tx5uzfX8p3SE 6tdgTKwkY3elT/mYj80gYa30hdwHVLOL3SAQAl4kU0c4uhVR9XiAfTJQ8GAlJJnNZEA+R1ArL0At8 4osJrdi1YfUX20NjYg0j88caZ99PbUsVD1MR/dqBPtuXNb9nFSjY3ycRAGy6osWCy+1lft3MNCwp5 W29ti+QwVioulzN5agxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5TQF-00HG2V-2A; Tue, 21 Nov 2023 16:16:23 +0000 Received: from mail-yb1-xb34.google.com ([2607:f8b0:4864:20::b34]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r5TQD-00HG1H-0u for linux-arm-kernel@lists.infradead.org; Tue, 21 Nov 2023 16:16:22 +0000 Received: by mail-yb1-xb34.google.com with SMTP id 3f1490d57ef6-d9caf5cc948so5385094276.0 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=lists.infradead.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=DUeopEqWiIoekIGb1AJYsiRpA1ZYIHcqiYAY3qkSUP8uROG/T+Y32Dp+qQknCk8+1o lELkcf0dju9LE5EMkdSTu+k+mL5axBNkn0C6v35/Zxzox5F3gGFsydKg+GMEoASFJQP+ r8RNM980EyzBDdkM8Q8aNXyIv6Cm6jG5Fe09dVwWdYg9EPOTg07Vnu89/K9z0vqqH510 TorLP6eBnDyznzyNW/XcbQ8HFi4dBnlJ5oagx7C+yPcFA1f6A1Gc9f1qkK/v1fRRiaQf 4HtDLPqViEfrRkaNKoY7JVa8iKYUrevwVJvRz/q9+ok9qVSi4S7ZWSYz3VpcvrHfi3hI X3eg== 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=PKYIvmxm525/lTqtWM4brw4cNQ4CM/0J7R/gCbQHVRwzBIxAwbewkOusw1XzXceB9K 8Oa03kx7lqp0P0cQhmtRCKYRcfxgb5vj12C7WkwubfhMn914KuHXhQFATpatJqBTDC6H 5CnLW9TuoArJW+A/NOtGE0r8uXrJ0KKUcr8cNL1zM9T0OB+p+82T+AZANravulSd8YLq xKIb10hihL4NZhrMwFixUukJiepIGVSY1YGtG1GulACSec3QE10pMthpV0GwNMUkJpzL QgzczMTCfHUkgUUQRgbTrm4TSk5onzKJMleZWMz10AqCr+dpgmu1NhjMM25slDqKuwCE 40Kw== X-Gm-Message-State: AOJu0YxLJihhadETejo/KtHWxYf071LxGM88ssHTnB+2aB/FMPl+mqfv oIMc250Bl5ib/F8lxtWb0yA= X-Google-Smtp-Source: AGHT+IGi9uK16aYMAYQhI90N2Dt00CS1k9ov+suyCQkx5en9XvS7iOSQ5LAGauyh7JBmkqcgxMMsew== 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-Disposition: inline In-Reply-To: <20231121155344.GB1938@willie-the-truck> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231121_081621_318716_9DE20879 X-CRM114-Status: GOOD ( 23.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel