fs/resctrl/monitor.c
Source file repositories/reference/linux-study-clean/fs/resctrl/monitor.c
File Facts
- System
- Linux kernel
- Corpus path
fs/resctrl/monitor.c- Extension
.c- Size
- 53067 bytes
- Lines
- 1922
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cpu.hlinux/resctrl.hlinux/sizes.hlinux/slab.hinternal.hmonitor_trace.h
Detected Declarations
struct rmid_entrystruct mbm_transactionfunction limbo_release_entryfunction __check_limbofunction has_busy_rmidfunction list_for_each_entryfunction resctrl_find_cleanest_closidfunction alloc_rmidfunction add_rmid_to_limbofunction free_rmidfunction mbm_cntr_getfunction mbm_cntr_allocfunction mbm_cntr_freefunction __l3_mon_event_countfunction __l3_mon_event_count_sumfunction __mon_event_countfunction mbm_bw_countfunction mon_event_readfunction list_for_each_entryfunction controllerfunction mbm_update_one_eventfunction mbm_updatefunction cqm_handle_limbofunction cqm_setup_limbo_handlerfunction mbm_handle_overflowfunction list_for_each_entryfunction mbm_setup_overflow_handlerfunction setup_rmid_lru_listfunction free_rmid_lru_listfunction resctrl_enable_mon_eventfunction resctrl_is_mon_event_enabledfunction resctrl_get_mon_evt_cfgfunction event_filter_showfunction resctrl_mbm_assign_on_mkdir_showfunction resctrl_mbm_assign_on_mkdir_writefunction mbm_cntr_free_allfunction resctrl_reset_rmid_allfunction for_each_mbm_event_idfunction rdtgroup_assign_cntrfunction rdtgroup_alloc_assign_cntrfunction rdtgroup_assign_cntr_eventfunction rdtgroup_assign_cntrsfunction rdtgroup_free_unassign_cntrfunction rdtgroup_unassign_cntr_eventfunction rdtgroup_unassign_cntrsfunction resctrl_parse_mem_transactionsfunction rdtgroup_update_cntr_eventfunction list_for_each_entry
Annotated Snippet
struct rmid_entry {
u32 closid;
u32 rmid;
int busy;
struct list_head list;
};
/*
* @rmid_free_lru - A least recently used list of free RMIDs
* These RMIDs are guaranteed to have an occupancy less than the
* threshold occupancy
*/
static LIST_HEAD(rmid_free_lru);
/*
* @closid_num_dirty_rmid The number of dirty RMID each CLOSID has.
* Only allocated when CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID is defined.
* Indexed by CLOSID. Protected by rdtgroup_mutex.
*/
static u32 *closid_num_dirty_rmid;
/*
* @rmid_limbo_count - count of currently unused but (potentially)
* dirty RMIDs.
* This counts RMIDs that no one is currently using but that
* may have a occupancy value > resctrl_rmid_realloc_threshold. User can
* change the threshold occupancy value.
*/
static unsigned int rmid_limbo_count;
/*
* @rmid_entry - The entry in the limbo and free lists.
*/
static struct rmid_entry *rmid_ptrs;
/*
* This is the threshold cache occupancy in bytes at which we will consider an
* RMID available for re-allocation.
*/
unsigned int resctrl_rmid_realloc_threshold;
/*
* This is the maximum value for the reallocation threshold, in bytes.
*/
unsigned int resctrl_rmid_realloc_limit;
/*
* x86 and arm64 differ in their handling of monitoring.
* x86's RMID are independent numbers, there is only one source of traffic
* with an RMID value of '1'.
* arm64's PMG extends the PARTID/CLOSID space, there are multiple sources of
* traffic with a PMG value of '1', one for each CLOSID, meaning the RMID
* value is no longer unique.
* To account for this, resctrl uses an index. On x86 this is just the RMID,
* on arm64 it encodes the CLOSID and RMID. This gives a unique number.
*
* The domain's rmid_busy_llc and rmid_ptrs[] are sized by index. The arch code
* must accept an attempt to read every index.
*/
static inline struct rmid_entry *__rmid_entry(u32 idx)
{
struct rmid_entry *entry;
u32 closid, rmid;
entry = &rmid_ptrs[idx];
resctrl_arch_rmid_idx_decode(idx, &closid, &rmid);
WARN_ON_ONCE(entry->closid != closid);
WARN_ON_ONCE(entry->rmid != rmid);
return entry;
}
static void limbo_release_entry(struct rmid_entry *entry)
{
lockdep_assert_held(&rdtgroup_mutex);
rmid_limbo_count--;
list_add_tail(&entry->list, &rmid_free_lru);
if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID))
closid_num_dirty_rmid[entry->closid]--;
}
/*
* Check the RMIDs that are marked as busy for this domain. If the
* reported LLC occupancy is below the threshold clear the busy bit and
* decrement the count. If the busy count gets to zero on an RMID, we
* free the RMID
*/
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/resctrl.h`, `linux/sizes.h`, `linux/slab.h`, `internal.h`, `monitor_trace.h`.
- Detected declarations: `struct rmid_entry`, `struct mbm_transaction`, `function limbo_release_entry`, `function __check_limbo`, `function has_busy_rmid`, `function list_for_each_entry`, `function resctrl_find_cleanest_closid`, `function alloc_rmid`, `function add_rmid_to_limbo`, `function free_rmid`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.