Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Radu Rendec <rrendec@redhat.com>
To: Pierre Gondois <pierre.gondois@arm.com>,
	 linux-arm-kernel@lists.infradead.org
Cc: Sudeep Holla <sudeep.holla@arm.com>,
	Adrien Thierry <athierry@redhat.com>,
	 Eric Chanudet <echanude@redhat.com>
Subject: Re: [RFC PATCH] arch_topology: Pre-allocate cacheinfo from primary CPU
Date: Mon, 27 Mar 2023 10:23:16 -0400	[thread overview]
Message-ID: <b859807a8cda770521aa47cc347865b0e7945c50.camel@redhat.com> (raw)
In-Reply-To: <a9985707-0367-3d6b-6a0e-2b471653dc08@arm.com>

On Mon, 2023-03-27 at 14:02 +0200, Pierre Gondois wrote:
> About populating the cache info from the CLIDR_EL1 register, it seems
> the information might be incorrect for DT based system, and the mask
> of L1 data/instruction caches could be advertised as private for
> ACPI/DT based systems when no cache information is available.
> There is a patch-set that should fix this at:
> https://lore.kernel.org/all/20230327115953.788244-1-pierre.gondois@arm.com/

Hello Pierre,

Thanks for pointing out this issue and creating a patch-set to fix it.
I will keep an eye on it. This is definitely important, since we are
planing to rely on the CLIDR_EL1 based detection.

> On 3/23/23 23:42, Radu Rendec wrote:
> > This patch attempts to enable automatic detection for RT kernels when no
> > DT/ACPI cache information is available, by pre-allocating cacheinfo
> > memory on the primary CPU. The allocated memory size depends on the
> > number of cache leaves, which at that point is unknown without the
> > DT/ACPI information. What this patch does is guess the number of cache
> > leaves and pre-allocate memory on the primary CPU, then go back and
> > reallocate the memory if the guess turns out to be wrong when automatic
> > detection eventually runs on the secondary CPU. In that case, it will
> > basically revert to the original behavior and still trigger a splat on
> > RT kernels. The assumption is that most systems have identical CPUs, so
> > the number of cache leaves will be the same on the secondary CPUs as the
> > primary CPU. The "guess" uses the number of leaves of the primary CPU.
> 
> Would it work to do the pre-allocation in fetch_cache_info() instead of
> returning '-ENOENT' ? This would allow to not add a new step in
> smp_prepare_cpus() and let all the logic in cacheinfo.c

That was my initial intention, and I agree it would be much cleaner.
Unfortunately, the number of cache leaves of the primary CPU hasn't
been detected/populated at the time when fetch_cache_info() is called.
That means we don't know how much memory to pre-allocate.

This is the call flow that I recorded (read from top to bottom):
smp_prepare_cpus
        init_cpu_topology
                parse_acpi_topology
                parse_dt_topology
                fetch_cache_info(cpu)
                        init_of_cache_level(cpu)
                        acpi_get_cache_info(cpu)
                        allocate_cache_info(cpu)
        store_cpu_topology(this_cpu)
                update_siblings_masks
                        detect_cache_attributes


The number of cache leaves of the primary CPU is populated inside that
last call to detect_cache_attributes(). If you can think of any other
way around it, I am definitely open to suggestions.

On a slightly different note, I think most of this code/mechanism is
shared with RISC-V, but smp_prepare_cpus() is ARM64 specific. Unless we
can think of a way to avoid that extra call to pre_alloc_cache_info(),
we may need one for RISC-V as well.

My main intention was to get some feedback and see if you are willing
to accept something along these lines upstream. I can improve it and
send subsequent versions of the patch if needed. Thanks again for
taking the time to review it.

Best regards,
Radu


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-03-27 14:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 22:42 [RFC PATCH] arch_topology: Pre-allocate cacheinfo from primary CPU Radu Rendec
2023-03-27 12:02 ` Pierre Gondois
2023-03-27 14:23   ` Radu Rendec [this message]
2023-03-29 14:42     ` Pierre Gondois
2023-03-29 15:03       ` Sudeep Holla
2023-03-29 15:39         ` Pierre Gondois
2023-03-29 21:35           ` Radu Rendec
2023-03-30  6:57             ` Pierre Gondois
2023-03-30 23:32               ` Radu Rendec
2023-03-31 14:49                 ` Pierre Gondois
2023-04-03 21:25                   ` 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=b859807a8cda770521aa47cc347865b0e7945c50.camel@redhat.com \
    --to=rrendec@redhat.com \
    --cc=athierry@redhat.com \
    --cc=echanude@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=pierre.gondois@arm.com \
    --cc=sudeep.holla@arm.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