Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4512416rdb; Tue, 12 Dec 2023 01:17:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEiuYEtf6SViDJ/6wVl3cJSkx1DaSNnlQURjESrz1Wf54CxBAOoXzKwQ02SMvEa8l6ibBOk X-Received: by 2002:a17:902:704c:b0:1d0:6ffd:9e23 with SMTP id h12-20020a170902704c00b001d06ffd9e23mr6103460plt.117.1702372642256; Tue, 12 Dec 2023 01:17:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702372642; cv=none; d=google.com; s=arc-20160816; b=JBlriiFBH2B9Ofm5p5rG/GHsDpl9zjndVXk8whdUVdefxrh4dLncWhXIYqAnlrWRRa e2cPoMzdmT3EIt6mve+d7X26ghMPrBO9ef8QWFbBZnPmpRUNarmjuBQzjLSoYu0GeYna L9JTCZU6l4JpZgdO3SXi7QLtBVhT0xA1nL1LMtGH394MV7MD7Bk4txHmtRTJDnDItCkW ZEeWPGnpf7Y70xlTBhF3ClWu5cnRyJqJQ2FD8iEUu6Ho1grzFNrRXogjHZg8KQ0C/8iz 5QlS91z++ybd63LNrZJIq5Qnc8bYxqUEh2skeA1N+kRmGWK41vJ48Wr0/a6WSwoCJ+ck woCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=jCwru107TFOER06Y7i4aZCIUB9a3qwYpW10kpjOT0LI=; fh=miluC9QvaJAGLGP65lEn/jh75yZIH019L3ZV/UtkNJw=; b=zPrfNCdXrLnhhDQrlxiXTG1ZE8Bw5DC8VQwoaa+ONGqB2jpB13ZA6sIU/YqM1eMXTs D0XSj/k/Cc1qXXt7XLy2yswEHRY0klq508GU1EUydylK+rWGzlHSsR2kPaStPL38LGPv V4WFDKyhZIni4S73TBUQh88gZ8cObTr5RIZc6hyGqNjaFC5v/3evCCU2fnRZdeTbVEEj 9FHjYKBUt6A4MSBnePM1lRt+ckoU+/UxSoo8NZssi2yheKrbo+9Kv9KymeFZTzGl1DL3 rlqDGaB7v+3G+FsTojoQPyOAbLuSc/rgqatMMWxPNgd2G6twxx0eB6McSvYR/7l2rWeb 4okw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Tb1exX7m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id d18-20020a170903231200b001d07619e8cdsi7751183plh.449.2023.12.12.01.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 01:17:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Tb1exX7m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 8251A80A7CE1; Tue, 12 Dec 2023 01:17:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235097AbjLLJQ7 (ORCPT + 99 others); Tue, 12 Dec 2023 04:16:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231748AbjLLJQ4 (ORCPT ); Tue, 12 Dec 2023 04:16:56 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D94E5DB for ; Tue, 12 Dec 2023 01:17:02 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A81A3C433C7; Tue, 12 Dec 2023 09:16:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702372620; bh=pAJ3nx5Llui3FrgGOwWJ1sBjH+cYEeTGCkjb+A7qsBQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Tb1exX7maotv6ujLhPqoFP1C0nl8/QWredniP2WIk+8s+CxcMA48E3PBP9bLi/ObO dcMLa0zNrvd4z43yk7j0X8mXbOu0Ep9isOGqzT0r1RwWWbpKX4koNmB/irb0QXhX5H bisSdNZqbFqCtIblE+UuqPoSbQW+Rx/Dwr7wNtlE/5LBQbz/sFd17fFgrH0vl2DH7T ggm+VZ7Mb5w2k88xAhIVbGpY96hLfkjbbjuRGVRtYTewGx3IlzTQVn06u08R/vxD6p pzQkjY0nKIiLdxawLJLu9cUsGKFE9IgwEj8SJLGFb9AeWTpg8JosVm2Vh0wenu0LhZ Bwppx6/sfawrw== Date: Tue, 12 Dec 2023 09:16:54 +0000 From: Will Deacon To: Robin Murphy , catalin.marinas@arm.com Cc: mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, jeremy.linton@arm.com, ilkka@os.amperecomputing.com, renyu.zj@linux.alibaba.com Subject: Re: [PATCH] perf/arm-cmn: Fail DTC counter allocation correctly Message-ID: <20231212091654.GA28174@willie-the-truck> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 morse.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 (morse.vger.email [0.0.0.0]); Tue, 12 Dec 2023 01:17:19 -0800 (PST) On Mon, Dec 11, 2023 at 07:27:28PM +0000, Robin Murphy wrote: > Calling arm_cmn_event_clear() before all DTC indices are allocated is > wrong, and can lead to arm_cmn_event_add() erroneously clearing live > counters from full DTCs where allocation fails. Since the DTC counters > are only updated by arm_cmn_init_counter() after all DTC and DTM > allocations succeed, nothing actually needs cleaning up in this case > anyway, and it should just return directly as it did before. > > Fixes: 7633ec2c262f ("perf/arm-cmn: Rework DTC counters (again)") > Signed-off-by: Robin Murphy > --- > drivers/perf/arm-cmn.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c > index 86d970e74129..c584165b13ba 100644 > --- a/drivers/perf/arm-cmn.c > +++ b/drivers/perf/arm-cmn.c > @@ -1816,7 +1816,7 @@ static int arm_cmn_event_add(struct perf_event *event, int flags) > idx = 0; > while (cmn->dtc[j].counters[idx]) > if (++idx == CMN_DT_NUM_COUNTERS) > - goto free_dtms; > + return -ENOSPC; > } > hw->dtc_idx[j] = idx; > } > -- > 2.39.2.101.g768bb238c484.dirty Acked-by: Will Deacon Catalin -- please can you take this one as a fix? Cheers, Will