public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: James Morse <james.morse@arm.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>,
	H Peter Anvin <hpa@zytor.com>, Babu Moger <Babu.Moger@amd.com>,
	<shameerali.kolothum.thodi@huawei.com>,
	D Scott Phillips OS <scott@os.amperecomputing.com>,
	<carl@os.amperecomputing.com>, <lcherian@marvell.com>,
	<bobo.shaobowang@huawei.com>, <tan.shaopeng@fujitsu.com>,
	<baolin.wang@linux.alibaba.com>,
	Jamie Iles <quic_jiles@quicinc.com>,
	Xin Hao <xhao@linux.alibaba.com>, <peternewman@google.com>,
	<dfustini@baylibre.com>, <amitsinght@marvell.com>,
	David Hildenbrand <david@redhat.com>,
	Rex Nie <rex.nie@jaguarmicro.com>,
	"Dave Martin" <dave.martin@arm.com>
Subject: Re: [PATCH v4 04/39] x86/resctrl: Use schema type to determine how to parse schema values
Date: Mon, 16 Sep 2024 15:33:27 -0700	[thread overview]
Message-ID: <6941deab-0bec-41e1-975b-274fc9d6b8e1@intel.com> (raw)
In-Reply-To: <4a1da47f-655a-4ba1-9b68-baaad297dda9@arm.com>

Hi James,

On 9/6/24 11:06 AM, James Morse wrote:
> Hi Reinette,
> 
> On 14/08/2024 04:56, Reinette Chatre wrote:
>> On 8/2/24 10:28 AM, James Morse wrote:
>>> diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
>>> index 9ca542a8e2d4..57c88e1c2adf 100644
>>> --- a/arch/x86/kernel/cpu/resctrl/core.c
>>> +++ b/arch/x86/kernel/cpu/resctrl/core.c
> 
>>> @@ -192,6 +191,18 @@ enum resctrl_scope {
>>>        RESCTRL_L3_NODE,
>>>    };
>>>    +/**
>>> + * enum resctrl_schema_fmt - The format user-space provides for a schema.
>>> + * @RESCTRL_SCHEMA_BITMAP:    The schema is a bitmap in hex.
>>> + * @RESCTRL_SCHEMA_PERCENTAGE:    The schema is a decimal percentage value.
>>> + * @RESCTRL_SCHEMA_MBPS:    The schema is a decimal MBps value.
>>> + */
>>> +enum resctrl_schema_fmt {
>>> +    RESCTRL_SCHEMA_BITMAP,
>>> +    RESCTRL_SCHEMA_PERCENTAGE,
>>> +    RESCTRL_SCHEMA_MBPS,
>>> +};
>>> +
>>
>> I believe that the choice of RESCTRL_SCHEMA_PERCENTAGE and RESCTRL_SCHEMA_MBPS has
>> potential for significant confusion. The closest place to where user space can enter
>> a MBps value (which is actually MiBps) is on Intel when resctrl is mounted with mba_MBps,
>> and as per above it will have the "RESCTRL_SCHEMA_PERCENTAGE" format.
> 
> It was AMD's QOS that I was thinking of. To pick the example from the documentation:
> | For example, to allocate 2GB/s limit on the first cache id:
> |    MB:0=2048;1=2048;2=2048;3=2048
> 
> How does user-space know that its not a percentage? Suck it and see...
> If those values aren't in MB/s ... I'm not sure what they are.

I agree that this is an issue.

> 
> 
> The schema format isn't exposed to user-space. (I think we should do that).
> I agree if it were, we'd need to report MBps/MiBps for the mba_sc case.

I agree that it would be ideal to expose the schema format to user space.

>> What is considered
>> here as RESCTRL_SCHEMA_MBPS also cannot really be considered as "MBPS" since it is used to
>> cover AMD's values that are "multiples of one eighth GB/s". Any new resource that
>> _actually_ uses MBPS will thus not be able to use RESCTRL_SCHEMA_MBPS.
> 
> Isn't this already covered by the granularity?
> AMD platforms are unfortunately reporting '1' as the granularity.
>  From the 1/8th GB/s it sounds like the granularity should really be 128 MB/s.

Unfortunately the existing interface makes consistent use of granularity (by user
space) difficult.

As the doc highlights:
	"bandwidth_gran":
		...
		available bandwidth control steps are
		min_bandwidth + N * bandwidth_gran.


You are correct that setting AMD's granularity to 128 MB/s would make the expected
bandwidth clear to user space. The problem is that the existing schemata displays to
user space and expects from user space the value of "N" for MB on AMD while it
displays to user space and expects from user space the value of "min_bandwidth + N *
bandwidth_gran" from user space for MB on Intel.

