All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: Reinette Chatre <reinette.chatre@intel.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Fenghua Yu <fenghua.yu@intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	shameerali.kolothum.thodi@huawei.com,
	Jamie Iles <jamie@nuviainc.com>,
	D Scott Phillips OS <scott@os.amperecomputing.com>
Subject: Re: [PATCH 11/24] x86/resctrl: Group staged configuration into a separate struct
Date: Fri, 12 Mar 2021 17:41:33 +0000	[thread overview]
Message-ID: <867f26b9-cd03-fa32-ba7a-038a7873435b@arm.com> (raw)
In-Reply-To: <28586ec7-608f-4857-19f9-f9a9d5c927f5@intel.com>

Hi Reinette,

On 17/11/2020 23:28, Reinette Chatre wrote:
> On 10/30/2020 9:11 AM, James Morse wrote:
>> Arm's MPAM may have surprisingly large bitmaps for its cache
>> portions as the architecture allows up to 4K portions. The size
>> exposed via resctrl may not be the same, some scaling may
>> occur.
>>
>> The values written to hardware may be unlike the values received
>> from resctrl, e.g. MBA percentages may be backed by a bitmap,
>> or a maximum value that isn't a percentage.
>>
>> Today resctrl's ctrlval arrays are written to directly by the

> If using a cryptic word like "ctrlval" it would be easier to understand what is meant if
> it matches the variable in the code, "ctrl_val".

I thought the non-underscore version was the preferred version, e.g:
setup_default_ctrlval(), domain_setup_ctrlval() and parse_ctrlval. I'll switch to the
underscore version for things other than functions if you think its clearer.


>> resctrl filesystem code. e.g. apply_config(). This is a problem
> 
> This sentence starts with "Today" implying what code does before this change but the
> example function, apply_config() is introduced in this patch.

I don't follow the problem here, 'today' refers to what the code does before the patch is
applied. "Before this patch" would make me unpopular, I'll try 'previously'.


>> if scaling or conversion is needed by the architecture.
>>
>> The arch code should own the ctrlval array (to allow scaling and
>> conversion), and should only need a single copy of the array for the
>> values currently applied in hardware.

> ok, but that is the case, no?

Its true for x86. But whether its true for MPAM depends on which side of the divide this
thing lands as the value from user-space may be different to what gets written to hardware.
If the filesystem code owned the list of values, there would need to be two copies to
allow MPAM to restore the values in hardware when CPUs come online.

(in particular, the MBA percentage control can be emulated with MPAMs bitmap or fractional
min/max, the driver has to choose at startup).

I'll try and bundle this as a clearer explanation into the commit message.


>> Move the new_ctrl bitmap value and flag into a struct for staged
>> configuration changes. This is created as an array to allow one per type
> 
> This is a bit cryptic as the reader may not know while reading this commit message what
> "new_ctrl" is or where it is currently hosted.

Sure, I'll add more explanation of the current code.


>> of configuration. Today there is only one element in the array, but
>> eventually resctrl will use the array slots for CODE/DATA/BOTH to detect
>> a duplicate schema being written.


>> diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
>> b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
>> index 28d69c78c29e..0c95ed83eb05 100644
>> --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
>> +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
> 
> ...
> 
>> @@ -240,15 +244,30 @@ static int parse_line(char *line, struct resctrl_schema *s,
>>       return -EINVAL;
>>   }
>>   +static void apply_config(struct rdt_hw_domain *hw_dom,
>> +             struct resctrl_staged_config *cfg, int closid,
>> +             cpumask_var_t cpu_mask, bool mba_sc)
>> +{
>> +    struct rdt_domain *dom = &hw_dom->resctrl;
>> +    u32 *dc = mba_sc ? hw_dom->mbps_val : hw_dom->ctrl_val;
>> +
>> +    if (cfg->new_ctrl != dc[closid]) {
>> +        cpumask_set_cpu(cpumask_any(&dom->cpu_mask), cpu_mask);
>> +        dc[closid] = cfg->new_ctrl;
>> +    }
>> +
>> +    cfg->have_new_ctrl = false;
> 
> Why is this necessary?

(hmm, its ended up in the wrong patch, but:) This was to ensure that once the resources
are merged, all the work for applying configuration changes is done by the first IPI,
ensuring if update_domains() is called for a second schema with the same resource, it
finds no new work to do.
But without this, the empty_bitmap check would still catch it. I'll remove it.


>> +}
>> +
>>   int update_domains(struct rdt_resource *r, int closid)
>>   {
>> +    struct resctrl_staged_config *cfg;
>>       struct rdt_hw_domain *hw_dom;
>>       struct msr_param msr_param;
>>       cpumask_var_t cpu_mask;
>>       struct rdt_domain *d;
>>       bool mba_sc;
>> -    u32 *dc;
>> -    int cpu;
>> +    int cpu, i;
>>         if (!zalloc_cpumask_var(&cpu_mask, GFP_KERNEL))
>>           return -ENOMEM;
>> @@ -260,10 +279,12 @@ int update_domains(struct rdt_resource *r, int closid)
>>       mba_sc = is_mba_sc(r);
>>       list_for_each_entry(d, &r->domains, list) {
>>           hw_dom = resctrl_to_arch_dom(d);
>> -        dc = !mba_sc ? hw_dom->ctrl_val : hw_dom->mbps_val;
>> -        if (d->have_new_ctrl && d->new_ctrl != dc[closid]) {
>> -            cpumask_set_cpu(cpumask_any(&d->cpu_mask), cpu_mask);
>> -            dc[closid] = d->new_ctrl;
>> +        for (i = 0; i < ARRAY_SIZE(d->staged_config); i++) {

> I understand it may make later patches easier but it seems too early to introduce this
> loop because apply_config() does not seem to be ready for it yet (it would just keep
> overwriting a closid's config).

Grouping these values is needed because they become a set, one per type of configuration.
This ended up here because its looping over the set, even its only got one entry at the
moment.

Sure, I'll move it into a later patch. Presumably you want the array indexing to move too.


>> +            cfg = &hw_dom->resctrl.staged_config[i];
>> +            if (!cfg->have_new_ctrl)
>> +                continue;
>> +
>> +            apply_config(hw_dom, cfg, closid, cpu_mask, mba_sc);
>>           }
>>       }
>>   @@ -338,7 +359,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
>>         list_for_each_entry(s, &resctrl_all_schema, list) {
>>           list_for_each_entry(dom, &s->res->domains, list)
>> -            dom->have_new_ctrl = false;
>> +            memset(dom->staged_config, 0, sizeof(dom->staged_config));
>>       }
>>         while ((tok = strsep(&buf, "\n")) != NULL) {
> 
> ...
> 
>> diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
>> index 9f71f0238239..f1164bbb66c5 100644
>> --- a/include/linux/resctrl.h
>> +++ b/include/linux/resctrl.h
>> @@ -26,13 +26,21 @@ enum resctrl_conf_type {
>>       CDP_DATA,
>>   };
>>   +/**
>> + * struct resctrl_staged_config - parsed configuration to be applied
>> + * @new_ctrl:        new ctrl value to be loaded
>> + * @have_new_ctrl:    did user provide new_ctrl for this domain
> 
> The "for this domain" in this description is no longer appropriate after the copy.

This structure is still embedded in struct rdt_domain, but I'll rephrase it.


Thanks,

James


>> + */
>> +struct resctrl_staged_config {
>> +    u32            new_ctrl;
>> +    bool            have_new_ctrl;
>> +};

>> @@ -59,6 +65,7 @@ struct rdt_domain {
>>       int                cqm_work_cpu;
>>         struct pseudo_lock_region    *plr;
>> +    struct resctrl_staged_config    staged_config[1];
>>   };

  reply	other threads:[~2021-03-12 17:42 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-30 16:10 [PATCH 00/24] x86/resctrl: Merge the CDP resources James Morse
2020-10-30 16:10 ` [PATCH 01/24] x86/resctrl: Split struct rdt_resource James Morse
2020-11-17 19:20   ` Reinette Chatre
2021-03-12 17:10     ` James Morse
2020-10-30 16:10 ` [PATCH 02/24] x86/resctrl: Split struct rdt_domain James Morse
2020-11-17 19:22   ` Reinette Chatre
2020-10-30 16:10 ` [PATCH 03/24] x86/resctrl: Add resctrl_arch_get_num_closid() James Morse
2020-11-17 19:57   ` Reinette Chatre
2021-03-12 17:10     ` James Morse
2020-10-30 16:11 ` [PATCH 04/24] x86/resctrl: Add a separate schema list for resctrl James Morse
2020-11-17 21:29   ` Reinette Chatre
2021-03-12 17:10     ` James Morse
2020-10-30 16:11 ` [PATCH 05/24] x86/resctrl: Pass the schema in resdir's private pointer James Morse
2020-11-17 21:49   ` Reinette Chatre
2021-03-12 17:11     ` James Morse
2020-10-30 16:11 ` [PATCH 06/24] x86/resctrl: Store the effective num_closid in the schema James Morse
2020-11-17 22:04   ` Reinette Chatre
2021-03-12 17:13     ` James Morse
2020-10-30 16:11 ` [PATCH 07/24] x86/resctrl: Label the resources with their configuration type James Morse
2020-11-17 22:30   ` Reinette Chatre
2021-03-12 17:36     ` James Morse
2020-10-30 16:11 ` [PATCH 08/24] x86/resctrl: Walk the resctrl schema list instead of an arch list James Morse
2020-11-17 22:52   ` Reinette Chatre
2021-03-12 17:37     ` James Morse
2020-10-30 16:11 ` [PATCH 09/24] x86/resctrl: Change rdt_resource to resctrl_schema in pseudo_lock_region James Morse
2020-10-30 16:11 ` [PATCH 10/24] x86/resctrl: Move the schema names into struct resctrl_schema James Morse
2020-11-10 11:39   ` Jamie Iles
2020-11-11 18:11     ` James Morse
2020-11-17 23:11   ` Reinette Chatre
2021-03-12 17:38     ` James Morse
2020-10-30 16:11 ` [PATCH 11/24] x86/resctrl: Group staged configuration into a separate struct James Morse
2020-11-17 23:28   ` Reinette Chatre
2021-03-12 17:41     ` James Morse [this message]
2020-10-30 16:11 ` [PATCH 12/24] x86/resctrl: Add closid to the staged config James Morse
2020-11-17 23:46   ` Reinette Chatre
2021-03-12 17:43     ` James Morse
2020-10-30 16:11 ` [PATCH 13/24] x86/resctrl: Allow different CODE/DATA configurations to be staged James Morse
2020-11-18  0:30   ` Reinette Chatre
2020-10-30 16:11 ` [PATCH 14/24] x86/resctrl: Make update_domains() learn the affected closids James Morse
2020-10-30 16:11 ` [PATCH 15/24] x86/resctrl: Add a helper to read a closid's configuration James Morse
2020-10-30 16:11 ` [PATCH 16/24] x86/resctrl: Add a helper to read/set the CDP configuration James Morse
2020-10-30 16:11 ` [PATCH 17/24] x86/resctrl: Use cdp_enabled in rdt_domain_reconfigure_cdp() James Morse
2020-10-30 16:11 ` [PATCH 18/24] x86/resctrl: Pass configuration type to resctrl_arch_get_config() James Morse
2020-10-30 16:11 ` [PATCH 19/24] x86/resctrl: Make ctrlval arrays the same size James Morse
2020-10-30 16:11 ` [PATCH 20/24] x86/resctrl: Apply offset correction when config is staged James Morse
2020-10-30 16:11 ` [PATCH 21/24] x86/resctrl: Calculate the index from the configuration type James Morse
2020-10-30 16:11 ` [PATCH 22/24] x86/resctrl: Merge the ctrlval arrays James Morse
2020-10-30 16:11 ` [PATCH 23/24] x86/resctrl: Remove rdt_cdp_peer_get() James Morse
2020-10-30 16:11 ` [PATCH 24/24] x86/resctrl: Merge the CDP resources James Morse
2020-11-13 15:38 ` [PATCH 00/24] " Jamie Iles
2020-11-16 17:54 ` Reinette Chatre
2020-11-17 13:05   ` James Morse

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=867f26b9-cd03-fa32-ba7a-038a7873435b@arm.com \
    --to=james.morse@arm.com \
    --cc=bp@alien8.de \
    --cc=fenghua.yu@intel.com \
    --cc=jamie@nuviainc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=reinette.chatre@intel.com \
    --cc=scott@os.amperecomputing.com \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=tglx@linutronix.de \
    --cc=x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.