Re: [PATCH v1 02/25] mm/swap: Don't abuse the seqcount latching API

2020-05-25 Thread John Ogness
Hi, This optimization is broken. The main concern here: Is it possible that lru_add_drain_all() _would_ have drained pagevec X, but then aborted because another lru_add_drain_all() is underway and that other task will _not_ drain pagevec X? I claim the answer is yes! My suggested changes are inli

Re: [PATCH v1 02/25] mm/swap: Don't abuse the seqcount latching API

2020-05-25 Thread Peter Zijlstra
On Mon, May 25, 2020 at 05:24:01PM +0200, Ahmed S. Darwish wrote: > Peter Zijlstra wrote: > > On Tue, May 19, 2020 at 11:45:24PM +0200, Ahmed S. Darwish wrote: > > > + WRITE_ONCE(lru_drain_gen, lru_drain_gen + 1); > > > + smp_wmb(); > > > > You can leave this smp_wmb() out and rely on the smp_mb(

Re: [PATCH v1 02/25] mm/swap: Don't abuse the seqcount latching API

2020-05-25 Thread Ahmed S. Darwish
Peter Zijlstra wrote: > On Tue, May 19, 2020 at 11:45:24PM +0200, Ahmed S. Darwish wrote: > > @@ -713,10 +713,20 @@ static void lru_add_drain_per_cpu(struct work_struct > > *dummy) > > */ > > void lru_add_drain_all(void) > > { > Re-adding cut-out comment for context: /* * l

Re: [PATCH v1 02/25] mm/swap: Don't abuse the seqcount latching API

2020-05-22 Thread Peter Zijlstra
On Fri, May 22, 2020 at 05:17:05PM +0200, Sebastian A. Siewior wrote: > On 2020-05-22 16:57:07 [+0200], Peter Zijlstra wrote: > > > @@ -725,21 +735,48 @@ void lru_add_drain_all(void) > > > if (WARN_ON(!mm_percpu_wq)) > > > return; > > > > > > > > + this_gen = READ_ONCE(lru_drain_gen)

Re: [PATCH v1 02/25] mm/swap: Don't abuse the seqcount latching API

2020-05-22 Thread Sebastian A. Siewior
On 2020-05-22 16:57:07 [+0200], Peter Zijlstra wrote: > > @@ -725,21 +735,48 @@ void lru_add_drain_all(void) > > if (WARN_ON(!mm_percpu_wq)) > > return; > > > > > + this_gen = READ_ONCE(lru_drain_gen); > > + smp_rmb(); > > this_gen = smp_load_acquire(&lru_drain_gen); >

Re: [PATCH v1 02/25] mm/swap: Don't abuse the seqcount latching API

2020-05-22 Thread Peter Zijlstra
On Tue, May 19, 2020 at 11:45:24PM +0200, Ahmed S. Darwish wrote: > @@ -713,10 +713,20 @@ static void lru_add_drain_per_cpu(struct work_struct > *dummy) > */ > void lru_add_drain_all(void) > { > + static unsigned int lru_drain_gen; > static struct cpumask has_work; > + static DE

Re: [PATCH v1 02/25] mm/swap: Don't abuse the seqcount latching API

2020-05-20 Thread Peter Zijlstra
On Wed, May 20, 2020 at 03:22:15PM +0300, Konstantin Khlebnikov wrote: > On 20/05/2020 00.45, Ahmed S. Darwish wrote: > > Commit eef1a429f234 ("mm/swap.c: piggyback lru_add_drain_all() calls") > > implemented an optimization mechanism to exit the to-be-started LRU > > drain operation (name it A) if

Re: [PATCH v1 02/25] mm/swap: Don't abuse the seqcount latching API

2020-05-20 Thread Konstantin Khlebnikov
On 20/05/2020 00.45, Ahmed S. Darwish wrote: Commit eef1a429f234 ("mm/swap.c: piggyback lru_add_drain_all() calls") implemented an optimization mechanism to exit the to-be-started LRU drain operation (name it A) if another drain operation *started and finished* while (A) was blocked on the LRU dr

[PATCH v1 02/25] mm/swap: Don't abuse the seqcount latching API

2020-05-19 Thread Ahmed S. Darwish
Commit eef1a429f234 ("mm/swap.c: piggyback lru_add_drain_all() calls") implemented an optimization mechanism to exit the to-be-started LRU drain operation (name it A) if another drain operation *started and finished* while (A) was blocked on the LRU draining mutex. This was done through a seqcount