linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Potapenko <glider@google.com>
To: Muchun Song <muchun.song@linux.dev>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Marco Elver <elver@google.com>,
	 Roman Gushchin <roman.gushchin@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	 Linux-MM <linux-mm@kvack.org>,
	Naresh Kamboju <naresh.kamboju@linaro.org>
Subject: Re: [PATCH 6.4 000/292] 6.4.5-rc1 review
Date: Wed, 26 Jul 2023 18:52:31 +0200	[thread overview]
Message-ID: <CAG_fn=UhA_g60eGFJDkg_z0qJWapOf8eyjZAG74_SBtRm3Nmcg@mail.gmail.com> (raw)
In-Reply-To: <CAG_fn=WtW1-azL+qGiRnskDdr2xrZBJB11goQJgv3+GBdz+x0A@mail.gmail.com>

On Tue, Jul 25, 2023 at 6:21 PM Alexander Potapenko <glider@google.com> wrote:
>
> On Tue, Jul 25, 2023 at 3:39 PM Naresh Kamboju
> <naresh.kamboju@linaro.org> wrote:
> >
> > On Tue, 25 Jul 2023 at 17:22, Alexander Potapenko <glider@google.com> wrote:
> > >
> > > On Tue, Jul 25, 2023 at 11:59 AM Alexander Potapenko <glider@google.com> wrote:
> > > >
> > > > On Mon, Jul 24, 2023 at 2:10 PM Naresh Kamboju
> > > > <naresh.kamboju@linaro.org> wrote:
> > > > >
> > > > > On Mon, 24 Jul 2023 at 15:50, Alexander Potapenko <glider@google.com> wrote:
> > > > > >
> > > > > > On Sat, Jul 22, 2023 at 6:37 PM Linus Torvalds
> > > > > > <torvalds@linux-foundation.org> wrote:
> > > > > > >
> > > > > > > [ Removed the stable reviewers, bringing in the kfence people ]
> > > > > > >
> > > > > > > See
> > > > > > >
> > > > > > >   https://lore.kernel.org/lkml/CA+G9fYvgy22wiY=c3wLOrCM6o33636abhtEynXhJkqxJh4ca0A@mail.gmail.com/
> > > > > > >
> > > > > > > for the original report. The warning was introduced in 8f0b36497303
> > > > > > > ("mm: kfence: fix objcgs vector allocation"), and Google doesn't find
> > > > > > > any other cases of this.
> > > > > > >
> > > > > > > Anybody?
> > > > > > >
> > > > > > >                     Linus
> > > > > > >
> > > > > >
>
> Muchun, any chance you know under what circumstances a KFENCE object
> has its meta->objcg set to a non-NULL value?
> It seems to be a quite rare case, and I've only seen it in live
> radix_tree_node objects.
> Since the check here:
> https://elixir.bootlin.com/linux/latest/source/mm/kfence/core.c#L1097
> ensures that this value is NULL when the object is freed, where is the
> code that is supposed to zero it?
> Could there be a race somewhere?


I am still puzzled about what is going on.

As far as I can see, when KFENCE pool is initialized, for ith object
page in the pool its page_slab()->memcg_data is set to a value derived
from kfence_metadata[i].objcg
Because KFENCE objects always occupy one page, no two objects are
expected to share memcg_data at any time.

When slab_alloc_node() is called, it first invokes
slab_pre_alloc_hook(), figures out the obj_cgroup and charges it for
the allocated memory. The obj_cgroup is returned to slab_alloc_node()
and after KFENCE allocation succeeds is passed to
slab_post_alloc_hook(), which then writes obj_cgroup to
*(page_slab(object)->memcg_data).

When an object is deallocated, slab_free() calls
memcg_slab_free_hook(), which zeroes *(page_slab(object)->memcg_data)
and passes the object to kfence_free().
At this point the object's meta->objcg must be NULL, so the warning
should not be firing.



--
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Paul Manicle, Liana Sebastian
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg


  reply	other threads:[~2023-07-26 16:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230721160528.800311148@linuxfoundation.org>
     [not found] ` <CA+G9fYvgy22wiY=c3wLOrCM6o33636abhtEynXhJkqxJh4ca0A@mail.gmail.com>
2023-07-22 16:36   ` Linus Torvalds
2023-07-24 10:19     ` Alexander Potapenko
2023-07-24 12:10       ` Naresh Kamboju
2023-07-25  9:13         ` Naresh Kamboju
2023-07-25  9:59         ` Alexander Potapenko
2023-07-25 11:52           ` Alexander Potapenko
2023-07-25 13:39             ` Naresh Kamboju
2023-07-25 16:21               ` Alexander Potapenko
2023-07-26 16:52                 ` Alexander Potapenko [this message]
2023-07-27  7:02                   ` Muchun Song
2023-07-27  7:26                     ` Muchun Song
2023-07-25 13:36           ` Naresh Kamboju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAG_fn=UhA_g60eGFJDkg_z0qJWapOf8eyjZAG74_SBtRm3Nmcg@mail.gmail.com' \
    --to=glider@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=elver@google.com \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    --cc=naresh.kamboju@linaro.org \
    --cc=roman.gushchin@linux.dev \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox