mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org, h.mitake@gmail.com,
	Ingo Molnar <mingo@elte.hu>, Paul Mackerras <paulus@samba.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Jens Axboe <jens.axboe@oracle.com>,
	Jason Baron <jbaron@redhat.com>
Subject: Re: [PATCH RFC 00/11] lock monitor: Separate features related to lock
Date: Thu, 18 Mar 2010 14:49:38 +0900	[thread overview]
Message-ID: <4BA1BEF2.4050706@dcl.info.waseda.ac.jp> (raw)
In-Reply-To: <20100317153858.GA5059@nowhere>

On 03/18/10 00:39, Frederic Weisbecker wrote:
 > On Wed, Mar 17, 2010 at 04:30:53PM +0900, Hitoshi Mitake wrote:
 >> On 03/17/10 10:32, Frederic Weisbecker wrote:
 >>> On Sun, Mar 14, 2010 at 07:13:55PM +0100, Peter Zijlstra wrote:
 >>>> On Sun, 2010-03-14 at 19:38 +0900, Hitoshi Mitake wrote:
 >>>>> Current lockdep is too complicated because,
 >>>>>    * dependency validation
 >>>>>    * statistics
 >>>>>    * event tracing
 >>>>> are all implemented by it.
 >>>>> This cause problem of overhead.
 >>>>> If user enables one of them, overhead of rests part is not avoidable.
 >>>>> (tracing is exception. If user enables validation or stat,
 >>>>> overhead of tracing doesn't occur.)
 >>>>>
 >>>>> So I suggest new subsystem "lock monitor".
 >>>>> This is a general purpose lock event hooking mechanism.
 >>>>>
 >>>>> lock monitor will be enable easy implementing and running
 >>>>> these features related to lock.
 >>>>>
 >>>>> And I'm hoping that lock monitor will reduce overhead of perf lock.
 >>>>> Because lock monitor separates dependency validation and event
 >> tracing clearly,
 >>>>> so calling of functions of lockdep (e.g. lock_acquire()) only for
 >> validation
 >>>>> will not occur lock events.
 >>>>>
 >>>>> I implemented it on the branch perf/inject of Frederic's
 >> random-tracing tree.
 >>>>> Because the branch is hottest place of lock and tracing :)
 >>>>
 >>>> OK, so I really don't like this much..
 >>>>
 >>>> Building a lockstat kernel (PROVE_LOCKING=n) should not have much more
 >>>> overhead than the proposed solution, if the simple lock acquistion
 >>>> tracking bothers you, you can do a patch to weaken that.
 >>>>
 >>>> I really really dislike how you add a monitor variable between
 >>>> everything for no reason what so ever.
 >>>>
 >>>> You use a new rwlock_t, which is an instant fail, those things are 
worse
 >>>> than useless.
 >>>>
 >>>> You add chained indirect calls into all lock ops, that's got to hurt.
 >>>
 >>>
 >>> Well, the idea was not bad at the first glance. It was separating
 >>> lockdep and lock events codes.
 >>>
 >>> But indeed, the indirect calls plus the locking are not good
 >>> for such a fast path.
 >>>
 >>> There is something else, it would be nice to keep the
 >>> lockdep_map ->   lockdep_class mapping so that we can
 >>> do lock profiling based on classes too. So we actually
 >>> need the lockdep code. What we don't need is the prove
 >>> locking or the lock stats. So I guess we can have a new
 >>> config to enable lock events and get rid of the prove
 >>> locking / lock stat code if we don't need it.
 >>>
 >>>
 >>
 >> Thanks for your comments, Peter and Frederic.
 >>
 >> My main motivation of writing this patch series was that
 >> some kernel codes uses lockdep functions (e.g. lock_acquire()) directly,
 >> so perf lock gets a lot of trace events without actual locks (e.g.
 >> might_lock_read()).
 >> I think that these are confusable things for users.
 >>
 >> But I noticed that these events can be reduced by
 >> turning off CONFIG_PROVE_LOCKING. Yeah, my patch series was 
pointless... :)
 >>
 >> Should perf lock warn not to use with CONFIG_PROVE_LOCKING?
 >
 >
 > Ah I see.
 >
 > might_lock_read() uses might_fault(), rcu, workqueues and probably
 > yet some others use sequences of lock_acquire/lock_release to prove
 > locking while there is actually no real lock operation involved, but
 > this is to detect dependency/balance mistakes.
 >
 > I think that these cases are easily detectable in that they never have
 > any lock_acquired in their scenario. So may be we can just ignore
 > scenarios without lock_acquired and indeed advise users not to use
 > PROVE_LOCKING.

Unfortunately, we cannot use this detection method.
Because trylock series (e.g. spin_trylock()) only issues
lock_acquire() like this,

static inline int __raw_spin_trylock(raw_spinlock_t *lock)
{
	preempt_disable();
	if (do_raw_spin_trylock(lock)) {
		spin_acquire(&lock->monitor, 0, 1, _RET_IP_); <- spin_acquire() only 
issues lock_acquire()
		return 1;
	}
	preempt_enable();
	return 0;
}

So distinguishing trylocks and lock_acquire()/lock_release() pairs from
might_lock_read(), might_fault() and etc is hard.

It seems that turning off PROVE_LOCKING must be required
for state machine of perf lock.

  reply	other threads:[~2010-03-18  5:49 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-14 10:38 Hitoshi Mitake
2010-03-14 10:38 ` [PATCH RFC 01/11] lock monitor: New subsystem for lock event hooking Hitoshi Mitake
2010-03-14 10:38 ` [PATCH RFC 02/11] Adopt lockdep to lock monitor Hitoshi Mitake
2010-03-14 10:38 ` [PATCH RFC 03/11] Adopt spinlock " Hitoshi Mitake
2010-03-14 10:38 ` [PATCH RFC 04/11] Adopt rwlock " Hitoshi Mitake
2010-03-14 10:38 ` [PATCH RFC 05/11] Adopt arch dependent rwsem " Hitoshi Mitake
2010-03-14 10:38 ` [PATCH RFC 06/11] Adopt rwsem of x86 " Hitoshi Mitake
2010-03-14 10:38 ` [PATCH RFC 07/11] Adopt the way of initializing semaphore " Hitoshi Mitake
2010-03-14 10:38 ` [PATCH RFC 08/11] Adopt mutex " Hitoshi Mitake
2010-03-14 10:38 ` [PATCH RFC 09/11] Adopt rcu_read_lock() " Hitoshi Mitake
2010-03-14 10:38 ` [PATCH RFC 10/11] Adopt kernel/sched.c " Hitoshi Mitake
2010-03-14 10:38 ` [PATCH RFC 11/11] Very dirty temporal solution for testing " Hitoshi Mitake
2010-03-14 18:13 ` [PATCH RFC 00/11] lock monitor: Separate features related to lock Peter Zijlstra
2010-03-17  1:32   ` Frederic Weisbecker
2010-03-17  7:30     ` Hitoshi Mitake
2010-03-17 15:39       ` Frederic Weisbecker
2010-03-18  5:49         ` Hitoshi Mitake [this message]
2010-03-18 20:30           ` Frederic Weisbecker
2010-03-20  5:51             ` Hitoshi Mitake
2010-03-23 15:45         ` Peter Zijlstra
2010-03-17  9:52     ` Ingo Molnar
2010-03-17 13:59       ` Jason Baron
2010-03-18  5:59       ` Hitoshi Mitake
2010-03-18 21:16         ` Frederic Weisbecker
2010-03-19  1:08           ` Mathieu Desnoyers
2010-03-19  1:23             ` Frederic Weisbecker
2010-03-19  1:36               ` Mathieu Desnoyers
2010-03-19  2:27                 ` Frederic Weisbecker
2010-03-19  2:40                   ` Mathieu Desnoyers
2010-03-19  3:06                     ` Frederic Weisbecker
2010-03-19 12:56                       ` Mathieu Desnoyers
2010-03-19 16:00                         ` Jason Baron
2010-03-20  4:51                           ` Frederic Weisbecker
2010-03-20  4:46                         ` Frederic Weisbecker
2010-03-20  5:56           ` Hitoshi Mitake
2010-03-20  8:23             ` Hitoshi Mitake
2010-03-21  9:49               ` Hitoshi Mitake
2010-03-23 15:32               ` Peter Zijlstra
2010-04-04  7:56                 ` Hitoshi Mitake
2010-03-17  1:47 ` Frederic Weisbecker
2010-03-17  7:33   ` Hitoshi Mitake
2010-03-17  9:50     ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BA1BEF2.4050706@dcl.info.waseda.ac.jp \
    --to=mitake@dcl.info.waseda.ac.jp \
    --cc=acme@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=h.mitake@gmail.com \
    --cc=jbaron@redhat.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®