drivers/resctrl/test_mpam_devices.c
Source file repositories/reference/linux-study-clean/drivers/resctrl/test_mpam_devices.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/resctrl/test_mpam_devices.c- Extension
.c- Size
- 13619 bytes
- Lines
- 398
- Domain
- Driver Families
- Bucket
- drivers/resctrl
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- 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
kunit/test.h
Detected Declarations
function test__props_mismatchfunction reset_fake_hierarchyfunction test_mpam_enable_merge_featuresfunction __test_mpam_reset_msc_bitmapfunction test_mpam_reset_msc_bitmap
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2025 Arm Ltd.
/* This file is intended to be included into mpam_devices.c */
#include <kunit/test.h>
/*
* This test catches fields that aren't being sanitised - but can't tell you
* which one...
*/
static void test__props_mismatch(struct kunit *test)
{
struct mpam_props parent = { 0 };
struct mpam_props child;
memset(&child, 0xff, sizeof(child));
__props_mismatch(&parent, &child, false);
memset(&child, 0, sizeof(child));
KUNIT_EXPECT_EQ(test, memcmp(&parent, &child, sizeof(child)), 0);
memset(&child, 0xff, sizeof(child));
__props_mismatch(&parent, &child, true);
KUNIT_EXPECT_EQ(test, memcmp(&parent, &child, sizeof(child)), 0);
}
static struct list_head fake_classes_list;
static struct mpam_class fake_class = { 0 };
static struct mpam_component fake_comp1 = { 0 };
static struct mpam_component fake_comp2 = { 0 };
static struct mpam_vmsc fake_vmsc1 = { 0 };
static struct mpam_vmsc fake_vmsc2 = { 0 };
static struct mpam_msc fake_msc1 = { 0 };
static struct mpam_msc fake_msc2 = { 0 };
static struct mpam_msc_ris fake_ris1 = { 0 };
static struct mpam_msc_ris fake_ris2 = { 0 };
static struct platform_device fake_pdev = { 0 };
static inline void reset_fake_hierarchy(void)
{
INIT_LIST_HEAD(&fake_classes_list);
memset(&fake_class, 0, sizeof(fake_class));
fake_class.level = 3;
fake_class.type = MPAM_CLASS_CACHE;
INIT_LIST_HEAD_RCU(&fake_class.components);
INIT_LIST_HEAD(&fake_class.classes_list);
memset(&fake_comp1, 0, sizeof(fake_comp1));
memset(&fake_comp2, 0, sizeof(fake_comp2));
fake_comp1.comp_id = 1;
fake_comp2.comp_id = 2;
INIT_LIST_HEAD(&fake_comp1.vmsc);
INIT_LIST_HEAD(&fake_comp1.class_list);
INIT_LIST_HEAD(&fake_comp2.vmsc);
INIT_LIST_HEAD(&fake_comp2.class_list);
memset(&fake_vmsc1, 0, sizeof(fake_vmsc1));
memset(&fake_vmsc2, 0, sizeof(fake_vmsc2));
INIT_LIST_HEAD(&fake_vmsc1.ris);
INIT_LIST_HEAD(&fake_vmsc1.comp_list);
fake_vmsc1.msc = &fake_msc1;
INIT_LIST_HEAD(&fake_vmsc2.ris);
INIT_LIST_HEAD(&fake_vmsc2.comp_list);
fake_vmsc2.msc = &fake_msc2;
memset(&fake_ris1, 0, sizeof(fake_ris1));
memset(&fake_ris2, 0, sizeof(fake_ris2));
fake_ris1.ris_idx = 1;
INIT_LIST_HEAD(&fake_ris1.msc_list);
fake_ris2.ris_idx = 2;
INIT_LIST_HEAD(&fake_ris2.msc_list);
fake_msc1.pdev = &fake_pdev;
fake_msc2.pdev = &fake_pdev;
list_add(&fake_class.classes_list, &fake_classes_list);
}
static void test_mpam_enable_merge_features(struct kunit *test)
{
reset_fake_hierarchy();
mutex_lock(&mpam_list_lock);
/* One Class+Comp, two RIS in one vMSC with common features */
fake_comp1.class = &fake_class;
list_add(&fake_comp1.class_list, &fake_class.components);
fake_comp2.class = NULL;
Annotation
- Immediate include surface: `kunit/test.h`.
- Detected declarations: `function test__props_mismatch`, `function reset_fake_hierarchy`, `function test_mpam_enable_merge_features`, `function __test_mpam_reset_msc_bitmap`, `function test_mpam_reset_msc_bitmap`.
- Atlas domain: Driver Families / drivers/resctrl.
- 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.