linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>
Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH v1] memory: tegra20: Add debug statistics
Date: Thu, 18 Mar 2021 19:38:59 +0300	[thread overview]
Message-ID: <c696c57d-7bc3-a089-43a2-c3eec1412895@gmail.com> (raw)
In-Reply-To: <9a634d0f-b12f-8b4d-8807-56182533fc3b@canonical.com>

18.03.2021 19:20, Krzysztof Kozlowski пишет:
> On 18/03/2021 17:18, Dmitry Osipenko wrote:
>> 18.03.2021 18:23, Krzysztof Kozlowski пишет:
>>
>>>> +
>>>> +	/* collect memory controller utilization percent for each client */
>>>> +	for (i = 0; i < mc->soc->num_clients; i += 2) {
>>>> +		client0 = &mc->soc->clients[i];
>>>> +		client1 = &mc->soc->clients[i + 1];
>>>> +
>>>> +		if (i + 1 == mc->soc->num_clients)
>>>> +			client1 = NULL;
>>>> +
>>>> +		tegra20_mc_stat_events(mc, client0, client1,
>>>> +				       MC_STAT_CONTROL_FILTER_PRI_DISABLE,
>>>> +				       MC_STAT_CONTROL_PRI_EVENT_HP,
>>>> +				       MC_STAT_CONTROL_EVENT_QUALIFIED,
>>>> +				       &stats[i + 0].events,
>>>> +				       &stats[i + 1].events);
>>>> +	}
>>>> +
>>>> +	/* collect more info from active clients */
>>>> +	for (i = 0; i < mc->soc->num_clients; i++) {
>>>> +		clientb = mc->soc->num_clients;
>>>> +
>>>> +		for (client0 = NULL; i < mc->soc->num_clients; i++) {
>>>> +			if (stats[i].events) {
>>>> +				client0 = &mc->soc->clients[i];
>>>> +				clienta = i++;
>>>> +				break;
>>>> +			}
>>>> +		}
>>>
>>> Could all clients have 0 events ending with "clienta" being undefined?
>>> "client0" would be non-NULL because of loop before.
>>
>> As per 6.8.5.3 of C99 standard, the declaration of a for-loop "is
>> reached in the order of execution before the first evaluation of the
>> controlling expression".
>>
>> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
>>
>>>> +
>>>> +		for (client1 = NULL; i < mc->soc->num_clients; i++) {
>>>> +			if (stats[i].events) {
>>>> +				client1 = &mc->soc->clients[i];
>>>> +				clientb = i;
>>>> +				break;
>>>> +			}
>>>> +		}
>>>> +
>>>> +		if (!client0 && !client1)
>>>> +			break;
>>
>> this means that both client0 and client1 are set t0 NULL here if all
>> clients have 0 events.
>>
> 
> Yes, you're right. I missed the assignment client0=NULL in the for().

Good, thank you for the review! I'll prepare v2.

      reply	other threads:[~2021-03-18 16:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-18 11:55 [PATCH v1] memory: tegra20: Add debug statistics Dmitry Osipenko
2021-03-18 15:23 ` Krzysztof Kozlowski
2021-03-18 16:18   ` Dmitry Osipenko
2021-03-18 16:20     ` Krzysztof Kozlowski
2021-03-18 16:38       ` Dmitry Osipenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c696c57d-7bc3-a089-43a2-c3eec1412895@gmail.com \
    --to=digetx@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=krzysztof.kozlowski@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).