Re: [PATCH] x86/mce: Dynamically size space for machine check records

Sohil Mehta
2024-02-29T00:39:48Z

On 2/28/2024 3:14 PM, Tony Luck wrote:

> static int mce_gen_pool_create(void)
> {
> + int mce_numrecords, mce_poolsz;
> struct gen_pool *tmpp;
> int ret = -ENOMEM;
> + void *mce_pool;
> + int order;
>
> - tmpp = gen_pool_create(ilog2(sizeof(struct mce_evt_llist)), -1);
> + order = ilog2(sizeof(struct mce_evt_llist)) + 1;
> + tmpp = gen_pool_create(order, -1);
> if (!tmpp)
> goto out;
>
> - ret = gen_pool_add(tmpp, (unsigned long)gen_pool_buf, MCE_POOLSZ, -1);
> + mce_numrecords = max(80, num_possible_cpus() * 4);
> + mce_poolsz = mce_numrecords * (1 << order);
> + mce_pool = kmalloc(mce_poolsz, GFP_KERNEL);
> + if (!mce_pool) {
> + gen_pool_destroy(tmpp);
> + goto out;
> + }
> + ret = gen_pool_add(tmpp, (unsigned long)mce_pool, mce_poolsz, -1);
> if (ret) {
> gen_pool_destroy(tmpp);

Is this missing a kfree(mce_pool) here?

> goto out;