Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1253708rda; Mon, 23 Oct 2023 07:14:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgl3FTiY7EJfdo4uHRIXnj5i5b+MU6EMYNnADqP22yMzt7/oGhw7zHiqvDJaTchpeMjFWH X-Received: by 2002:a17:902:f546:b0:1bd:d141:f02d with SMTP id h6-20020a170902f54600b001bdd141f02dmr6201557plf.68.1698070470430; Mon, 23 Oct 2023 07:14:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698070470; cv=none; d=google.com; s=arc-20160816; b=MZ+igZ0CVTayxjG3MHYiCfSWp9yUFvELXBIqquGYvyAaHpj2yOIucTVWdCzsyJUnP4 PzH9RaRTvlMhktWVTXo/aDBMWVLuDi42BletU5B2TjoHeJOO1C22mXSsfq/+pOk03p/+ Sqm++KLHE5gK/1CuB/5UqldTzksBEa7tGZQyqctx5xZ0/2JLo1PkpHqrC9U5lKfWpov9 tXDyIUdDxh1FMvJOevKqtKv4SK3Tp6Id//cHxydJGuiaAGA//2BiZUJKJdMACZPcycAN 0iMAjR9dRxJWgx5C7JAbihKhMnIENH4Dd/vq1n+fMBZuabpBkQgXADSJlMHzufsMBxqx MJ3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=LuVdZGjPNgfm+9V5yev0Y/ZIVC2bYYOfZw4GXuHsWx4=; fh=YRVrtD/LmBd1XSJqb2q6jEMCal+MSVcSdl50PSPhs1Q=; b=cttCiNZU7DgyyP7+/2WHGTH0snKcuC2LCwOjZkMvjiN9/9CIDgxOAQLck6ChUPcQUn 2mdx3dS35wUnzJxzCBjlC20//BnWRQtqXltqI1I0jil87F3oXluMDjtrlOHwWj9CEbRU rwnJ755jGlNLZJErEuBZeXrz/cN7AXTB9YkNV1S1m33ccl3y/HpdfzTkpVpxVAJS0aV1 2SnhcXlA8F+4j7Kr7/FQakHfbFC23F4DR5L+gwCftiAfYU83UHPTB3dN/IMZkn8/IMXM Bq1NOdLx4whhohxY+qADGiWQSEtx1KtlcoTJNj6EhQoW+/GdT+f4ODaS5I9FFbg2Lvgd lUDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id x17-20020a170902ec9100b001c61a27f5b6si6679098plg.400.2023.10.23.07.14.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 07:14:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 703A48085F9B; Mon, 23 Oct 2023 07:14:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229807AbjJWOOV (ORCPT + 99 others); Mon, 23 Oct 2023 10:14:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbjJWOOU (ORCPT ); Mon, 23 Oct 2023 10:14:20 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C87D6DF for ; Mon, 23 Oct 2023 07:14:17 -0700 (PDT) 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: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Mon, 23 Oct 2023 07:14:27 -0700 (PDT) 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.