lkml.org 
[lkml]   [2020]   [Aug]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag
On Sun 09-08-20 22:43:53, Uladzislau Rezki (Sony) wrote:
[...]
> Limitations and concerns (Main part)
> ====================================
> The current memmory-allocation interface presents to following
> difficulties that this patch is designed to overcome:
>
> a) If built with CONFIG_PROVE_RAW_LOCK_NESTING, the lockdep will
> complain about violation("BUG: Invalid wait context") of the
> nesting rules. It does the raw_spinlock vs. spinlock nesting
> checks, i.e. it is not legal to acquire a spinlock_t while
> holding a raw_spinlock_t.
>
> Internally the kfree_rcu() uses raw_spinlock_t(in rcu-dev branch)
> whereas the "page allocator" internally deals with spinlock_t to
> access to its zones. The code also can be broken from higher level
> of view:
> <snip>
> raw_spin_lock(&some_lock);
> kfree_rcu(some_pointer, some_field_offset);
> <snip>

Is there any fundamental problem to make zone raw_spin_lock?

> b) If built with CONFIG_PREEMPT_RT. Please note, in that case spinlock_t
> is converted into sleepable variant. Invoking the page allocator from
> atomic contexts leads to "BUG: scheduling while atomic".

[...]

> Proposal
> ========
> 1) Make GFP_* that ensures that the allocator returns NULL rather
> than acquire its own spinlock_t. Having such flag will address a and b
> limitations described above. It will also make the kfree_rcu() code
> common for RT and regular kernel, more clean, less handling corner
> cases and reduce the code size.

I do not think this is a good idea. Single purpose gfp flags that tend
to heavily depend on the current implementation of the page allocator
have turned out to be problematic. Users used to misunderstand their
meaning resulting in a lot of abuse which was not trivial to remove.
This flag seem to fall into exactly this sort of category. If there is a
problem in nesting then that should be addressed rather than a new flag
exported IMHO. If that is absolutely not possible for some reason then
we can try to figure out what to do but that really need a very strong
justification.

--
Michal Hocko
SUSE Labs

\
 
 \ /
  Last update: 2020-08-10 14:32    [W:0.163 / U:0.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site