From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752368AbbHENKb (ORCPT ); Wed, 5 Aug 2015 09:10:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41981 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752118AbbHENK3 (ORCPT ); Wed, 5 Aug 2015 09:10:29 -0400 Date: Wed, 5 Aug 2015 15:08:23 +0200 From: Oleg Nesterov To: Linus Torvalds Cc: Peter Zijlstra , Arnd Bergmann , Ingo Molnar , "Paul E.McKenney" , Waiman Long , Linux Kernel Mailing List Subject: Re: qrwlock && read-after-read Message-ID: <20150805130823.GA18587@redhat.com> References: <20150804130053.GA22608@redhat.com> <20150804131036.GQ25159@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 On 08/04, Linus Torvalds wrote: > > I refused to have something that broke the tasklist lock, so the "irq > users nest" was a requirement. And I was going to reply that this breaks tasklist lock anyway but failed to find anything wrong after the quick grep. > So it's not like I love the current semantics, but at least they are > realistic and can work. I agree that teaching lockdep to check for > this would be a good idea, because the semantics _are_ subtle. Yes... Just for example, the comment above task_lock(), Nests both inside and outside of read_lock(&tasklist_lock). is no longer correct. Fortunately task_lock() is not irq-safe, and iirc nobody does task_lock() + read_lock(&tasklist_lock) in process context, so we are probably fine. Still, qrwlock changed the rules and now it can only nest inside of read_lock(tasklist_lock). Hmm. And afaics this in turn means that the next sentence It must not be nested with write_lock_irq(&tasklist_lock), neither inside nor outside. also becomes wrong. So task_lock() can nest inside tasklist_lock, write-or-read doesn't matter. So it would be really nice to fix lockdep, but as Peter explains (thanks Peter!) this is not simple. > (And I'm not 100% convinced we needed the fair model at all, but > fairness does end up being a good thing _if_ it works). Yes. At least this automatically fixes the easy-to-trigger problems with write_lock(tasklist) starvation/lockup. Oleg.