linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Axel Rasmussen <axelrasmussen@google.com>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: bpf <bpf@vger.kernel.org>, linux-mm <linux-mm@kvack.org>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Nicolas Saenz Julienne <nsaenzju@redhat.com>,
	 LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm: mmap_lock: replace get_memcg_path_buf() with on-stack buffer
Date: Thu, 27 Jun 2024 14:41:53 -0700	[thread overview]
Message-ID: <CAJHvVcgMd9=oXwB_cnyP2_aBKAXSx4+PDryLPn=R_-b6LeGehw@mail.gmail.com> (raw)
In-Reply-To: <1a48d05c-539b-4d5d-9375-f2aaa5fa0dd4@I-love.SAKURA.ne.jp>

On Fri, Jun 21, 2024 at 10:57 PM Tetsuo Handa
<penguin-kernel@i-love.sakura.ne.jp> wrote:
>
> On 2024/06/22 8:03, Axel Rasmussen wrote:
> > No objections. Looking back all the way to the first version [1] the
> > buffers were already percpu, instead of on the stack like this. IOW,
> > there was no on-list discussion about why this shouldn't go on the
> > stack. It has been a while, but if memory serves I opted to do it that
> > way just out of paranoia around putting large buffers on the stack.
> > But, I agree 256 bytes isn't all that large.
> >
> > That v1 patch wasn't all that complex, but then again it didn't deal
> > with various edge cases properly :) so it has grown significantly more
> > complex over time. Reconsidering the approach seems reasonable now,
> > given how much code this removes.
> >
> > This change looks straightforwardly correct to me. You can take:
> >
> > Reviewed-by: Axel Rasmussen <axelrasmussen@google.com>
>
> Thank you. One question. CONTEXT_COUNT was defined as below.
>
> >> -/*
> >> - * How many contexts our trace events might be called in: normal, softirq, irq,
> >> - * and NMI.
> >> - */
> >> -#define CONTEXT_COUNT 4
>
> Is there possibility that this function (or in general, trace events) is called from NMI
> context? If yes, I worry that functions called from get_mm_memcg_path() are not NMI-safe.
> Original change at
> https://lkml.kernel.org/r/3e9b2a54-73d4-48cb-a510-d17984c97a45@I-love.SAKURA.ne.jp was
> posted due to worrying about NMI safety.

I think it's unlikely, but I'm not certain. Although trace events *in
general* can be called from NMI context.

This code was added based on the discussion here [1] from v4 of this
patchset. At the time I don't think we had any certainty that this
*was* called from NMI context, but rather just that if CONTEXT_COUNT
was 4 when it only had to be 3 in practice, it wasn't a huge deal, but
getting it wrong the other way would be much worse.

[1]: https://lore.kernel.org/r/20201020184746.300555-2-axelrasmussen@google.com

>


      reply	other threads:[~2024-06-27 21:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-21  1:08 Tetsuo Handa
2024-06-21 23:03 ` Axel Rasmussen
2024-06-22  5:57   ` Tetsuo Handa
2024-06-27 21:41     ` Axel Rasmussen [this message]

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='CAJHvVcgMd9=oXwB_cnyP2_aBKAXSx4+PDryLPn=R_-b6LeGehw@mail.gmail.com' \
    --to=axelrasmussen@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=bpf@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nsaenzju@redhat.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    /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