linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] perpcu rwsem, fs/locks and killing lglocks
@ 2016-09-05 19:40 Peter Zijlstra
  2016-09-05 19:40 ` [PATCH 1/7] percpu-rwsem: DEFINE_STATIC_PERCPU_RWSEM Peter Zijlstra
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Peter Zijlstra @ 2016-09-05 19:40 UTC (permalink / raw)
  To: oleg, paulmck, tj, mingo, linux-kernel, der.herr, peterz, dave,
	riel, viro, torvalds, wagi

Hi all,

Here are some patches that I've been sitting on for far too long now.

They're a respin of earlier work [1], and have been verified by Daniel Wagner
to not suffer the regression he measured with the previous set (part of which
was operator error).

Patches 4 and 5 were needed to solve a (smallish) performance regression on
CONFIG_PREEMPT=y. They avoid a number of preemption points (and code).

I was going to gather pretty numbers from Daniels data, but I keep putting that
off and figured I ought to send the patches already.

[1] https://lkml.kernel.org/r/20150622121623.291363374@infradead.org

---
 Documentation/locking/lglock.txt | 166 ---------------------------------------
 fs/Kconfig                       |   1 +
 fs/locks.c                       |  68 +++++++++++-----
 include/linux/lglock.h           |  81 -------------------
 include/linux/percpu-rwsem.h     |  36 +++++++--
 kernel/locking/Makefile          |   1 -
 kernel/locking/lglock.c          | 111 --------------------------
 kernel/stop_machine.c            |  42 ++++++----
 8 files changed, 107 insertions(+), 399 deletions(-)

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: [PATCH 2/7] fs/locks: Replace lg_global with a percpu-rwsem
@ 2016-09-06  1:58 Andreas Mohr
  2016-09-06  8:23 ` Peter Zijlstra
  0 siblings, 1 reply; 13+ messages in thread
From: Andreas Mohr @ 2016-09-06  1:58 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: der.herr, Al Viro, mingo, torvalds, dave, Oleg Nesterov, riel,
	tj, paulmck, linux-kernel

Hi,

[no properly binding reference via In-Reply-To: available thus manually re-creating, sorry]

https://lkml.org/lkml/2016/9/5/832


Two thoughts:

***multiple locks

Don't have much insight into this
(didn't spend much thinking on this),
but of course it's unfortunate
that two lock types need to be serviced
rather than having the atomic handling exchange area/section
be sufficiently guarded by one lock only
(the question here could possibly be:
what kind of currently existing
structural disadvantage/layer distribution
prevents us from being able to
have things simply serviced
within one granular lock area only?)


***lock handling

> +	percpu_down_read(&file_rwsem);
>  	spin_lock(&ctx->flc_lock);


>  	spin_unlock(&ctx->flc_lock);
> +	percpu_up_read(&file_rwsem);


These are repeated multiple times in this commit, thus error-prone.

A possibly good way to commit-micro-manage this would be:
1. commit shoves things into a newly created encapsulation/wrapper helper
   stuff_lock(&flc_lock);  /* <---- naming surely can be improved here */
2. [this commit]
   extend encapsulation/wrapper helper
   to be servicing file_rwsem, too:
   stuff_lock(&flc_lock, &file_rwsem);

That way it is pretty much guaranteed that:
a) neither one nor the other lock type
   will get forgotten later, at a specific use site
b) lock order will be correctly maintained at all times
   (AB-BA deadlock......)


[or, IOW, you get some symmetry/consistency malus points
for having provided
a relatively large amount of LOC extensions
which put certain amounts of stress on
code implementation quality/maintainability ;)]

HTH,

Andreas Mohr

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

end of thread, other threads:[~2016-09-06  8:59 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-05 19:40 [PATCH 0/7] perpcu rwsem, fs/locks and killing lglocks Peter Zijlstra
2016-09-05 19:40 ` [PATCH 1/7] percpu-rwsem: DEFINE_STATIC_PERCPU_RWSEM Peter Zijlstra
2016-09-05 19:40 ` [PATCH 2/7] fs/locks: Replace lg_global with a percpu-rwsem Peter Zijlstra
2016-09-05 19:40 ` [PATCH 3/7] fs/locks: Replace lg_local with a per-cpu spinlock Peter Zijlstra
2016-09-05 19:40 ` [PATCH 4/7] percpu-rwsem: Add down_read_preempt_disable() Peter Zijlstra
2016-09-05 19:40 ` [PATCH 5/7] fs/locks: Use percpu_down_read_preempt_disable Peter Zijlstra
2016-09-05 19:41 ` [PATCH 6/7] stop_machine: Remove stop_cpus_lock and lg_double_lock/unlock() Peter Zijlstra
2016-09-05 19:41 ` [PATCH 7/7] locking: Remove lglock Peter Zijlstra
2016-09-06  4:45 ` [PATCH 0/7] perpcu rwsem, fs/locks and killing lglocks Mike Galbraith
2016-09-06  1:58 [PATCH 2/7] fs/locks: Replace lg_global with a percpu-rwsem Andreas Mohr
2016-09-06  8:23 ` Peter Zijlstra
2016-09-06  8:36   ` Andreas Mohr
2016-09-06  8:59     ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).