From: Radu Rendec <rrendec@redhat.com>
To: Pierre Gondois <pierre.gondois@arm.com>, linux-kernel@vger.kernel.org
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Sudeep Holla <sudeep.holla@arm.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 1/2] cacheinfo: Add arch specific early level initializer
Date: Thu, 06 Apr 2023 17:21:48 -0400 [thread overview]
Message-ID: <04a6394d3a80e911d9d1ea3362c96ed5a808e09d.camel@redhat.com> (raw)
In-Reply-To: <10dd6c41-b09b-624c-ba1b-183f4e879ff6@arm.com>
Hello Pierre,
On Thu, 2023-04-06 at 10:17 +0200, Pierre Gondois wrote:
> [start]
> > + unsigned int early_leaves = cache_leaves(cpu);
> > int ret;
> >
> > /* Since early initialization/allocation of the cacheinfo is allowed
> > * via fetch_cache_info() and this also gets called as CPU hotplug
> > * callbacks via cacheinfo_cpu_online, the init/alloc can be skipped
> > * as it will happen only once (the cacheinfo memory is never freed).
> > - * Just populate the cacheinfo.
> > + * Just populate the cacheinfo. However, if the cacheinfo has been
> > + * allocated early through the arch-specific early_cache_level() call,
> > + * there is a chance the info is wrong (this can happen on arm64). In
> > + * that case, call init_cache_level() anyway to give the arch-specific
> > + * code a chance to make things right.
> > */
> > - if (per_cpu_cacheinfo(cpu))
> > + if (per_cpu_cacheinfo(cpu) && !ci_cacheinfo(cpu)->early_arch_info)
> > goto populate_leaves;
> >
> > if (init_cache_level(cpu) || !cache_leaves(cpu))
> > return -ENOENT;
> >
> > + if (cache_leaves(cpu) <= early_leaves)
> > + goto populate_leaves;
> > +
> > + kfree(per_cpu_cacheinfo(cpu))
> >
> > ret = allocate_cache_info(cpu);
> > if (ret)
> > return ret;
> [stop]
>
> Maybe this would be the occasion to put the code between the start/stop in a separate
> function and remove the 'populate_leaves' label. The code seems correct, but it was
> already a bit complex to read before the patch.
Yes, that makes sense. I will address this (and your other comment
about the braces) and post v3 shortly. Thanks for reviewing the patch
and for the feedback!
After I had sent v2, I realized there was something missing from that
code between start/stop. I think we should also set the early_arch_info
flag back to false to prevent another detection/reallocation in case
detect_cache_attributes() is called again (I'm thinking CPU hotplug).
I will address this as well in v3.
Best regards,
Radu
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-04-06 21:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-03 23:15 [PATCH v2 0/2] arch_topology: Pre-allocate cacheinfo from primary CPU Radu Rendec
2023-04-03 23:15 ` [PATCH v2 1/2] cacheinfo: Add arch specific early level initializer Radu Rendec
2023-04-06 8:17 ` Pierre Gondois
2023-04-06 21:21 ` Radu Rendec [this message]
2023-04-03 23:15 ` [PATCH v2 2/2] cacheinfo: Add arm64 early level initializer implementation Radu Rendec
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=04a6394d3a80e911d9d1ea3362c96ed5a808e09d.camel@redhat.com \
--to=rrendec@redhat.com \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pierre.gondois@arm.com \
--cc=sudeep.holla@arm.com \
--cc=will@kernel.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).