RE: [PATCH v2 2/2] kfence: allow change number of object by early parameter
From: yuanlinyu
Date: Sun Dec 28 2025 - 23:20:09 EST
> From: Marco Elver <elver@xxxxxxxxxx>
> Sent: Thursday, December 18, 2025 6:24 PM
> To: yuanlinyu <yuanlinyu@xxxxxxxxx>
> Cc: Alexander Potapenko <glider@xxxxxxxxxx>; Dmitry Vyukov
> <dvyukov@xxxxxxxxxx>; Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>;
> Huacai Chen <chenhuacai@xxxxxxxxxx>; WANG Xuerui <kernel@xxxxxxxxxx>;
> kasan-dev@xxxxxxxxxxxxxxxx; linux-mm@xxxxxxxxx; loongarch@xxxxxxxxxxxxxxx;
> linux-kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH v2 2/2] kfence: allow change number of object by early
> parameter
> > Could you share the better design idea ?
>
> Hot-patchable constants, similar to static branches/jump labels. This
> had been discussed in the past (can't find the link now), but it's not
> trivial to implement unfortunately.
>
Hi Marco,
If you have concern about one more global,
how about below code ?
/* The pool of pages used for guard pages and objects with number of objects at lower bits . */
unsigned long __kfence_pool_objects __read_mostly;
static __always_inline bool is_kfence_address(const void *addr)
{
return unlikely((unsigned long)((char *)addr - KFENCE_POOL_ADDR) < KFENCE_POOL_LEN && __kfence_pool_objects);
}
It may generate one or two more instruction when compare with original patch.