lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aC5s0CQMHeud3LDa@hyeyoo>
Date: Thu, 22 May 2025 09:16:16 +0900
From: Harry Yoo <harry.yoo@...cle.com>
To: Usama Arif <usamaarif642@...il.com>
Cc: Shakeel Butt <shakeel.butt@...ux.dev>, surenb@...gle.com,
        Andrew Morton <akpm@...ux-foundation.org>, hannes@...xchg.org,
        vlad.wing@...il.com, linux-mm@...ck.org, kent.overstreet@...ux.dev,
        linux-kernel@...r.kernel.org, kernel-team@...a.com, vbabka@...e.cz,
        cl@...two.org, rientjes@...gle.com, roman.gushchin@...ux.dev
Subject: Re: [PATCH 2/2] mm: slub: only warn once when allocating slab obj
 extensions fails

On Tue, May 20, 2025 at 04:22:16PM +0100, Usama Arif wrote:
> 
> 
> On 20/05/2025 15:18, Shakeel Butt wrote:
> > On Tue, May 20, 2025 at 02:42:09PM +0100, Usama Arif wrote:
> >>
> >>
> >> On 20/05/2025 14:34, Harry Yoo wrote:
> >>> On Tue, May 20, 2025 at 01:25:47PM +0100, Usama Arif wrote:
> >>>> In memory bound systems, a large number of warnings for failing this
> >>>> allocation repeatedly may mask any real issues in the system
> >>>> during memory pressure being reported in dmesg. Change this to
> >>>> WARN_ONCE.
> >>>>
> >>>> Signed-off-by: Usama Arif <usamaarif642@...il.com>
> >>>> Reported-by: Vlad Poenaru <vlad.wing@...il.com>
> >>>> Closes: https://lore.kernel.org/all/17fab2d6-5a74-4573-bcc3-b75951508f0a@gmail.com/
> >>>> ---
> >>>
> >>> Hi,
> >>>
> >>> Please Cc SLAB ALLOCATOR folks in MAINTAINERS on patches that touch
> >>> slab code ;)
> >>>
> >>
> >> Thanks for adding them to CC! I was just thinking of this as a memory
> >> allocation profiling issue and added the maintainers for it,
> >> but should have added slab maintainers as well.
> >>
> >>
> >>>>  mm/slub.c | 2 +-
> >>>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>>
> >>>> diff --git a/mm/slub.c b/mm/slub.c
> >>>> index bf43c403ead2..97cb3d9e8d00 100644
> >>>> --- a/mm/slub.c
> >>>> +++ b/mm/slub.c
> >>>> @@ -2102,7 +2102,7 @@ prepare_slab_obj_exts_hook(struct kmem_cache *s, gfp_t flags, void *p)
> >>>>  
> >>>>  	slab = virt_to_slab(p);
> >>>>  	if (!slab_obj_exts(slab) &&
> >>>> -	    WARN(alloc_slab_obj_exts(slab, s, flags, false),
> >>>> +	    WARN_ONCE(alloc_slab_obj_exts(slab, s, flags, false),
> >>>>  		 "%s, %s: Failed to create slab extension vector!\n",
> >>>>  		 __func__, s->name))
> >>>
> >>> I think this should be pr_warn_once()?
> >>> I'm not sure why this was WARN() in the first place.
> >>>
> >>
> >> Isn't WARN_ONCE the same as pr_warn_once but with needing the condition
> >> of the first arg to be true? We only want to warn if alloc_slab_obj_exts
> >> returns non-zero. So WARN_ONCE should be ok?
> >>
> > 
> > The difference is the impact on panic_on_warn users which are mostly
> > testing bots. This warning is not actionable, so I agree with Harry to
> > covert this to pr_warn_once().
> > 
> 
> Sounds good! Will change it to below for the next revision.
> Will wait for the kvmalloc conversation to conclude before sending
> the next revision.
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index 08804d2f2ead..ab0b7ee87159 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -2101,11 +2101,13 @@ prepare_slab_obj_exts_hook(struct kmem_cache *s, gfp_t flags, void *p)
>                 return NULL;
>  
>         slab = virt_to_slab(p);
> -       if (!slab_obj_exts(slab) &&
> -           WARN(alloc_slab_obj_exts(slab, s, flags, false),
> -                "%s, %s: Failed to create slab extension vector!\n",
> -                __func__, s->name))
> -               return NULL;
> +       if (!slab_obj_exts(slab)) {
> +               if(alloc_slab_obj_exts(slab, s, flags, false))
> +                       pr_warn_once("%s, %s: Failed to create slab extension vector!\n",
> +                               __func__, s->name);
> +               else
> +                       return NULL;

Returning NULL when alloc_slab_obj_exts() succeeds doesn't make sense.
I think you meant something like this?

if (!slab_obj_exts(slab) &&
    alloc_slab_obj_exts(slab, s, flags, false)) {
	pr_warn_once("%s, %s: Failed to create slab extension vector!\n",
		__func__, s->name);
	return NULL;
}

> +       }
>  
>         return slab_obj_exts(slab) + obj_to_index(s, slab, p);
>  }
> 

-- 
Cheers,
Harry / Hyeonggon

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