Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-19 Thread Paul E. McKenney
On Wed, Aug 19, 2020 at 01:26:02AM +0200, Thomas Gleixner wrote: > Paul, > > On Tue, Aug 18 2020 at 10:13, Paul E. McKenney wrote: > > On Tue, Aug 18, 2020 at 06:55:11PM +0200, Thomas Gleixner wrote: > >> On Tue, Aug 18 2020 at 09:13, Paul E. McKenney wrote: > >> > On Tue, Aug 18, 2020 at 04:43:14

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-18 Thread Thomas Gleixner
Paul, On Tue, Aug 18 2020 at 10:13, Paul E. McKenney wrote: > On Tue, Aug 18, 2020 at 06:55:11PM +0200, Thomas Gleixner wrote: >> On Tue, Aug 18 2020 at 09:13, Paul E. McKenney wrote: >> > On Tue, Aug 18, 2020 at 04:43:14PM +0200, Thomas Gleixner wrote: >> >> Throttling the flooder is incresing ro

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-18 Thread Paul E. McKenney
On Tue, Aug 18, 2020 at 06:55:11PM +0200, Thomas Gleixner wrote: > On Tue, Aug 18 2020 at 09:13, Paul E. McKenney wrote: > > On Tue, Aug 18, 2020 at 04:43:14PM +0200, Thomas Gleixner wrote: > >> On Tue, Aug 18 2020 at 06:53, Paul E. McKenney wrote: > >> > On Tue, Aug 18, 2020 at 09:43:44AM +0200, M

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-18 Thread Thomas Gleixner
On Tue, Aug 18 2020 at 09:13, Paul E. McKenney wrote: > On Tue, Aug 18, 2020 at 04:43:14PM +0200, Thomas Gleixner wrote: >> On Tue, Aug 18 2020 at 06:53, Paul E. McKenney wrote: >> > On Tue, Aug 18, 2020 at 09:43:44AM +0200, Michal Hocko wrote: >> >> Thomas had a good point that it doesn't really m

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-18 Thread Paul E. McKenney
On Tue, Aug 18, 2020 at 05:02:32PM +0200, Michal Hocko wrote: > On Tue 18-08-20 06:53:27, Paul E. McKenney wrote: > > On Tue, Aug 18, 2020 at 09:43:44AM +0200, Michal Hocko wrote: > > > On Mon 17-08-20 15:28:03, Paul E. McKenney wrote: > > > > On Mon, Aug 17, 2020 at 10:28:49AM +0200, Michal Hocko

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-18 Thread Paul E. McKenney
On Tue, Aug 18, 2020 at 04:43:14PM +0200, Thomas Gleixner wrote: > On Tue, Aug 18 2020 at 06:53, Paul E. McKenney wrote: > > On Tue, Aug 18, 2020 at 09:43:44AM +0200, Michal Hocko wrote: > >> Thomas had a good point that it doesn't really make much sense to > >> optimize for flooders because that j

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-18 Thread Uladzislau Rezki
Hello, Michal. You mentioned somewhere in the thread to show figures regarding hitting a fast path and "fallback one". We follow fallback when a page allocation fails. Please see below the plot. I hope it is easy to understand: wget ftp://vps418301.ovh.net/incoming/100_kfree_rcu_fast_hit_vs

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-18 Thread Michal Hocko
On Tue 18-08-20 06:53:27, Paul E. McKenney wrote: > On Tue, Aug 18, 2020 at 09:43:44AM +0200, Michal Hocko wrote: > > On Mon 17-08-20 15:28:03, Paul E. McKenney wrote: > > > On Mon, Aug 17, 2020 at 10:28:49AM +0200, Michal Hocko wrote: > > > > On Mon 17-08-20 00:56:55, Uladzislau Rezki wrote: > > >

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-18 Thread Thomas Gleixner
On Tue, Aug 18 2020 at 06:53, Paul E. McKenney wrote: > On Tue, Aug 18, 2020 at 09:43:44AM +0200, Michal Hocko wrote: >> Thomas had a good point that it doesn't really make much sense to >> optimize for flooders because that just makes them more effective. > > The point is not to make the flooders

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-18 Thread Paul E. McKenney
On Tue, Aug 18, 2020 at 09:43:44AM +0200, Michal Hocko wrote: > On Mon 17-08-20 15:28:03, Paul E. McKenney wrote: > > On Mon, Aug 17, 2020 at 10:28:49AM +0200, Michal Hocko wrote: > > > On Mon 17-08-20 00:56:55, Uladzislau Rezki wrote: > > > > [ . . . ] > > > > > > wget > > > > ftp://vps418301.o

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-18 Thread Michal Hocko
On Mon 17-08-20 15:28:03, Paul E. McKenney wrote: > On Mon, Aug 17, 2020 at 10:28:49AM +0200, Michal Hocko wrote: > > On Mon 17-08-20 00:56:55, Uladzislau Rezki wrote: > > [ . . . ] > > > > wget > > > ftp://vps418301.ovh.net/incoming/100_kmalloc_kfree_rcu_proc_percpu_pagelist_fractio_is_8.pn

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-17 Thread Paul E. McKenney
On Mon, Aug 17, 2020 at 10:28:49AM +0200, Michal Hocko wrote: > On Mon 17-08-20 00:56:55, Uladzislau Rezki wrote: [ . . . ] > > wget > > ftp://vps418301.ovh.net/incoming/100_kmalloc_kfree_rcu_proc_percpu_pagelist_fractio_is_8.png > > 1/8 of the memory in pcp lists is quite large and likely

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-17 Thread Uladzislau Rezki
On Mon, Aug 17, 2020 at 10:28:49AM +0200, Michal Hocko wrote: > On Mon 17-08-20 00:56:55, Uladzislau Rezki wrote: > [...] > > Michal asked to provide some data regarding how many pages we need and how > > "lockless allocation" behaves when it comes to success vs failed scenarios. > > > > Please se

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-17 Thread Michal Hocko
On Sat 15-08-20 01:14:53, Thomas Gleixner wrote: [...] > For normal operations a couple of pages which can be preallocated are > enough. What you are concerned of is the case where you run out of > pointer storage space. > > There are two reasons why that can happen: > > 1) RCU call floodin

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-17 Thread Michal Hocko
On Mon 17-08-20 00:56:55, Uladzislau Rezki wrote: [...] > Michal asked to provide some data regarding how many pages we need and how > "lockless allocation" behaves when it comes to success vs failed scenarios. > > Please see below some results. The test case is a tight loop of 1 000 000 > alloca

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-16 Thread Uladzislau Rezki
On Fri, Aug 14, 2020 at 11:52:06PM +0200, Peter Zijlstra wrote: > On Fri, Aug 14, 2020 at 01:41:40PM -0700, Paul E. McKenney wrote: > > > And that enforces the GFP_NOLOCK allocation mode or some other solution > > > unless you make a new rule that calling call_rcu() is forbidden while > > > holding

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-15 Thread Paul E. McKenney
On Sat, Aug 15, 2020 at 10:27:54AM +0200, Peter Zijlstra wrote: > On Sat, Aug 15, 2020 at 01:14:53AM +0200, Thomas Gleixner wrote: > > > > As a matter of fact I assume^Wdeclare that removing struct rcu_head which > > provides a fallback is not an option at all. I know that you want to, > > but it

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-15 Thread Paul E. McKenney
On Sat, Aug 15, 2020 at 07:18:39AM -0700, Paul E. McKenney wrote: > On Sat, Aug 15, 2020 at 10:42:50AM +0200, Peter Zijlstra wrote: > > On Sat, Aug 15, 2020 at 01:14:53AM +0200, Thomas Gleixner wrote: > > > > > #1 trivial fix is to force switching to an high prio thread or a soft > > >interrup

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-15 Thread Paul E. McKenney
On Sat, Aug 15, 2020 at 10:42:50AM +0200, Peter Zijlstra wrote: > On Sat, Aug 15, 2020 at 01:14:53AM +0200, Thomas Gleixner wrote: > > > #1 trivial fix is to force switching to an high prio thread or a soft > >interrupt which does the allocation > > Yeah, push the alocation out to another con

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-15 Thread Paul E. McKenney
On Sat, Aug 15, 2020 at 02:43:51AM +0200, Thomas Gleixner wrote: > Paul, > > On Fri, Aug 14 2020 at 16:41, Paul E. McKenney wrote: > > On Sat, Aug 15, 2020 at 01:14:53AM +0200, Thomas Gleixner wrote: > >> As a matter of fact I assume^Wdeclare that removing struct rcu_head which > >> provides a fal

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-15 Thread Peter Zijlstra
On Sat, Aug 15, 2020 at 01:14:53AM +0200, Thomas Gleixner wrote: > > As a matter of fact I assume^Wdeclare that removing struct rcu_head which > provides a fallback is not an option at all. I know that you want to, > but it wont work ever. Dream on, but as we agreed on recently there is > this thi

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-15 Thread Thomas Gleixner
Paul, On Fri, Aug 14 2020 at 16:41, Paul E. McKenney wrote: > On Sat, Aug 15, 2020 at 01:14:53AM +0200, Thomas Gleixner wrote: >> As a matter of fact I assume^Wdeclare that removing struct rcu_head which >> provides a fallback is not an option at all. I know that you want to, >> but it wont work e

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-15 Thread Peter Zijlstra
On Sat, Aug 15, 2020 at 01:14:53AM +0200, Thomas Gleixner wrote: > #1 trivial fix is to force switching to an high prio thread or a soft >interrupt which does the allocation Yeah, push the alocation out to another context. I did consider it, but why bother? Also, raising a softirq can't be d

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Paul E. McKenney
On Sat, Aug 15, 2020 at 01:14:53AM +0200, Thomas Gleixner wrote: > Paul, > > On Fri, Aug 14 2020 at 11:01, Paul E. McKenney wrote: > > On Fri, Aug 14, 2020 at 04:06:04PM +0200, Michal Hocko wrote: > >> > > > Vlastimil raised same question earlier, i answered, but let me > >> > > > answer again: >

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Thomas Gleixner
On Fri, Aug 14 2020 at 23:52, Peter Zijlstra wrote: > On Fri, Aug 14, 2020 at 01:41:40PM -0700, Paul E. McKenney wrote: >> > And that enforces the GFP_NOLOCK allocation mode or some other solution >> > unless you make a new rule that calling call_rcu() is forbidden while >> > holding zone lock or a

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Paul E. McKenney
On Fri, Aug 14, 2020 at 11:52:06PM +0200, Peter Zijlstra wrote: > On Fri, Aug 14, 2020 at 01:41:40PM -0700, Paul E. McKenney wrote: > > > And that enforces the GFP_NOLOCK allocation mode or some other solution > > > unless you make a new rule that calling call_rcu() is forbidden while > > > holding

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Thomas Gleixner
Paul, On Fri, Aug 14 2020 at 11:01, Paul E. McKenney wrote: > On Fri, Aug 14, 2020 at 04:06:04PM +0200, Michal Hocko wrote: >> > > > Vlastimil raised same question earlier, i answered, but let me answer >> > > > again: >> > > > >> > > > It is hard to achieve because the logic does not stick to c

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Peter Zijlstra
On Fri, Aug 14, 2020 at 01:41:40PM -0700, Paul E. McKenney wrote: > > And that enforces the GFP_NOLOCK allocation mode or some other solution > > unless you make a new rule that calling call_rcu() is forbidden while > > holding zone lock or any other lock which might be nested inside the > > GFP_NO

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Paul E. McKenney
On Fri, Aug 14, 2020 at 09:33:47PM +0200, Thomas Gleixner wrote: > On Fri, Aug 14 2020 at 11:02, Paul E. McKenney wrote: > > On Fri, Aug 14, 2020 at 07:49:24PM +0200, Peter Zijlstra wrote: > >> On Fri, Aug 14, 2020 at 09:11:06AM -0700, Paul E. McKenney wrote: > >> > Just to make sure we are talking

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Thomas Gleixner
On Fri, Aug 14 2020 at 11:02, Paul E. McKenney wrote: > On Fri, Aug 14, 2020 at 07:49:24PM +0200, Peter Zijlstra wrote: >> On Fri, Aug 14, 2020 at 09:11:06AM -0700, Paul E. McKenney wrote: >> > Just to make sure we are talking about the same thing, please see below >> > for an untested patch that i

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Paul E. McKenney
On Fri, Aug 14, 2020 at 06:19:04PM +0200, pet...@infradead.org wrote: > On Fri, Aug 14, 2020 at 07:14:25AM -0700, Paul E. McKenney wrote: > > > Doing this to kfree_rcu() is the first step. We will also be doing this > > to call_rcu(), which has some long-standing invocations from various > > raw

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Paul E. McKenney
On Fri, Aug 14, 2020 at 07:49:24PM +0200, Peter Zijlstra wrote: > On Fri, Aug 14, 2020 at 09:11:06AM -0700, Paul E. McKenney wrote: > > Just to make sure we are talking about the same thing, please see below > > for an untested patch that illustrates how I was interpreting your words. > > Was this

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Paul E. McKenney
On Fri, Aug 14, 2020 at 04:06:04PM +0200, Michal Hocko wrote: > On Fri 14-08-20 06:34:50, Paul E. McKenney wrote: > > On Fri, Aug 14, 2020 at 02:48:32PM +0200, Michal Hocko wrote: > > > On Fri 14-08-20 14:15:44, Uladzislau Rezki wrote: > > > > > On Thu 13-08-20 19:09:29, Thomas Gleixner wrote: > >

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Peter Zijlstra
On Fri, Aug 14, 2020 at 09:11:06AM -0700, Paul E. McKenney wrote: > Just to make sure we are talking about the same thing, please see below > for an untested patch that illustrates how I was interpreting your words. > Was this what you had in mind? No, definitely not. Also, since we used to be ab

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread peterz
On Fri, Aug 14, 2020 at 07:14:25AM -0700, Paul E. McKenney wrote: > Doing this to kfree_rcu() is the first step. We will also be doing this > to call_rcu(), which has some long-standing invocations from various > raw contexts, including hardirq handler. Most hardirq handler are not raw on RT due

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Paul E. McKenney
On Fri, Aug 14, 2020 at 07:14:25AM -0700, Paul E. McKenney wrote: > On Fri, Aug 14, 2020 at 10:30:37AM +0200, Peter Zijlstra wrote: > > On Fri, Aug 14, 2020 at 01:59:04AM +0200, Thomas Gleixner wrote: [ . . . ] > > > > 3. Reusing existing GFP_ flags/values/whatever to communicate > > > > the

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Paul E. McKenney
On Fri, Aug 14, 2020 at 12:23:06PM +0200, pet...@infradead.org wrote: > On Fri, Aug 14, 2020 at 10:30:37AM +0200, Peter Zijlstra wrote: > > > > 1. Prohibit invoking allocators from raw atomic context, such > > > > as when holding a raw spinlock. > > > > > > Clearly the simplest solution but

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Paul E. McKenney
On Fri, Aug 14, 2020 at 10:30:37AM +0200, Peter Zijlstra wrote: > On Fri, Aug 14, 2020 at 01:59:04AM +0200, Thomas Gleixner wrote: > > On Fri, Aug 14 2020 at 00:06, peterz wrote: > > > I'm still not getting it, how do we end up trying to allocate memory > > > from under raw spinlocks if you're not

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Michal Hocko
On Fri 14-08-20 06:34:50, Paul E. McKenney wrote: > On Fri, Aug 14, 2020 at 02:48:32PM +0200, Michal Hocko wrote: > > On Fri 14-08-20 14:15:44, Uladzislau Rezki wrote: > > > > On Thu 13-08-20 19:09:29, Thomas Gleixner wrote: > > > > > Michal Hocko writes: > > > > [...] > > > > > > Why should we li

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Paul E. McKenney
On Fri, Aug 14, 2020 at 02:48:32PM +0200, Michal Hocko wrote: > On Fri 14-08-20 14:15:44, Uladzislau Rezki wrote: > > > On Thu 13-08-20 19:09:29, Thomas Gleixner wrote: > > > > Michal Hocko writes: > > > [...] > > > > > Why should we limit the functionality of the allocator for something > > > > >

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Michal Hocko
On Fri 14-08-20 14:15:44, Uladzislau Rezki wrote: > > On Thu 13-08-20 19:09:29, Thomas Gleixner wrote: > > > Michal Hocko writes: > > [...] > > > > Why should we limit the functionality of the allocator for something > > > > that is not a real problem? > > > > > > We'd limit the allocator for exa

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Uladzislau Rezki
> On Thu 13-08-20 19:09:29, Thomas Gleixner wrote: > > Michal Hocko writes: > [...] > > > Why should we limit the functionality of the allocator for something > > > that is not a real problem? > > > > We'd limit the allocator for exactly ONE new user which was aware of > > this problem _before_ t

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Uladzislau Rezki
On Thu, Aug 13, 2020 at 06:36:17PM +0200, Michal Hocko wrote: > On Thu 13-08-20 18:20:47, Uladzislau Rezki wrote: > > > On Thu 13-08-20 08:41:59, Paul E. McKenney wrote: > > > > On Thu, Aug 13, 2020 at 04:53:35PM +0200, Michal Hocko wrote: > > > > > On Thu 13-08-20 16:34:57, Thomas Gleixner wrote:

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread peterz
On Fri, Aug 14, 2020 at 10:30:37AM +0200, Peter Zijlstra wrote: > > > 1.Prohibit invoking allocators from raw atomic context, such > > > as when holding a raw spinlock. > > > > Clearly the simplest solution but not Pauls favourite and > > unfortunately he has a good reason. > > Whic

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Peter Zijlstra
On Fri, Aug 14, 2020 at 01:59:04AM +0200, Thomas Gleixner wrote: > On Fri, Aug 14 2020 at 00:06, peterz wrote: > > I'm still not getting it, how do we end up trying to allocate memory > > from under raw spinlocks if you're not allowed to use kfree_rcu() under > > one ? > > > > Can someone please sp

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-14 Thread Michal Hocko
On Thu 13-08-20 19:09:29, Thomas Gleixner wrote: > Michal Hocko writes: [...] > > Why should we limit the functionality of the allocator for something > > that is not a real problem? > > We'd limit the allocator for exactly ONE new user which was aware of > this problem _before_ the code hit main

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Thomas Gleixner
On Fri, Aug 14 2020 at 00:06, peterz wrote: > I'm still not getting it, how do we end up trying to allocate memory > from under raw spinlocks if you're not allowed to use kfree_rcu() under > one ? > > Can someone please spell out the actual problem? Your actual problem is the heat wave. Get an ice

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Paul E. McKenney
On Fri, Aug 14, 2020 at 12:06:19AM +0200, pet...@infradead.org wrote: > On Thu, Aug 13, 2020 at 11:52:57AM -0700, Paul E. McKenney wrote: > > On Thu, Aug 13, 2020 at 08:26:18PM +0200, pet...@infradead.org wrote: > > > > I thought the rule was: > > > > > > - No allocators (alloc/free) inside raw_

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread peterz
On Thu, Aug 13, 2020 at 11:52:57AM -0700, Paul E. McKenney wrote: > On Thu, Aug 13, 2020 at 08:26:18PM +0200, pet...@infradead.org wrote: > > I thought the rule was: > > > > - No allocators (alloc/free) inside raw_spinlock_t, full-stop. > > > > Why are we trying to craft an exception? > > So t

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Michal Hocko
On Thu 13-08-20 20:31:21, Peter Zijlstra wrote: > On Thu, Aug 13, 2020 at 09:29:04AM -0700, Paul E. McKenney wrote: [...] > > 3. Reusing existing GFP_ flags/values/whatever to communicate > > the raw-context information that was to be communicated by > > the new GFP_ flag. > > > > 4. Mak

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Paul E. McKenney
On Thu, Aug 13, 2020 at 08:26:18PM +0200, pet...@infradead.org wrote: > On Thu, Aug 13, 2020 at 04:34:57PM +0200, Thomas Gleixner wrote: > > Michal Hocko writes: > > > On Thu 13-08-20 15:22:00, Thomas Gleixner wrote: > > >> It basically requires to convert the wait queue to something else. Is > >

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread peterz
On Thu, Aug 13, 2020 at 09:29:04AM -0700, Paul E. McKenney wrote: > OK. So the current situation requires a choice between these these > alternatives, each of which has shortcomings that have been mentioned > earlier in this thread: > > 1.Prohibit invoking allocators from raw atomic context,

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread peterz
On Thu, Aug 13, 2020 at 04:34:57PM +0200, Thomas Gleixner wrote: > Michal Hocko writes: > > On Thu 13-08-20 15:22:00, Thomas Gleixner wrote: > >> It basically requires to convert the wait queue to something else. Is > >> the waitqueue strict single waiter? > > > > I would have to double check. Fro

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Paul E. McKenney
On Thu, Aug 13, 2020 at 07:12:11PM +0200, Michal Hocko wrote: > On Thu 13-08-20 09:29:04, Paul E. McKenney wrote: > > On Thu, Aug 13, 2020 at 06:13:57PM +0200, Michal Hocko wrote: > > > On Thu 13-08-20 09:04:42, Paul E. McKenney wrote: > > > > On Thu, Aug 13, 2020 at 05:54:12PM +0200, Michal Hocko

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Michal Hocko
On Thu 13-08-20 19:09:29, Thomas Gleixner wrote: > Michal Hocko writes: > > On Thu 13-08-20 16:34:57, Thomas Gleixner wrote: [...] I will go though the rest of the email tomorrow. > >> Really, if your primary lockless caches are empty then any allocation > >> which comes from deep atomic context

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Michal Hocko
On Thu 13-08-20 09:29:04, Paul E. McKenney wrote: > On Thu, Aug 13, 2020 at 06:13:57PM +0200, Michal Hocko wrote: > > On Thu 13-08-20 09:04:42, Paul E. McKenney wrote: > > > On Thu, Aug 13, 2020 at 05:54:12PM +0200, Michal Hocko wrote: > > [...] > > > > If the whole bailout is guarded by CONFIG_PRE

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Thomas Gleixner
Michal Hocko writes: > On Thu 13-08-20 16:34:57, Thomas Gleixner wrote: >> Michal Hocko writes: >> > Yes, that would have to somehow need to annotate the zone_lock to be ok >> > in those paths so that lockdep doesn't complain. >> >> That opens the worst of all cans of worms. If we start this her

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Michal Hocko
On Thu 13-08-20 18:20:47, Uladzislau Rezki wrote: > > On Thu 13-08-20 08:41:59, Paul E. McKenney wrote: > > > On Thu, Aug 13, 2020 at 04:53:35PM +0200, Michal Hocko wrote: > > > > On Thu 13-08-20 16:34:57, Thomas Gleixner wrote: > > > > > Michal Hocko writes: > > > > > > On Thu 13-08-20 15:22:00,

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Paul E. McKenney
On Thu, Aug 13, 2020 at 06:13:57PM +0200, Michal Hocko wrote: > On Thu 13-08-20 09:04:42, Paul E. McKenney wrote: > > On Thu, Aug 13, 2020 at 05:54:12PM +0200, Michal Hocko wrote: > [...] > > > If the whole bailout is guarded by CONFIG_PREEMPT_RT specific atomicity > > > check then there is no func

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Matthew Wilcox
On Thu, Aug 13, 2020 at 06:14:32PM +0200, Thomas Gleixner wrote: > Matthew Wilcox writes: > > On Thu, Aug 13, 2020 at 03:27:15PM +0200, Thomas Gleixner wrote: > >> And guarding it with RT is not working either because then you are back > >> to square one with the problem which triggered the discus

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Uladzislau Rezki
> On Thu 13-08-20 08:41:59, Paul E. McKenney wrote: > > On Thu, Aug 13, 2020 at 04:53:35PM +0200, Michal Hocko wrote: > > > On Thu 13-08-20 16:34:57, Thomas Gleixner wrote: > > > > Michal Hocko writes: > > > > > On Thu 13-08-20 15:22:00, Thomas Gleixner wrote: > > > > >> It basically requires to c

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Thomas Gleixner
Matthew Wilcox writes: > On Thu, Aug 13, 2020 at 03:27:15PM +0200, Thomas Gleixner wrote: >> And guarding it with RT is not working either because then you are back >> to square one with the problem which triggered the discussion in the >> first place: >> >> raw_spin_lock() >> alloc() >> if

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Michal Hocko
On Thu 13-08-20 09:04:42, Paul E. McKenney wrote: > On Thu, Aug 13, 2020 at 05:54:12PM +0200, Michal Hocko wrote: [...] > > If the whole bailout is guarded by CONFIG_PREEMPT_RT specific atomicity > > check then there is no functional problem - GFP_RT_SAFE would still be > > GFP_NOWAIT so functional

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Paul E. McKenney
On Thu, Aug 13, 2020 at 05:54:12PM +0200, Michal Hocko wrote: > On Thu 13-08-20 08:41:59, Paul E. McKenney wrote: > > On Thu, Aug 13, 2020 at 04:53:35PM +0200, Michal Hocko wrote: > > > On Thu 13-08-20 16:34:57, Thomas Gleixner wrote: > > > > Michal Hocko writes: > > > > > On Thu 13-08-20 15:22:00

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Michal Hocko
On Thu 13-08-20 08:41:59, Paul E. McKenney wrote: > On Thu, Aug 13, 2020 at 04:53:35PM +0200, Michal Hocko wrote: > > On Thu 13-08-20 16:34:57, Thomas Gleixner wrote: > > > Michal Hocko writes: > > > > On Thu 13-08-20 15:22:00, Thomas Gleixner wrote: > > > >> It basically requires to convert the w

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Paul E. McKenney
On Thu, Aug 13, 2020 at 04:53:35PM +0200, Michal Hocko wrote: > On Thu 13-08-20 16:34:57, Thomas Gleixner wrote: > > Michal Hocko writes: > > > On Thu 13-08-20 15:22:00, Thomas Gleixner wrote: > > >> It basically requires to convert the wait queue to something else. Is > > >> the waitqueue strict

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Michal Hocko
On Thu 13-08-20 16:34:57, Thomas Gleixner wrote: > Michal Hocko writes: > > On Thu 13-08-20 15:22:00, Thomas Gleixner wrote: > >> It basically requires to convert the wait queue to something else. Is > >> the waitqueue strict single waiter? > > > > I would have to double check. From what I remembe

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Thomas Gleixner
Michal Hocko writes: > On Thu 13-08-20 15:22:00, Thomas Gleixner wrote: >> It basically requires to convert the wait queue to something else. Is >> the waitqueue strict single waiter? > > I would have to double check. From what I remember only kswapd should > ever sleep on it. That would make it

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Matthew Wilcox
On Thu, Aug 13, 2020 at 03:27:15PM +0200, Thomas Gleixner wrote: > And guarding it with RT is not working either because then you are back > to square one with the problem which triggered the discussion in the > first place: > > raw_spin_lock() > alloc() > if (RT && !preemptible()) <- False

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Uladzislau Rezki
On Thu, Aug 13, 2020 at 03:41:39PM +0200, Michal Hocko wrote: > On Thu 13-08-20 15:29:31, Uladzislau Rezki wrote: > [...] > > I was a bit out of focus and did not mention about one thing. Identifying > > the context > > type using preemtable() primitives looks a bit not suitable, IMHO. GFP_* > >

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Michal Hocko
On Thu 13-08-20 15:27:15, Thomas Gleixner wrote: > Michal Hocko writes: > > On Thu 13-08-20 11:58:40, Uladzislau Rezki wrote: > > [...] > >> Sorry for jumping in. We can rely on preemptable() for sure, if > >> CONFIG_PREEMPT_RT > >> is enabled, something like below: > >> > >> if (IS_ENABLED_RT &

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Michal Hocko
On Thu 13-08-20 15:29:31, Uladzislau Rezki wrote: [...] > I was a bit out of focus and did not mention about one thing. Identifying the > context > type using preemtable() primitives looks a bit not suitable, IMHO. GFP_* > flags are > not supposed to identify a context type, because it is not pos

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Michal Hocko
On Thu 13-08-20 15:22:00, Thomas Gleixner wrote: > Uladzislau Rezki writes: > > On Thu, Aug 13, 2020 at 09:50:27AM +0200, Michal Hocko wrote: > >> On Wed 12-08-20 02:13:25, Thomas Gleixner wrote: > >> [...] > >> > I can understand your rationale and what you are trying to solve. So, if > >> > we c

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Uladzislau Rezki
Hello, Michal. > > On Wed 12-08-20 02:13:25, Thomas Gleixner wrote: > > [...] > > > I can understand your rationale and what you are trying to solve. So, if > > > we can actually have a distinct GFP variant: > > > > > > GFP_I_ABSOLUTELY_HAVE_TO_DO_THAT_AND_I_KNOW_IT_CAN_FAIL_EARLY > > > > Even

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Thomas Gleixner
Michal Hocko writes: > On Thu 13-08-20 11:58:40, Uladzislau Rezki wrote: > [...] >> Sorry for jumping in. We can rely on preemptable() for sure, if >> CONFIG_PREEMPT_RT >> is enabled, something like below: >> >> if (IS_ENABLED_RT && preemptebale()) > > Sure. I thought this was an RT specific thi

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Thomas Gleixner
Uladzislau Rezki writes: > On Thu, Aug 13, 2020 at 09:50:27AM +0200, Michal Hocko wrote: >> On Wed 12-08-20 02:13:25, Thomas Gleixner wrote: >> [...] >> > I can understand your rationale and what you are trying to solve. So, if >> > we can actually have a distinct GFP variant: >> > >> > GFP_I_A

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Michal Hocko
On Thu 13-08-20 11:58:40, Uladzislau Rezki wrote: [...] > Sorry for jumping in. We can rely on preemptable() for sure, if > CONFIG_PREEMPT_RT > is enabled, something like below: > > if (IS_ENABLED_RT && preemptebale()) Sure. I thought this was an RT specific thing that would be noop otherwise.

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Uladzislau Rezki
On Thu, Aug 13, 2020 at 09:50:27AM +0200, Michal Hocko wrote: > On Wed 12-08-20 02:13:25, Thomas Gleixner wrote: > [...] > > I can understand your rationale and what you are trying to solve. So, if > > we can actually have a distinct GFP variant: > > > > GFP_I_ABSOLUTELY_HAVE_TO_DO_THAT_AND_I_KN

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Michal Hocko
On Wed 12-08-20 02:13:25, Thomas Gleixner wrote: [...] > I can understand your rationale and what you are trying to solve. So, if > we can actually have a distinct GFP variant: > > GFP_I_ABSOLUTELY_HAVE_TO_DO_THAT_AND_I_KNOW_IT_CAN_FAIL_EARLY Even if we cannot make the zone->lock raw I would pr

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-13 Thread Michal Hocko
On Wed 12-08-20 13:38:35, Thomas Gleixner wrote: > Thomas Gleixner writes: > > Thomas Gleixner writes: > >> Michal Hocko writes: > >>> zone->lock should be held for a very limited amount of time. > >> > >> Emphasis on should. free_pcppages_bulk() can hold it for quite some time > >> when a large

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-12 Thread Paul E. McKenney
On Wed, Aug 12, 2020 at 10:32:50AM +0200, Thomas Gleixner wrote: > Paul, > > "Paul E. McKenney" writes: > > On Wed, Aug 12, 2020 at 02:13:25AM +0200, Thomas Gleixner wrote: > >> That much I understood, but I somehow failed to figure the why out > >> despite the elaborate changelog. 2 weeks of 30+

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-12 Thread Uladzislau Rezki
On Wed, Aug 12, 2020 at 01:38:35PM +0200, Thomas Gleixner wrote: > Thomas Gleixner writes: > > Thomas Gleixner writes: > >> Michal Hocko writes: > >>> zone->lock should be held for a very limited amount of time. > >> > >> Emphasis on should. free_pcppages_bulk() can hold it for quite some time >

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-12 Thread Thomas Gleixner
Thomas Gleixner writes: > Thomas Gleixner writes: >> Michal Hocko writes: >>> zone->lock should be held for a very limited amount of time. >> >> Emphasis on should. free_pcppages_bulk() can hold it for quite some time >> when a large amount of pages are purged. We surely would have converted >>

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-12 Thread Thomas Gleixner
Paul, "Paul E. McKenney" writes: > On Wed, Aug 12, 2020 at 02:13:25AM +0200, Thomas Gleixner wrote: >> That much I understood, but I somehow failed to figure the why out >> despite the elaborate changelog. 2 weeks of 30+C seem to have cooked my >> brain :) > > Ouch!!! And what on earth is German

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-11 Thread Paul E. McKenney
On Wed, Aug 12, 2020 at 02:13:25AM +0200, Thomas Gleixner wrote: > "Paul E. McKenney" writes: > > Hence Ulad's work on kfree_rcu(). The approach is to allocate a > > page-sized array to hold all the pointers, then fill in the rest of these > > pointers on each subsequent kfree_rcu() call. These

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-11 Thread Thomas Gleixner
"Paul E. McKenney" writes: > Hence Ulad's work on kfree_rcu(). The approach is to allocate a > page-sized array to hold all the pointers, then fill in the rest of these > pointers on each subsequent kfree_rcu() call. These arrays of pointers > also allows use of kfree_bulk() instead of kfree(),

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-11 Thread Paul E. McKenney
On Tue, Aug 11, 2020 at 09:39:10PM +0200, Thomas Gleixner wrote: > Thomas Gleixner writes: > > "Paul E. McKenney" writes: > >> On Tue, Aug 11, 2020 at 04:44:21PM +0200, Thomas Gleixner wrote: > >>> Now RCU creates a new thing which enforces to make page allocation in > >>> atomic context possible

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-11 Thread Thomas Gleixner
Thomas Gleixner writes: > "Paul E. McKenney" writes: >> On Tue, Aug 11, 2020 at 04:44:21PM +0200, Thomas Gleixner wrote: >>> Now RCU creates a new thing which enforces to make page allocation in >>> atomic context possible on RT. What for? >>> >>> What's the actual use case in truly atomic conte

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-11 Thread Paul E. McKenney
On Tue, Aug 11, 2020 at 09:02:40AM -0700, Paul E. McKenney wrote: > On Tue, Aug 11, 2020 at 05:43:16PM +0200, Thomas Gleixner wrote: > > "Paul E. McKenney" writes: > > > On Tue, Aug 11, 2020 at 04:44:21PM +0200, Thomas Gleixner wrote: > > >> Now RCU creates a new thing which enforces to make page

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-11 Thread Paul E. McKenney
On Tue, Aug 11, 2020 at 05:43:16PM +0200, Thomas Gleixner wrote: > "Paul E. McKenney" writes: > > On Tue, Aug 11, 2020 at 04:44:21PM +0200, Thomas Gleixner wrote: > >> Now RCU creates a new thing which enforces to make page allocation in > >> atomic context possible on RT. What for? > >> > >> Wha

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-11 Thread Sebastian Andrzej Siewior
On 2020-08-11 17:43:16 [+0200], Thomas Gleixner wrote: > Where? See commit 8ac88f7177c75 ("rcu/tree: Keep kfree_rcu() awake during lock contention") Sebastian

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-11 Thread Thomas Gleixner
"Paul E. McKenney" writes: > On Tue, Aug 11, 2020 at 04:44:21PM +0200, Thomas Gleixner wrote: >> Now RCU creates a new thing which enforces to make page allocation in >> atomic context possible on RT. What for? >> >> What's the actual use case in truly atomic context for this new thing on >> an R

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-11 Thread Paul E. McKenney
On Tue, Aug 11, 2020 at 04:44:21PM +0200, Thomas Gleixner wrote: > Michal Hocko writes: > > On Mon 10-08-20 18:07:39, Uladzislau Rezki wrote: > >> > On Sun 09-08-20 22:43:53, Uladzislau Rezki (Sony) wrote: > >> > Is there any fundamental problem to make zone raw_spin_lock? > >> > > >> Good point.

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-11 Thread Thomas Gleixner
Thomas Gleixner writes: > Michal Hocko writes: >> zone->lock should be held for a very limited amount of time. > > Emphasis on should. free_pcppages_bulk() can hold it for quite some time > when a large amount of pages are purged. We surely would have converted > it to a raw lock long time ago ot

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-11 Thread Thomas Gleixner
Michal Hocko writes: > On Mon 10-08-20 18:07:39, Uladzislau Rezki wrote: >> > On Sun 09-08-20 22:43:53, Uladzislau Rezki (Sony) wrote: >> > Is there any fundamental problem to make zone raw_spin_lock? >> > >> Good point. Converting a regular spinlock to the raw_* variant can solve >> an issue an

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-11 Thread Uladzislau Rezki
On Tue, Aug 11, 2020 at 12:26:49PM +0200, Michal Hocko wrote: > On Tue 11-08-20 11:37:13, Uladzislau Rezki wrote: > > On Tue, Aug 11, 2020 at 10:19:17AM +0200, Michal Hocko wrote: > > > On Mon 10-08-20 21:25:26, Michal Hocko wrote: > > > > On Mon 10-08-20 18:07:39, Uladzislau Rezki wrote: > > > [..

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-11 Thread Uladzislau Rezki
On Tue, Aug 11, 2020 at 12:21:24PM +0200, Michal Hocko wrote: > On Tue 11-08-20 11:18:07, Uladzislau Rezki wrote: > > On Mon, Aug 10, 2020 at 09:25:25PM +0200, Michal Hocko wrote: > > > On Mon 10-08-20 18:07:39, Uladzislau Rezki wrote: > > > > > On Sun 09-08-20 22:43:53, Uladzislau Rezki (Sony) wro

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-11 Thread Uladzislau Rezki
On Tue, Aug 11, 2020 at 12:28:18PM +0200, Michal Hocko wrote: > On Tue 11-08-20 11:42:51, Uladzislau Rezki wrote: > > On Tue, Aug 11, 2020 at 11:37:13AM +0200, Uladzislau Rezki wrote: > > > On Tue, Aug 11, 2020 at 10:19:17AM +0200, Michal Hocko wrote: > [...] > > > > Anyway, if the zone->lock is no

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-11 Thread Michal Hocko
On Tue 11-08-20 11:42:51, Uladzislau Rezki wrote: > On Tue, Aug 11, 2020 at 11:37:13AM +0200, Uladzislau Rezki wrote: > > On Tue, Aug 11, 2020 at 10:19:17AM +0200, Michal Hocko wrote: [...] > > > Anyway, if the zone->lock is not a good fit for raw_spin_lock then the > > > only way I can see forward

Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag

2020-08-11 Thread Michal Hocko
On Tue 11-08-20 11:37:13, Uladzislau Rezki wrote: > On Tue, Aug 11, 2020 at 10:19:17AM +0200, Michal Hocko wrote: > > On Mon 10-08-20 21:25:26, Michal Hocko wrote: > > > On Mon 10-08-20 18:07:39, Uladzislau Rezki wrote: > > [...] > > > > The problem that i see is we can not use the page allocator f

  1   2   >