linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH 3/4] base/drivers/topology: Move instructions in the error path
Date: Tue, 30 Oct 2018 11:42:09 +0530	[thread overview]
Message-ID: <CAOh2x==N=YM+4WE8wouM9mFd0h0L+npwww97e2HAf2HsEm5J0w@mail.gmail.com> (raw)
In-Reply-To: <1540830201-2947-3-git-send-email-daniel.lezcano@linaro.org>

On Mon, Oct 29, 2018 at 9:56 PM Daniel Lezcano
<daniel.lezcano@linaro.org> wrote:
>
> When the function topology_parse_cpu_capacity() fails, we set the boolean
> cap_parsing_failed to true and we free the raw_capacity. This is correct as
> the function begins with a check against cap_parsing_failed thus protecting
> the function to be re-entered.
>
> However, even it is impossible that can happen with the current code, let's

Why impossible ?

> move in the instructions:
>
>  - cap_parsing_failed = true;
>  - free_raw_capacity();
>
>  ... in the 'else' block when the error is detected, that is more semantically
>  correct.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>  drivers/base/arch_topology.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
> index b19d6d4..7311641 100644
> --- a/drivers/base/arch_topology.c
> +++ b/drivers/base/arch_topology.c
> @@ -155,9 +155,9 @@ bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
>                         pr_err("cpu_capacity: missing %pOF raw capacity\n",
>                                 cpu_node);
>                         pr_err("cpu_capacity: partial information: fallback to 1024 for all CPUs\n");
> +                       cap_parsing_failed = true;
> +                       free_raw_capacity();
>                 }
> -               cap_parsing_failed = true;
> -               free_raw_capacity();

While it is fine to move free_raw_capacity(), it is not to move the
other line. With your
patch what will happen if the first CPU in DT doesn't have the
"capacity-dmips-mhz"
property set ? We will never set cap_parsing_failed and keep on
re-entering this routine
which wasn't required.

Note that the current implementation isn't written to always print an
error where this
property is only partially filled and the same wouldn't happen with
your patch as well.

--
viresh

  reply	other threads:[~2018-10-30  6:12 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-29 16:23 [PATCH 1/4] base/drivers/arch_topology: Remove useless check Daniel Lezcano
2018-10-29 16:23 ` [PATCH 2/4] base/drivers/arch_topology: Replace mutex with READ_ONCE / WRITE_ONCE Daniel Lezcano
2018-10-30  5:57   ` Viresh Kumar
2018-11-23 13:58   ` Sudeep Holla
2018-11-23 16:04     ` Daniel Lezcano
2018-11-23 16:20       ` Sudeep Holla
2018-11-23 16:54         ` Daniel Lezcano
2018-11-26  8:27           ` Juri Lelli
2018-11-26  8:39             ` Daniel Lezcano
2018-11-26 11:33             ` Mark Brown
2018-10-29 16:23 ` [PATCH 3/4] base/drivers/topology: Move instructions in the error path Daniel Lezcano
2018-10-30  6:12   ` Viresh Kumar [this message]
2018-10-30  8:32     ` Daniel Lezcano
2018-10-29 16:23 ` [PATCH 4/4] base/drivers/topology: Default dmpis-mhz if they are not set in DT Daniel Lezcano
2018-10-30  7:13   ` Viresh Kumar
2018-10-30  8:39     ` Daniel Lezcano
2018-10-30  8:45       ` Viresh Kumar
2018-10-30  8:58   ` Viresh Kumar
2018-11-21 22:12     ` Daniel Lezcano
2018-11-22  4:29       ` Viresh Kumar
2018-11-22 10:29         ` Daniel Lezcano
2018-11-22 10:31           ` Viresh Kumar
2018-11-22 10:32             ` Daniel Lezcano
2018-11-22 11:11             ` Daniel Lezcano
2018-10-30  5:50 ` [PATCH 1/4] base/drivers/arch_topology: Remove useless check Viresh Kumar
2018-10-30  7:55   ` Daniel Lezcano
2018-10-30  8:33     ` Viresh Kumar
2018-10-30 13:35       ` Daniel Lezcano
2018-10-31  4:27         ` Viresh Kumar

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='CAOh2x==N=YM+4WE8wouM9mFd0h0L+npwww97e2HAf2HsEm5J0w@mail.gmail.com' \
    --to=viresh.kumar@linaro.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=vincent.guittot@linaro.org \
    /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).