From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751879AbcGMDHK (ORCPT ); Tue, 12 Jul 2016 23:07:10 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:35603 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750941AbcGMDHA (ORCPT ); Tue, 12 Jul 2016 23:07:00 -0400 From: Ming Lei To: linux-kernel@vger.kernel.org Cc: Ming Lei , Peter Zijlstra , Ingo Molnar Subject: [PATCH] lockdep: fix warning in case of no_validate lock Date: Wed, 13 Jul 2016 11:06:36 +0800 Message-Id: <1468379196-21096-1-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now there are several locks which are marked as no_validate, so name of the lock class can be different with the no_validate lock. This patch avoids this warning for this case, and fix the following warning: [ 14.413292] ------------[ cut here ]------------ [ 14.413297] WARNING: CPU: 1 PID: 1434 at kernel/locking/lockdep.c:704 register_lock_class+0x44a/0x4f0 [ 14.413298] Modules linked in: bcache raid1 psmouse dax_pmem dax nd_pmem serio_raw nvme nd_btt nvme_core floppy null_blk configs autofs4 [ 14.413309] CPU: 1 PID: 1434 Comm: bcache-register Tainted: G W 4.7.0-rc6-next-20160708+ #2069 [ 14.413310] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.9.0-0-g01a84be-prebuilt.qemu-project.org 04/01/2014 [ 14.413311] 0000000000000000 ffff880076973900 ffffffffba459dec 0000000000000000 [ 14.413313] 0000000000000000 ffff880076973940 ffffffffba08af71 000002c0ba1312a2 [ 14.413316] ffffffffbb9fd1e0 0000000000000000 0000000000000000 ffff880074d078d0 [ 14.413318] Call Trace: [ 14.413321] [] dump_stack+0x85/0xc9 [ 14.413323] [] __warn+0xd1/0xf0 [ 14.413324] [] warn_slowpath_null+0x1d/0x20 [ 14.413326] [] register_lock_class+0x44a/0x4f0 [ 14.413328] [] __lock_acquire+0x85/0x1920 [ 14.413330] [] ? kvm_clock_read+0x23/0x40 [ 14.413332] [] ? sched_clock+0x9/0x10 [ 14.413334] [] ? sched_clock_local+0x18/0x80 [ 14.413336] [] lock_acquire+0xd4/0x240 [ 14.413342] [] ? mca_reap+0x54/0x180 [bcache] [ 14.413343] [] down_write_trylock+0x67/0x80 [ 14.413347] [] ? mca_reap+0x54/0x180 [bcache] [ 14.413351] [] mca_reap+0x54/0x180 [bcache] [ 14.413354] [] mca_alloc+0xc2/0x5a0 [bcache] [ 14.413358] [] bch_btree_node_get+0x143/0x290 [bcache] [ 14.413364] [] run_cache_set+0x239/0x8f0 [bcache] [ 14.413368] [] register_bcache+0x14d2/0x1a30 [bcache] [ 14.413370] [] ? mutex_lock_nested+0x2db/0x460 [ 14.413372] [] kobj_attr_store+0xf/0x20 [ 14.413374] [] sysfs_kf_write+0x44/0x60 [ 14.413376] [] kernfs_fop_write+0x144/0x1e0 [ 14.413378] [] __vfs_write+0x28/0x120 [ 14.413380] [] ? percpu_down_read+0x57/0x90 [ 14.413381] [] ? __sb_start_write+0xca/0xe0 [ 14.413382] [] ? __sb_start_write+0xca/0xe0 [ 14.413383] [] vfs_write+0xb5/0x1b0 [ 14.413385] [] ? trace_hardirqs_on_caller+0xef/0x210 [ 14.413386] [] SyS_write+0x49/0xa0 [ 14.413388] [] entry_SYSCALL_64_fastpath+0x23/0xc1 [ 14.413391] [] ? __this_cpu_preempt_check+0x13/0x20 [ 14.413392] ---[ end trace 16710c495b4dbf2f ]--- Signed-off-by: Ming Lei --- kernel/locking/lockdep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 589d763..cf071ec 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -701,7 +701,8 @@ look_up_lock_class(struct lockdep_map *lock, unsigned int subclass) * Huh! same key, different name? Did someone trample * on some memory? We're most confused. */ - WARN_ON_ONCE(class->name != lock->name); + WARN_ON_ONCE(lock->key != &__lockdep_no_validate__ && + class->name != lock->name); return class; } } -- 1.9.1