Re: [PATCH v8 17/21] x86,fs/resctrl: Move the resctrl filesystem code to live in /fs/resctrl

Fenghua Yu
2025-04-15T00:27:48Z

Hi, James,

On 4/11/25 09:42, James Morse wrote:
> Resctrl is a filesystem interface to hardware that provides cache
> allocation policy and bandwidth control for groups of tasks or CPUs.
>
> To support more than one architecture, resctrl needs to live in /fs/.
>
> Move the code that is concerned with the filesystem interface to
> /fs/resctrl.
>
> Signed-off-by: James Morse <james.morse@arm.com>
> ---
> Changes since *:
> * This patch is generated by a script.
> ---
> arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 636 ---
> arch/x86/kernel/cpu/resctrl/internal.h | 380 +-
> arch/x86/kernel/cpu/resctrl/monitor.c | 902 +---
> arch/x86/kernel/cpu/resctrl/monitor_trace.h | 18 +-
> arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1080 +---
> .../kernel/cpu/resctrl/pseudo_lock_trace.h | 2 +
> arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4556 +----------------
> fs/resctrl/ctrlmondata.c | 660 +++
> fs/resctrl/internal.h | 442 ++
> fs/resctrl/monitor.c | 932 ++++
> fs/resctrl/monitor_trace.h | 33 +
> fs/resctrl/pseudo_lock.c | 1115 ++++
> fs/resctrl/pseudo_lock_trace.h | 17 +
> fs/resctrl/rdtgroup.c | 4313 ++++++++++++++++
> 14 files changed, 7668 insertions(+), 7418 deletions(-)

[SNIP]

> diff --git a/fs/resctrl/pseudo_lock.c b/fs/resctrl/pseudo_lock.c
> index e69de29bb2d1..29682dd46871 100644
> --- a/fs/resctrl/pseudo_lock.c
> +++ b/fs/resctrl/pseudo_lock.c
> @@ -0,0 +1,1115 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Resource Director Technology (RDT)
> + *
> + * Pseudo-locking support built on top of Cache Allocation Technology (CAT)
> + *
> + * Copyright (C) 2018 Intel Corporation
> + *
> + * Author: Reinette Chatre <reinette.chatre@intel.com>
> + */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include <linux/cacheflush.h>
> +#include <linux/cacheinfo.h>
> +#include <linux/cpu.h>
> +#include <linux/cpumask.h>
> +#include <linux/debugfs.h>
> +#include <linux/kthread.h>
> +#include <linux/mman.h>
> +#include <linux/perf_event.h>
> +#include <linux/pm_qos.h>
> +#include <linux/resctrl.h>
> +#include <linux/slab.h>
> +#include <linux/uaccess.h>
> +
> +#include <asm/cpu_device_id.h>
> +#include <asm/perf_event.h>
> +
> +#include "../../events/perf_event.h" /* For X86_CONFIG() */
> +#include "internal.h"
> +
> +#define CREATE_TRACE_POINTS
> +
> +#include "pseudo_lock_trace.h"

[SNIP]

> +}
> diff --git a/fs/resctrl/pseudo_lock_trace.h b/fs/resctrl/pseudo_lock_trace.h
> index e69de29bb2d1..7a6a1983953a 100644
> --- a/fs/resctrl/pseudo_lock_trace.h
> +++ b/fs/resctrl/pseudo_lock_trace.h
> @@ -0,0 +1,17 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#undef TRACE_SYSTEM
> +#define TRACE_SYSTEM resctrl
> +
> +#if !defined(_X86_RESCTRL_PSEUDO_LOCK_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
> +#define _X86_RESCTRL_PSEUDO_LOCK_TRACE_H
> +
> +#include <linux/tracepoint.h>
> +
> +#endif /* _X86_RESCTRL_PSEUDO_LOCK_TRACE_H */
> +
> +#undef TRACE_INCLUDE_PATH
> +#define TRACE_INCLUDE_PATH .
> +
> +#define TRACE_INCLUDE_FILE pseudo_lock_trace
> +
> +#include <trace/define_trace.h>

If applying patch 1-17, building the kernel reports this error, which
will cause bisect failure:

CC      fs/resctrl/pseudo_lock.o
In file included from fs/resctrl/pseudo_lock_trace.h:17,
from fs/resctrl/pseudo_lock.c:35:
./include/trace/define_trace.h:110:42: fatal error:
./pseudo_lock_trace.h: No such file or directory
110 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
|                                          ^
compilation terminated.
make[4]: *** [scripts/Makefile.build:203: fs/resctrl/pseudo_lock.o] Error 1

Again combining patch 18 with this patch together makes the error go away.

But you said combining them together may cause the conversion python
tool complex:
https://lore.kernel.org/lkml/97aeaf87-b2db-4efb-9d81-43769c6f27b0@arm.com/

Is there a better way to resolve this error? Maybe update the tool not
to generate or include fs/resctrl/pseudo_lock_trace.h at all?

[SNIP]

Thanks.

-Fenghua