From: Reinette Chatre <reinette.chatre@intel.com>
To: Tony Luck <tony.luck@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>
Cc: Fenghua Yu <fenghua.yu@intel.com>,
Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>,
Peter Newman <peternewman@google.com>,
James Morse <james.morse@arm.com>,
Babu Moger <babu.moger@amd.com>,
"Drew Fustini" <dfustini@baylibre.com>,
Dave Martin <Dave.Martin@arm.com>, <linux-kernel@vger.kernel.org>,
<patches@lists.linux.dev>
Subject: Re: [PATCH 1/3] cacheinfo: Add function to get cacheinfo for a given (cpu, cachelevel)
Date: Mon, 3 Jun 2024 11:06:53 -0700 [thread overview]
Message-ID: <9a283339-b6d1-48f0-a949-d772152bf7c1@intel.com> (raw)
In-Reply-To: <20240531195720.232561-2-tony.luck@intel.com>
Hi Tony,
On 5/31/24 12:57 PM, Tony Luck wrote:
> Resctrl code open codes a search for information about a given cache
> level in a couple of places (and more are on the way).
>
> Provide a new inline function get_cpu_cacheinfo_level() in
> <linux/cacheinfo.h> to do the search and return a pointer to
> the cacheinfo structure.
>
> Simplify the existing get_cpu_cacheinfo_id() by using this new
> function to do the search.
>
> Signed-off-by: Tony Luck <tony.luck@intel.com>
> ---
> include/linux/cacheinfo.h | 21 ++++++++++++++++-----
> 1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h
> index 2cb15fe4fe12..301b0b24f446 100644
> --- a/include/linux/cacheinfo.h
> +++ b/include/linux/cacheinfo.h
> @@ -113,10 +113,10 @@ int acpi_get_cache_info(unsigned int cpu,
> const struct attribute_group *cache_get_priv_group(struct cacheinfo *this_leaf);
>
> /*
> - * Get the id of the cache associated with @cpu at level @level.
> + * Get the cacheinfo structure for cache associated with @cpu at level @level.
"for cache" -> "for the cache"?
> * cpuhp lock must be held.
> */
> -static inline int get_cpu_cacheinfo_id(int cpu, int level)
> +static inline struct cacheinfo *get_cpu_cacheinfo_level(int cpu, int level)
> {
> struct cpu_cacheinfo *ci = get_cpu_cacheinfo(cpu);
> int i;
> @@ -124,12 +124,23 @@ static inline int get_cpu_cacheinfo_id(int cpu, int level)
> for (i = 0; i < ci->num_leaves; i++) {
> if (ci->info_list[i].level == level) {
> if (ci->info_list[i].attributes & CACHE_ID)
> - return ci->info_list[i].id;
> - return -1;
> + return &ci->info_list[i];
> + return NULL;
> }
> }
>
> - return -1;
> + return NULL;
> +}
> +
> +/*
> + * Get the id of the cache associated with @cpu at level @level.
> + * cpuhp lock must be held.
> + */
> +static inline int get_cpu_cacheinfo_id(int cpu, int level)
> +{
> + struct cacheinfo *ci = get_cpu_cacheinfo_level(cpu, level);
> +
> + return ci ? ci->id : -1;
> }
>
> #ifdef CONFIG_ARM64
Just the one nitpick from me.
Thank you.
| Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Reinette
next prev parent reply other threads:[~2024-06-03 18:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-31 19:57 [PATCH 0/3] Add and use get_cpu_cacheinfo_level() Tony Luck
2024-05-31 19:57 ` [PATCH 1/3] cacheinfo: Add function to get cacheinfo for a given (cpu, cachelevel) Tony Luck
2024-06-03 18:06 ` Reinette Chatre [this message]
2024-05-31 19:57 ` [PATCH 2/3] x86/resctrl: Replace open code cacheinfo search in pseudo_lock_region_init() Tony Luck
2024-06-03 18:07 ` Reinette Chatre
2024-05-31 19:57 ` [PATCH 3/3] x86/resctrl: Replace open code cacheinfo search in rdtgroup_cbm_to_size() Tony Luck
2024-06-03 18:07 ` Reinette Chatre
2024-06-04 18:03 ` Luck, Tony
2024-06-03 16:55 ` [PATCH 0/3] Add and use get_cpu_cacheinfo_level() Reinette Chatre
2024-06-03 17:01 ` Borislav Petkov
2024-06-03 17:18 ` Luck, Tony
2024-06-03 18:24 ` Borislav Petkov
2024-06-05 2:22 ` Andrew Morton
2024-06-05 8:14 ` Borislav Petkov
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=9a283339-b6d1-48f0-a949-d772152bf7c1@intel.com \
--to=reinette.chatre@intel.com \
--cc=Dave.Martin@arm.com \
--cc=akpm@linux-foundation.org \
--cc=babu.moger@amd.com \
--cc=bp@alien8.de \
--cc=dfustini@baylibre.com \
--cc=fenghua.yu@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=james.morse@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.wieczor-retman@intel.com \
--cc=patches@lists.linux.dev \
--cc=peternewman@google.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.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