public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] change sb_writers to use percpu_rw_semaphore
@ 2015-07-22 21:15 Oleg Nesterov
  2015-07-22 21:15 ` [PATCH 1/4] percpu-rwsem: introduce percpu_down_read_trylock() Oleg Nesterov
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Oleg Nesterov @ 2015-07-22 21:15 UTC (permalink / raw)
  To: Al Viro, Dave Chinner, Dave Hansen, Jan Kara
  Cc: Paul E. McKenney, Peter Zijlstra, linux-fsdevel, linux-kernel

On top of "[PATCH 0/4] sb_write: lockdep fixes/cleanups" series.
Now that it was reviewed (thanks Jan!), let me send the actual
conversion.

1-2 add the simple percpu_rw_semaphore changes, this does not
conflict with the pending rcu_sync changes.

3/4 is really ugly but please see the changelog, this is the
temporary kludge to avoid the problems with other percpu-rwsem
changes routed via another tree.

4/4 looks simple and straightforward after the previous series.

Testing. Well, so far I only verified that ioctl(FIFREEZE) +
ioctl(FITHAW) seems to wors "as expected" on my testing machine
with ext3. So probably this needs more testing. Will try to do
this later. And after that we can hopefully remove the "trylock"
hack in __sb_start_write(), this series doesn't remove it.

But. I will be travelling till the end of the next week, and I'm
not sure I will have the internet access. So let me apologize in
advance if (most probably) I won't be able to reply until I return.

Please review.

Oleg.

 fs/super.c                    |  134 +++++++++++++++--------------------------
 include/linux/fs.h            |   22 +++----
 include/linux/percpu-rwsem.h  |   20 ++++++
 kernel/locking/percpu-rwsem.c |   13 ++++
 4 files changed, 89 insertions(+), 100 deletions(-)


^ permalink raw reply	[flat|nested] 18+ messages in thread
* [PATCH RFC 0/4] change sb_writers to use percpu_rw_semaphore
@ 2015-07-13 21:25 Oleg Nesterov
  2015-07-13 21:25 ` [PATCH 4/4] " Oleg Nesterov
  0 siblings, 1 reply; 18+ messages in thread
From: Oleg Nesterov @ 2015-07-13 21:25 UTC (permalink / raw)
  To: Al Viro, Jan Kara, Linus Torvalds, Paul McKenney, Peter Zijlstra
  Cc: Daniel Wagner, Davidlohr Bueso, Ingo Molnar, Tejun Heo,
	linux-kernel

Hello,

Al, Jan, could you comment? I mean the intent, the patches are
obviously not for inclusion yet.

We can remove everything from struct sb_writers except frozen
(which can become a boolean, it seems) and add the array of
percpu_rw_semaphore's instead.

__sb_start/end_write() can use percpu_down/up_read(), and
freeze/thaw_super() can use percpu_down/up_write().

Why:

	- Firstly, __sb_start_write() looks simply buggy. I does
	  __sb_end_write() if it sees ->frozen, but if it migrates
	  to another CPU before percpu_counter_dec() sb_wait_write()
	  can wrongly succeed if there is another task which holds
	  the same "semaphore": sb_wait_write() can miss the result
	  of the previous percpu_counter_inc() but see the result
	  of this percpu_counter_dec().

	- This code doesn't look simple. It would be better to rely
	  on the generic locking code.

	- __sb_start_write() will be a little bit faster, but this
	  is minor.

Todo:

	- __sb_start_write(wait => false) always fail.

	  Thivial, we already have percpu_down_read_trylock() just
	  this patch wasn't merged yet.

	- sb_lockdep_release() and sb_lockdep_acquire() play with
	  percpu_rw_semaphore's internals.

	  Trivial, we need a couple of new helper in percpu-rwsem.c.

	- Fix get_super_thawed(), it will spin if MS_RDONLY...

	  It is not clear to me what exactly should we do, but this
	  doesn't look hard. Perhaps it can just return if MS_RDONLY.

	- Most probably I missed something else, and I do not need
	  how to test.

Finally. freeze_super() calls synchronize_sched_expedited() 3 times in
a row. This is bad and just stupid. But if we change percpu_rw_semaphore
to use rcu_sync (see https://lkml.org/lkml/2015/7/11/211) we can avoid
this and do synchronize_sched() only once. Just we need some more simple
changes in percpu-rwsem.c, so that all sb_writers->rw_sem[] semaphores
could use the single sb_writers->rss.

In this case destroy_super() needs some modifications too,
percpu_free_rwsem() will be might_sleep(). But this looks simple too.

Oleg.

 fs/super.c         |  147 +++++++++++++++++++--------------------------------
 include/linux/fs.h |   14 +----
 2 files changed, 58 insertions(+), 103 deletions(-)


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2015-08-11 13:29 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-22 21:15 [PATCH 0/4] change sb_writers to use percpu_rw_semaphore Oleg Nesterov
2015-07-22 21:15 ` [PATCH 1/4] percpu-rwsem: introduce percpu_down_read_trylock() Oleg Nesterov
2015-07-22 21:15 ` [PATCH 2/4] percpu-rwsem: introduce percpu_rwsem_release() and percpu_rwsem_acquire() Oleg Nesterov
2015-07-31 10:20   ` Peter Zijlstra
2015-08-03 15:40     ` Oleg Nesterov
2015-07-22 21:15 ` [PATCH 3/4] shift percpu_counter_destroy() into destroy_super_work() Oleg Nesterov
2015-07-28  8:36   ` Jan Kara
2015-07-22 21:15 ` [PATCH 4/4] change sb_writers to use percpu_rw_semaphore Oleg Nesterov
2015-07-22 21:34   ` Oleg Nesterov
2015-07-28  8:34   ` Jan Kara
2015-08-03 17:30     ` Oleg Nesterov
2015-08-07 19:54   ` Oleg Nesterov
2015-08-07 19:55 ` [PATCH 0/4] " Oleg Nesterov
2015-08-10 14:59   ` Jan Kara
2015-08-10 22:41     ` Dave Chinner
2015-08-11 13:16       ` Oleg Nesterov
2015-08-11 13:29         ` Jan Kara
  -- strict thread matches above, loose matches on Subject: below --
2015-07-13 21:25 [PATCH RFC " Oleg Nesterov
2015-07-13 21:25 ` [PATCH 4/4] " Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox