Re: [PATCH bpf-next v2 1/2] bpf: Make non-preallocated allocation low priority

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 7, 2022 at 11:44 PM Alexei Starovoitov
<alexei.starovoitov@xxxxxxxxx> wrote:
>
> On Thu, Jul 7, 2022 at 3:28 AM Yafang Shao <laoar.shao@xxxxxxxxx> wrote:
> >
> > On Thu, Jul 7, 2022 at 8:07 AM Shakeel Butt <shakeelb@xxxxxxxxxx> 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.
> > >
> >
> > After reading the discussion[1], it looks good to me to use GFP_NOWAIT
> > instead. I will update it.
>
> Should we use GFP_ATOMIC | __GFP_NOMEMALLOC instead
> to align with its usage in the networking stack?

GFP_ATOMIC | __GFP_NOMEMALLOC will continue to break the memcg limit,
so we have to modify the try_charge_memcg() code to make sure
__GFP_NOMEMALLOC takes precedence over the __GFP_HIGH flag, IOW, if
both of them are set we won't allow it to break memcg limit.  That
will need more verification.

-- 
Regards
Yafang




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux