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 26238C004C0 for ; Mon, 23 Oct 2023 14:14:55 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wB+Cabcg9+8vGWPrrTMOGdmJbLrgKUWX9wWHDnl3HWI=; b=M0D1AKxN/DALB5 P1uIwiMC6Jc9uwWrIkxvtPbBE4dDZZnjgjEnAW4QQYPNABRpmH6Pat6hRdg1T7Hd9NdCB8nSVBPk4 ccXZHXN/Hk8yDC4z5kfjFQ4yYpkwPwvsiqSrIyEvKw5C5XQijUzJErbzY5VHCc2oenORzyevM4oUw ZH/KGFXq2dcApLYJibdnU/u7dTeBvX2cmUUgU7PGhtThf21p11oSAAUdfJhLCCLjUVULA34EwdX+j 7k0j4n/8lxt4IwdEuEXqWDjxZY525xlJjdPQv/cyQb07ahYkwWacsV44JRK5lpPulbo+z+MzdznAf hwIkvNm6xycNNAdae+9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1quvhM-007Wd5-0O; Mon, 23 Oct 2023 14:14:28 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1quvhI-007Wc8-23 for linux-arm-kernel@lists.infradead.org; Mon, 23 Oct 2023 14:14:26 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 96CEF1FB; Mon, 23 Oct 2023 07:14:58 -0700 (PDT) Received: from [10.57.5.125] (unknown [10.57.5.125]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7E2B23F64C; Mon, 23 Oct 2023 07:14:16 -0700 (PDT) Message-ID: <37b9a97e-4142-4f6f-85c9-7d90abb8f334@arm.com> Date: Mon, 23 Oct 2023 15:14:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] perf/arm-cmn: Rework DTC counters (again) To: Mark Rutland , Ilkka Koskinen Cc: will@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, jeremy.linton@arm.com, renyu.zj@linux.alibaba.com References: <5f6ade76b47f033836d7a36c03555da896dfb4a3.1697824215.git.robin.murphy@arm.com> <8e179525-bba-c577-85cf-4aa0a7af436@os.amperecomputing.com> Content-Language: en-GB From: Robin Murphy In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231023_071424_776625_B151872E X-CRM114-Status: GOOD ( 11.43 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2023-10-23 10:06, Mark Rutland wrote: > On Fri, Oct 20, 2023 at 03:50:30PM -0700, Ilkka Koskinen wrote: >> Hi Robin, >> >> I have one comment, otherwise the patch looks good to me. > >>> +/* @i is the DTC number, @idx is the counter index on that DTC */ >>> +#define for_each_hw_dtc_idx(hw, i, idx) \ >>> + for (int i = 0, idx; i < CMN_MAX_DTCS; i++) if ((idx = hw->dtc_idx[i]) >= 0) >> >> Isn't that "idx" unnecessary in the initialization? > > That creates the 'idx' variable that's assigned to by `idx = hw->dtc_idx[i]`, > so that is necessary. Right, the intent is to take advantage of locally-scoped iterator variables since they're a nice thing, but completely-implicit definitions aren't so nice (at best they'd be surprising, at worst they could confusingly shadow existing variables in the outer scope), so the macro invoker still provides their names to at least give some visible context to their use within the loop body. I guess this is still a fairly new paradigm since the C11 switch, and I'm not aware of any "standard" style for such iterator macros yet, so I just did what seemed most logical. Thanks, Robin. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel