[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v10 01/12] xen/common: add cache coloring common code


  • To: Carlo Nonato <carlo.nonato@xxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Wed, 27 Nov 2024 14:57:52 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=minervasys.tech smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3OPpQ6SSC7w1EteO/O4Qgo0V+iE709uxjQDzGlRrdUM=; b=VWDJEcuRsBYXzFkU+JhpbPCueDqkBpWZBSikq6yE+yFH4/xLzEsokQmWIpWhaX7L1QLvLOZI++DzuCPm15142TjLN23GpvTBT1DsSQyhlxGFfXw7RIE1jKxTzj7ohs/osY4vvTN9BrD2bCU5ANUzAh+nP3OFJ4wNQ+jKOZvO6/Xjpsa+HyMEck3LkXlbMeny0xhQP0f2TqfFQzRyvT/uYV+wrWaAZAcF6ctWmaHub7acH7wUK+wrAbE6y2WY+SJFzOSF8SRmObkmTLJqB+qP9U7qn9fSbwZmWRQziJzX+YJdJ8M2XRMyzbaGdcOD2PGe6TsInSBtupSPYfUgaeII8w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FLIZH1QfB9Yf5FQb1NwoLD1gPcAPjfOsNYNSjUqAWOnpLk3od6xvSG+7SArO+E/jHscKd7ftro3Lz95MshY/E3w/zqNG1wmUvdh6qUr/ASdXjnev4zeeuDE6uufUsykrhJnJ2mw5oCCGd1N0incmC8pB0YdV5d0GTCveI8Pio2xf04WSeUplfl/vOroltGftx67iqhcaZLD6H48czeQ/ymsOXuGKhcdwsOA9s9dTMJjWLbrEE1KvJLatqj2bfSuKutlUX+Z7n4WnJI46Veat3BigRc+JeV8Yi/3Gh0rM4OLv4wrZO4I13WPwpwmjpXUhUkDQC+wYW8/dNlprURGAng==
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <andrea.bastoni@xxxxxxxxxxxxxxx>, <marco.solieri@xxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Wed, 27 Nov 2024 13:58:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 27/11/2024 14:24, Carlo Nonato wrote:
> 
> 
> Hi Michal,
> 
> On Wed, Nov 27, 2024 at 11:48 AM Michal Orzel <michal.orzel@xxxxxxx> wrote:
>> On 19/11/2024 15:13, Carlo Nonato wrote:
>>>
>>>
>>> Last Level Cache (LLC) coloring allows to partition the cache in smaller
>>> chunks called cache colors.
>>>
>>> Since not all architectures can actually implement it, add a 
>>> HAS_LLC_COLORING
>>> Kconfig option.
>>> LLC_COLORS_ORDER Kconfig option has a range maximum of 10 (2^10 = 1024)
>>> because that's the number of colors that fit in a 4 KiB page when integers
>>> are 4 bytes long.
>>>
>>> LLC colors are a property of the domain, so struct domain has to be 
>>> extended.
>>>
>>> Based on original work from: Luca Miccio <lucmiccio@xxxxxxxxx>
>>>
>>> Signed-off-by: Carlo Nonato <carlo.nonato@xxxxxxxxxxxxxxx>
>>> Signed-off-by: Marco Solieri <marco.solieri@xxxxxxxxxxxxxxx>

[...]

>>> +### llc-nr-ways (arm64)
>>> +> `= <integer>`
>>> +
>>> +> Default: `Obtained from hardware`
>>> +
>>> +Specify the number of ways of the Last Level Cache. This option is 
>>> available
>>> +only when `CONFIG_LLC_COLORING` is enabled. LLC size and number of ways 
>>> are used
>>> +to find the number of supported cache colors. By default the value is
>>> +automatically computed by probing the hardware, but in case of specific 
>>> needs,
>>> +it can be manually set. Those include failing probing and debugging/testing
>>> +purposes so that it's possible to emulate platforms with different number 
>>> of
>>> +supported colors. If set, also "llc-size" must be set, otherwise the 
>>> default
>>> +will be used. Note that using both options implies "llc-coloring=on".
>> I can understand this decision, but ...
>>
>> [...]
>>
>>> +    if ( llc_size && llc_nr_ways )
>>> +    {
>>> +        llc_coloring_enabled = true;
>>> +        way_size = llc_size / llc_nr_ways;
>>> +    }
>>> +    else if ( !llc_coloring_enabled )
>>> +        return;
>> the above code does not seem to be right. When debugging or in general it is 
>> useful to have on the cmdline:
>> llc-size=1M llc-nr-ways=16 llc-coloring=on
>> and be able to disable it by just switching between on/off in llc-coloring=. 
>> However, with your solution,
>> even if I specify llc-coloring=off, it will be enabled because I specified 
>> both llc-size and llc-nr-ways.
>> I think llc-coloring= should have a precedence.
> 
> How do you differentiate from
> llc-size=1M llc-nr-ways=16 llc-coloring=off
> where llc coloring is disabled, and
> llc-size=1M llc-nr-ways=16
> where llc coloring is enabled? I mean, in both situations llc_coloring_enabled
> is going to be set to false.
I was thinking about the following:
diff --git a/xen/common/llc-coloring.c b/xen/common/llc-coloring.c
index 29b75e0e0d6a..b6684a6cf736 100644
--- a/xen/common/llc-coloring.c
+++ b/xen/common/llc-coloring.c
@@ -11,7 +11,12 @@

 #define NR_LLC_COLORS          (1U << CONFIG_LLC_COLORS_ORDER)

-static bool __ro_after_init llc_coloring_enabled;
+/*
+ * -1: not specified (disabled unless llc-size and llc-nr-ways present)
+ *  0: explicitly disabled through cmdline
+ *  1: explicitly enabled through cmdline
+ */
+static int8_t __ro_after_init llc_coloring_enabled = -1;
 boolean_param("llc-coloring", llc_coloring_enabled);

 static unsigned int __initdata llc_size;
@@ -48,7 +53,7 @@ void __init llc_coloring_init(void)
 {
     unsigned int way_size;

-    if ( llc_size && llc_nr_ways )
+    if ( (llc_coloring_enabled < 0) && (llc_size && llc_nr_ways) )
     {
         llc_coloring_enabled = true;
         way_size = llc_size / llc_nr_ways;

~Michal





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.