From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964925AbbHDNDB (ORCPT ); Tue, 4 Aug 2015 09:03:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37383 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964884AbbHDNC6 (ORCPT ); Tue, 4 Aug 2015 09:02:58 -0400 Date: Tue, 4 Aug 2015 15:00:53 +0200 From: Oleg Nesterov To: Arnd Bergmann , Ingo Molnar , Linus Torvalds , "Paul E.McKenney" , Peter Zijlstra , Waiman Long Cc: linux-kernel@vger.kernel.org Subject: qrwlock && read-after-read Message-ID: <20150804130053.GA22608@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I am working on the (off-topic) bug report which motivated me to look at locking/qrwlock.c and it seems to me there is a problem with the queued rwlocks. Unless I am totally confused read-after-read is no longer valid, write_lock() stops the new readers. And lockdep doesn't know this, read_lock()->rwlock_acquire_read() doesn't match the reality. The code doing read_lock(X); read_lock(X); can deadlock if another CPU does write_lock(X) in between. This was fine before rwlock_t was changed to use qrwlock. A nested read_lock() in interrupt should be fine though, and this is because queue_read_lock_slowpath() "ignores" _QW_WAITING if in_interrupt(). This means that rwlock_t has the really strange semantics imho, and again, it is not lockdep-friendly. What do you think we can/should do? Or did I misread this code? Oleg.