All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roman Gushchin <roman.gushchin@linux.dev>
To: Shakeel Butt <shakeelb@google.com>
Cc: Yafang Shao <laoar.shao@gmail.com>,
	ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	kafai@fb.com, songliubraving@fb.com, yhs@fb.com,
	john.fastabend@gmail.com, kpsingh@kernel.org,
	quentin@isovalent.com, haoluo@google.com, bpf@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [PATCH bpf-next v2 1/2] bpf: Make non-preallocated allocation low priority
Date: Wed, 6 Jul 2022 17:25:00 -0700	[thread overview]
Message-ID: <YsYn3HoqQ4JtTaO6@castle> (raw)
In-Reply-To: <20220707000721.dtl356trspb23ctp@google.com>

On Thu, Jul 07, 2022 at 12:07:21AM +0000, Shakeel Butt wrote:
> On Wed, Jul 06, 2022 at 03:58:47PM +0000, Yafang Shao wrote:
> > GFP_ATOMIC doesn't cooperate well with memcg pressure so far, especially
> > if we allocate too much GFP_ATOMIC memory. For example, when we set the
> > memcg limit to limit a non-preallocated bpf memory, the GFP_ATOMIC can
> > easily break the memcg limit by force charge. So it is very dangerous to
> > use GFP_ATOMIC in non-preallocated case. One way to make it safe is to
> > remove __GFP_HIGH from GFP_ATOMIC, IOW, use (__GFP_ATOMIC |
> > __GFP_KSWAPD_RECLAIM) instead, then it will be limited if we allocate
> > too much memory.
> 
> Please use GFP_NOWAIT instead of (__GFP_ATOMIC | __GFP_KSWAPD_RECLAIM).
> There is already a plan to completely remove __GFP_ATOMIC and mm-tree
> already have a patch for that.

Oh, I didn't know this, thanks for heads up!
I agree that GFP_NOWAIT is the best choice then.

Btw, we probably shouldn't even add GFP_NOWAIT if the allocation is performed
from the bpf syscall context. Why would we fail to pre-allocate a map if
we can easily go into the reclaim? But probably better to leave it for
a separate change.

Thanks!

  parent reply	other threads:[~2022-07-07  0:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-06 15:58 [PATCH bpf-next v2 0/2] bpf: Minor fixes for non-preallocated memory Yafang Shao
2022-07-06 15:58 ` [PATCH bpf-next v2 1/2] bpf: Make non-preallocated allocation low priority Yafang Shao
2022-07-06 16:47   ` Alexei Starovoitov
2022-07-06 19:09     ` Roman Gushchin
2022-07-06 22:11       ` Alexei Starovoitov
2022-07-06 22:54         ` Roman Gushchin
2022-07-06 23:22           ` Alexei Starovoitov
2022-07-07  0:07   ` Shakeel Butt
2022-07-07  0:14     ` Alexei Starovoitov
2022-07-07  0:25     ` Roman Gushchin [this message]
2022-07-07  2:09       ` Alexei Starovoitov
2022-07-07  3:36         ` Roman Gushchin
2022-07-07 10:27     ` Yafang Shao
2022-07-07 15:44       ` Alexei Starovoitov
2022-07-07 16:19         ` Yafang Shao
2022-07-06 15:58 ` [PATCH bpf-next v2 2/2] bpf: Warn on non-preallocated case for missed trace types Yafang Shao
2022-07-06 16:50   ` Alexei Starovoitov
2022-07-07 10:29     ` Yafang Shao
2022-07-07 15:45       ` Alexei Starovoitov
2022-07-07 16:22         ` Yafang Shao

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=YsYn3HoqQ4JtTaO6@castle \
    --to=roman.gushchin@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=laoar.shao@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=quentin@isovalent.com \
    --cc=shakeelb@google.com \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.