Re: [RFC PATCH v2 11/14] x86/watchdog/hardlockup: Add an HPET-based hardlockup detector

From: Peter Zijlstra
Date: Tue Apr 09 2019 - 07:03:57 EST


On Wed, Feb 27, 2019 at 08:05:15AM -0800, Ricardo Neri wrote:
> diff --git a/arch/x86/include/asm/hpet.h b/arch/x86/include/asm/hpet.h
> index 4d559e0c746f..15dc3b576496 100644
> --- a/arch/x86/include/asm/hpet.h
> +++ b/arch/x86/include/asm/hpet.h
> @@ -123,12 +123,24 @@ struct hpet_hld_data {
> u32 num;
> u32 flags;
> u64 ticks_per_second;
> + u32 handling_cpu;
> + struct cpumask cpu_monitored_mask;
> + struct msi_msg msi_msg;
> };

Please don't use struct cpumask unless you absolutely have to.

The above is better written as:


struct hpet_hld_data {
...
unsigned long cpumask[0];
};

and allocated using:

struct hpet_hld_data *hhd = kzalloc(sizeof(struct hpet_hld_data) + cpumask_size());

and used as:

to_cpumask(hhd->cpumask);