Skip to content

Commit 931be44

Browse files
hfxspbp3tk0v
authored andcommitted
x86/resctrl: Add tracepoint for llc_occupancy tracking
In our production environment, after removing monitor groups, those unused RMIDs get stuck in the limbo list forever because their llc_occupancy is always larger than the threshold. But the unused RMIDs can be successfully freed by turning up the threshold. In order to know how much the threshold should be, perf can be used to acquire the llc_occupancy of RMIDs in each rdt domain. Instead of using perf tool to track llc_occupancy and filter the log manually, it is more convenient for users to use tracepoint to do this work. So add a new tracepoint that shows the llc_occupancy of busy RMIDs when scanning the limbo list. Suggested-by: Reinette Chatre <reinette.chatre@intel.com> Suggested-by: James Morse <james.morse@arm.com> Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: James Morse <james.morse@arm.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Link: https://lore.kernel.org/r/20240408092303.26413-3-haifeng.xu@shopee.com
1 parent 8773922 commit 931be44

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Documentation/arch/x86/resctrl.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,12 @@ during mkdir.
446446
max_threshold_occupancy is a user configurable value to determine the
447447
occupancy at which an RMID can be freed.
448448

449+
The mon_llc_occupancy_limbo tracepoint gives the precise occupancy in bytes
450+
for a subset of RMID that are not immediately available for allocation.
451+
This can't be relied on to produce output every second, it may be necessary
452+
to attempt to create an empty monitor group to force an update. Output may
453+
only be produced if creation of a control or monitor group fails.
454+
449455
Schemata files - general concepts
450456
---------------------------------
451457
Each line in the file describes one resource. The line starts with

arch/x86/kernel/cpu/resctrl/monitor.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <asm/resctrl.h>
2525

2626
#include "internal.h"
27+
#include "trace.h"
2728

2829
/**
2930
* struct rmid_entry - dirty tracking for all RMID.
@@ -354,6 +355,16 @@ void __check_limbo(struct rdt_domain *d, bool force_free)
354355
rmid_dirty = true;
355356
} else {
356357
rmid_dirty = (val >= resctrl_rmid_realloc_threshold);
358+
359+
/*
360+
* x86's CLOSID and RMID are independent numbers, so the entry's
361+
* CLOSID is an empty CLOSID (X86_RESCTRL_EMPTY_CLOSID). On Arm the
362+
* RMID (PMG) extends the CLOSID (PARTID) space with bits that aren't
363+
* used to select the configuration. It is thus necessary to track both
364+
* CLOSID and RMID because there may be dependencies between them
365+
* on some architectures.
366+
*/
367+
trace_mon_llc_occupancy_limbo(entry->closid, entry->rmid, d->id, val);
357368
}
358369

359370
if (force_free || !rmid_dirty) {

arch/x86/kernel/cpu/resctrl/trace.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ TRACE_EVENT(pseudo_lock_l3,
3535
TP_printk("hits=%llu miss=%llu",
3636
__entry->l3_hits, __entry->l3_miss));
3737

38+
TRACE_EVENT(mon_llc_occupancy_limbo,
39+
TP_PROTO(u32 ctrl_hw_id, u32 mon_hw_id, int domain_id, u64 llc_occupancy_bytes),
40+
TP_ARGS(ctrl_hw_id, mon_hw_id, domain_id, llc_occupancy_bytes),
41+
TP_STRUCT__entry(__field(u32, ctrl_hw_id)
42+
__field(u32, mon_hw_id)
43+
__field(int, domain_id)
44+
__field(u64, llc_occupancy_bytes)),
45+
TP_fast_assign(__entry->ctrl_hw_id = ctrl_hw_id;
46+
__entry->mon_hw_id = mon_hw_id;
47+
__entry->domain_id = domain_id;
48+
__entry->llc_occupancy_bytes = llc_occupancy_bytes;),
49+
TP_printk("ctrl_hw_id=%u mon_hw_id=%u domain_id=%d llc_occupancy_bytes=%llu",
50+
__entry->ctrl_hw_id, __entry->mon_hw_id, __entry->domain_id,
51+
__entry->llc_occupancy_bytes)
52+
);
53+
3854
#endif /* _TRACE_RESCTRL_H */
3955

4056
#undef TRACE_INCLUDE_PATH

0 commit comments

Comments
 (0)