> 
> Any platform that did have a real MB/s control could report whatever granularity it really
> has here.
> 
> 
>> Considering that RESCTRL_SCHEMA_PERCENTAGE and RESCTRL_SCHEMA_MBPS use the same parser,
>> could "RESCTRL_SCHEMA_RANGE" be more fitting? I acknowledge that it is very generic and
>> better
>> ideas are welcome. A "range" does seem to be appropriate considering the later patch
>> (x86/resctrl:
> 
>> Add max_bw to struct resctrl_membw) that codes an explicit max.
> 
> Yes because the AMD platforms have a firmware-advertised maximum value, I presume that is
> an achievable bandwidth. (otherwise why advertise it to user-space!).
> (I'm not sure why data_width is 4 - it looks like that was the hard coded based on one
>   platforms limit ... that probably needs fixing too)
> 
> But if you had a MBps control, I'm not sure that implies you know what the maximum
> achievable bandwidth is. The control may have a range based on some power of two, which is
> unrelated to the bandwidth.

I believe that is the current resctrl mechanism, with the huge caveat that the only
implementation is actually software defined range limit.

> In the arm world the hardware never knows what the achievable bandwidth is - that is
> something only the SoC designer can work out.
> 
> 
> I agree we can parse both values as a range, as resctrl doesn't need to interpret the
> values, its just whatever the hardware does.
> 
> I did it like this as I'd like to expose "percentage/MBps/bitmap" to user-space so that
> control types user-space doesn't recognised can be programmed. If arm64 and riscv each
> want to add new schema types, it would be good to do it in a way that is low-impact for
> the resctrl filesystem code, and unaware user-space can do something with.
> percentage/MBps/bitmap are the control schemes we already have.

Adding bitmap will need more thought, since resctrl does not support that today for
MB there is some flexibility when adding support for it.

> 
> The MBps/range difference matters if the 'maximum bandwidth' isn't actually an achievable
> number e.g. ~0, then user-space can't treat it as some kind of percentage.

This last statement is not clear to me. It sounds as though you are considering the
underlying implementation treating provided bandwidth as percentage as opposed to
the interface itself being bandwidth or percentage? hmmm ... or are you referring to
the software controller?

I wonder if bandwidth and percentage can continue using the same interface as today
by using bandwidth_gran as you hinted to ... but with the backward compatibility of
needing to distinguish between schemata interface expecting the total or the steps.
I do not know what (if any) impact there will be if AMD's bandwidth_gran is
changed to 128 MB/s.

Reinette

  reply	other threads:[~2024-09-16 22:33 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-02 17:28 [PATCH v4 00/39] x86/resctrl: Move the resctrl filesystem code to /fs/resctrl James Morse
2024-08-02 17:28 ` [PATCH v4 01/39] x86/resctrl: Fix allocation of cleanest CLOSID on platforms with no monitors James Morse
2024-08-02 17:28 ` [PATCH v4 02/39] x86/resctrl: Add a helper to avoid reaching into the arch code resource list James Morse
2024-08-02 17:28 ` [PATCH v4 03/39] x86/resctrl: Remove fflags from struct rdt_resource James Morse
2024-08-14  3:53   ` Reinette Chatre
2024-08-02 17:28 ` [PATCH v4 04/39] x86/resctrl: Use schema type to determine how to parse schema values James Morse
2024-08-14  3:56   ` Reinette Chatre
2024-09-06 18:06     ` James Morse
2024-09-16 22:33       ` Reinette Chatre [this message]
2024-09-30 16:42         ` James Morse
2024-08-02 17:28 ` [PATCH v4 05/39] x86/resctrl: Use schema type to determine the schema format string James Morse
2024-08-14  3:57   ` Reinette Chatre
2024-08-02 17:28 ` [PATCH v4 06/39] x86/resctrl: Move data_width to be a schema property James Morse
2024-08-14  3:59   ` Reinette Chatre
2024-09-13 18:07     ` James Morse
2024-08-02 17:28 ` [PATCH v4 07/39] x86/resctrl: Add max_bw to struct resctrl_membw James Morse
2024-08-14  4:00   ` Reinette Chatre
2024-08-02 17:28 ` [PATCH v4 08/39] x86/resctrl: Generate default_ctrl instead of sharing it James Morse
2024-08-14  4:00   ` Reinette Chatre
2024-09-13 18:07     ` James Morse
2024-09-16 22:34       ` Reinette Chatre
2024-08-02 17:28 ` [PATCH v4 09/39] x86/resctrl: Add helper for setting CPU default properties James Morse
2024-08-02 17:28 ` [PATCH v4 10/39] x86/resctrl: Remove rdtgroup from update_cpu_closid_rmid() James Morse
2024-08-02 17:28 ` [PATCH v4 11/39] x86/resctrl: Export resctrl fs's init function James Morse
2024-08-14  4:01   ` Reinette Chatre
2024-08-02 17:28 ` [PATCH v4 12/39] x86/resctrl: Wrap resctrl_arch_find_domain() around rdt_find_domain() James Morse
2024-08-02 17:28 ` [PATCH v4 13/39] x86/resctrl: Move resctrl types to a separate header James Morse
2024-08-02 17:28 ` [PATCH v4 14/39] x86/resctrl: Add a resctrl helper to reset all the resources James Morse
2024-08-02 17:28 ` [PATCH v4 15/39] x86/resctrl: Move monitor exit work to a resctrl exit call James Morse
2024-08-14  4:01   ` Reinette Chatre
2024-09-30 16:42     ` James Morse
2024-08-02 17:28 ` [PATCH v4 16/39] x86/resctrl: Move monitor init work to a resctrl init call James Morse
2024-08-02 17:28 ` [PATCH v4 17/39] x86/resctrl: Rewrite and move the for_each_*_rdt_resource() walkers James Morse
2024-08-15  6:43   ` Shaopeng Tan (Fujitsu)
2024-09-30 16:42     ` James Morse
2024-08-02 17:28 ` [PATCH v4 18/39] x86/resctrl: Export the is_mbm_*_enabled() helpers to asm/resctrl.h James Morse
2024-08-02 17:28 ` [PATCH v4 19/39] x86/resctrl: Add resctrl_arch_is_evt_configurable() to abstract BMEC James Morse
2024-08-14  4:01   ` Reinette Chatre
2024-08-02 17:28 ` [PATCH v4 20/39] x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers James Morse
2024-08-14  4:02   ` Reinette Chatre
2024-10-02 16:58     ` James Morse
2024-08-02 17:28 ` [PATCH v4 21/39] x86/resctrl: Move mbm_cfg_mask to struct rdt_resource James Morse
2024-08-02 17:28 ` [PATCH v4 22/39] x86/resctrl: Add resctrl_arch_ prefix to pseudo lock functions James Morse
2024-08-02 17:28 ` [PATCH v4 23/39] x86/resctrl: Allow an architecture to disable pseudo lock James Morse
2024-08-14  4:02   ` Reinette Chatre
2024-08-02 17:28 ` [PATCH v4 24/39] x86/resctrl: Make prefetch_disable_bits belong to the arch code James Morse
2024-08-02 17:28 ` [PATCH v4 25/39] x86/resctrl: Make resctrl_arch_pseudo_lock_fn() take a plr James Morse
2024-08-02 17:28 ` [PATCH v4 26/39] x86/resctrl: Move thread_throttle_mode_init() to be managed by resctrl James Morse
2024-08-02 17:28 ` [PATCH v4 27/39] x86/resctrl: Move get_config_index() to a header James Morse
2024-08-02 17:28 ` [PATCH v4 28/39] x86/resctrl: Claim get_{mon,ctrl}_domain_from_cpu() helpers for resctrl James Morse
2024-08-02 17:28 ` [PATCH v4 29/39] x86/resctrl: Describe resctrl's bitmap size assumptions James Morse
2024-08-02 17:28 ` [PATCH v4 30/39] x86/resctrl: Rename resctrl_sched_in() to begin with "resctrl_arch_" James Morse
2024-08-02 17:28 ` [PATCH v4 31/39] x86/resctrl: resctrl_exit() teardown resctrl but leave the mount point James Morse
2024-08-02 17:28 ` [PATCH v4 32/39] x86/resctrl: Drop __init/__exit on assorted symbols James Morse
2024-08-02 17:28 ` [PATCH v4 33/39] x86/resctrl: Move is_mba_sc() out of core.c James Morse
2024-08-02 17:28 ` [PATCH v4 34/39] x86/resctrl: Add end-marker to the resctrl_event_id enum James Morse
2024-08-02 17:28 ` [PATCH v4 35/39] x86/resctrl: Remove a newline to avoid confusing the code move script James Morse
2024-08-02 17:28 ` [PATCH v4 36/39] x86/resctrl: Split trace.h James Morse
2024-08-02 17:28 ` [PATCH v4 37/39] fs/resctrl: Add boiler plate for external resctrl code James Morse
2024-08-14  4:04   ` Reinette Chatre
2024-08-02 17:28 ` [PATCH v4 38/39] x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl James Morse
2024-08-02 17:28 ` [PATCH v4 39/39] x86/resctrl: Add python script to move resctrl code to /fs/resctrl James Morse
2024-08-06  7:13 ` [PATCH v4 00/39] x86/resctrl: Move the resctrl filesystem " Shaopeng Tan (Fujitsu)
2024-08-15  7:04   ` Shaopeng Tan (Fujitsu)
2024-10-02 16:58     ` 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=6941deab-0bec-41e1-975b-274fc9d6b8e1@intel.com \
    --to=reinette.chatre@intel.com \
    --cc=Babu.Moger@amd.com \
    --cc=amitsinght@marvell.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=bobo.shaobowang@huawei.com \
    --cc=bp@alien8.de \
    --cc=carl@os.amperecomputing.com \
    --cc=dave.martin@arm.com \
    --cc=david@redhat.com \
    --cc=dfustini@baylibre.com \
    --cc=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=james.morse@arm.com \
    --cc=lcherian@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peternewman@google.com \
    --cc=quic_jiles@quicinc.com \
    --cc=rex.nie@jaguarmicro.com \
    --cc=scott@os.amperecomputing.com \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=tan.shaopeng@fujitsu.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xhao@linux.alibaba.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