Patch "x86/resctrl: Fix memory bandwidth counter width for AMD" has been added to the 5.7-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    x86/resctrl: Fix memory bandwidth counter width for AMD

to the 5.7-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     x86-resctrl-fix-memory-bandwidth-counter-width-for-a.patch
and it can be found in the queue-5.7 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 6058bc426003cfa269d35262ed5b0a00506c0104
Author: Babu Moger <babu.moger@xxxxxxx>
Date:   Thu Jun 4 14:45:16 2020 -0500

    x86/resctrl: Fix memory bandwidth counter width for AMD
    
    [ Upstream commit 2c18bd525c47f882f033b0a813ecd09c93e1ecdf ]
    
    Memory bandwidth is calculated reading the monitoring counter
    at two intervals and calculating the delta. It is the softwareâ??s
    responsibility to read the count often enough to avoid having
    the count roll over _twice_ between reads.
    
    The current code hardcodes the bandwidth monitoring counter's width
    to 24 bits for AMD. This is due to default base counter width which
    is 24. Currently, AMD does not implement the CPUID 0xF.[ECX=1]:EAX
    to adjust the counter width. But, the AMD hardware supports much
    wider bandwidth counter with the default width of 44 bits.
    
    Kernel reads these monitoring counters every 1 second and adjusts the
    counter value for overflow. With 24 bits and scale value of 64 for AMD,
    it can only measure up to 1GB/s without overflowing. For the rates
    above 1GB/s this will fail to measure the bandwidth.
    
    Fix the issue setting the default width to 44 bits by adjusting the
    offset.
    
    AMD future products will implement CPUID 0xF.[ECX=1]:EAX.
    
     [ bp: Let the line stick out and drop {}-brackets around a single
       statement. ]
    
    Fixes: 4d05bf71f157 ("x86/resctrl: Introduce AMD QOS feature")
    Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
    Signed-off-by: Borislav Petkov <bp@xxxxxxx>
    Link: https://lkml.kernel.org/r/159129975546.62538.5656031125604254041.stgit@xxxxxxxxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index d242e864726c0..c1551541c7a53 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -980,10 +980,10 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c)
 
 		c->x86_cache_max_rmid  = ecx;
 		c->x86_cache_occ_scale = ebx;
-		if (c->x86_vendor == X86_VENDOR_INTEL)
-			c->x86_cache_mbm_width_offset = eax & 0xff;
-		else
-			c->x86_cache_mbm_width_offset = -1;
+		c->x86_cache_mbm_width_offset = eax & 0xff;
+
+		if (c->x86_vendor == X86_VENDOR_AMD && !c->x86_cache_mbm_width_offset)
+			c->x86_cache_mbm_width_offset = MBM_CNTR_WIDTH_OFFSET_AMD;
 	}
 }
 
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 3dd13f3a8b231..0963864757143 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -37,6 +37,7 @@
 #define MBA_IS_LINEAR			0x4
 #define MBA_MAX_MBPS			U32_MAX
 #define MAX_MBA_BW_AMD			0x800
+#define MBM_CNTR_WIDTH_OFFSET_AMD	20
 
 #define RMID_VAL_ERROR			BIT_ULL(63)
 #define RMID_VAL_UNAVAIL		BIT_ULL(62)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux