From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754156AbbFEJ4B (ORCPT ); Fri, 5 Jun 2015 05:56:01 -0400 Received: from mail-wg0-f47.google.com ([74.125.82.47]:34964 "EHLO mail-wg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750878AbbFEJz5 (ORCPT ); Fri, 5 Jun 2015 05:55:57 -0400 Date: Fri, 5 Jun 2015 11:55:52 +0200 From: Ingo Molnar To: Peter Zijlstra Cc: umgwanakikbuti@gmail.com, mingo@elte.hu, ktkhai@parallels.com, rostedt@goodmis.org, tglx@linutronix.de, juri.lelli@gmail.com, pang.xunlei@linaro.org, oleg@redhat.com, wanpeng.li@linux.intel.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 13/14] lockdep: Implement lock pinning Message-ID: <20150605095552.GA7893@gmail.com> References: <20150605084836.364306429@infradead.org> <20150605085206.135690748@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150605085206.135690748@infradead.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Peter Zijlstra wrote: > RFC: a possible alternative API would be something like: > > int cookie = lockdep_pin_lock(&foo); > ... > lockdep_unpin_lock(&foo, cookie); Yeah, this would be even nicer. > Where we pick a random number for the pin_count; this makes it > impossible to sneak a lock break in without also passing the right > cookie along. > > I've not done this because it ends up generating code for !LOCKDEP, > esp. if you need to pass the cookie around for some reason. The cookie could be a zero-size structure, which can be 'passed around' syntactically but creates no overhead in the code. But I'd expect cookie-passing to be a sign of badness in most cases: the lock should generally be unpinned at the same level of abstraction... Thanks, Ingo