Re: [patch v2 19/38] x86/cpu: Provide debug interface
From: Sohil Mehta
Date: Fri Jul 28 2023 - 19:58:08 EST
> +++ b/arch/x86/kernel/cpu/debugfs.c
> @@ -0,0 +1,58 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <linux/debugfs.h>
> +
> +#include <asm/apic.h>
> +#include <asm/processor.h>
> +
I ran checkpatch through the patches and it lists a bunch of errors and
warnings. Most of them are due to issues in the existing code which is
probably not worth fixing.
However, I found a couple of recommendations which might be of interest.
1) Using linux headers instead of the asm ones. Namely,
> Consider using #include <linux/processor.h> instead of <asm/processor.h>
> Consider using #include <linux/topology.h> instead of <asm/topology.h>
> Consider using #include <linux/smp.h> instead of <asm/smp.h>
2) Macros with multiple statements should be enclosed in a do - while loop
>From patch 20/38:
> +#define cpuid_subleaf(leaf, subleaf, regs) \
> + BUILD_BUG_ON(sizeof(*(regs)) != 16); \
> + __cpuid_read(leaf, subleaf, (u32 *)(regs))
I am wondering if either of them matter?
> +static __init int cpu_init_debugfs(void)
> +{
> + struct dentry *dir, *base = debugfs_create_dir("topo", arch_debugfs_dir);
> + unsigned long id;
> + char name [10];
> +
Excess space after name and before the square bracket can be avoided.
Sohil