Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6281548yba; Tue, 14 May 2019 05:07:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwhov4gKrlpa/TUNuPJ3F+zVBn3axkaOVGDs6917vkMXIrtOip+OBKuwoHJWD0a5x+ArkgX X-Received: by 2002:a62:3085:: with SMTP id w127mr17124970pfw.170.1557835655784; Tue, 14 May 2019 05:07:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557835655; cv=none; d=google.com; s=arc-20160816; b=UHnL5zlDTN6Zh71+1cwbQ5tX6pQ7LMAxqjXmP2p/lmK1O/cHd/rvxUkYxCnsABw0Cp Rn+XoQGTOhdgxf2+4LmnejwBa9VGp8wyEuEQ+2FRc6bP5k3gcs/VTza07Fq0IJAunLzo 6R6Wj94p5gFKOB2PPB/+5B1HfQjEwwy5P0YrKCwaOr7h4FxqJONkaN+i9B2u85A1li/5 OzeSJppKz4DQA1vmgnaZtu89SE4aScIw/9T21gA9cuBi5u42wQLI1J7KJqT3zdwXW4iK auE5/DXIqcTQntWhGRSk2p5zI9y96gTJpfq+MD1MyL5Oyz/E8gIpHC4CUNZ6Wgk6nSso soJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ANiALWppH8ILUGFxS4Qrkx79rFjQyK8e8zRwG0vYFV8=; b=Hch59fs1ISb99pIKWJ8LVqbtm5PNgr/BDpdcptY/s196rqcPncjxpqthmp9lvKZba6 7U6fG8gS/xgXeIc3GNejlc5KGbynYdhdNG81EEOtbG5itoqY4GrOxYGbnk+6jI51OCpB IK2PLSW40sKtmpO9/PM5md6rPkGfSdqTMhTfC5STzQnTwsm9Q7Jxb4uoytFdHu3mOUoE SyB8P2UUliT8oAHV++7kjQU/LNL6+Jzhnf2aWT/CZqWJwdZO/eBtxOz8C43McMFLNbaX gbpwGbMBb9VXv31g+k86u6EmacQ0wJaXF+8hV76q4uHi2NhPxauwGSv0MftGmd2kxAOc kR2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="c/Yu05Re"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i195si11176635pfe.20.2019.05.14.05.07.20; Tue, 14 May 2019 05:07:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="c/Yu05Re"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726362AbfENMEX (ORCPT + 99 others); Tue, 14 May 2019 08:04:23 -0400 Received: from merlin.infradead.org ([205.233.59.134]:36310 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbfENMEW (ORCPT ); Tue, 14 May 2019 08:04:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ANiALWppH8ILUGFxS4Qrkx79rFjQyK8e8zRwG0vYFV8=; b=c/Yu05Reag7wzOJIwT0uOImpO EKhRRNkobwhMnBKiBQjvxenWIkAaDDHsLs9tA7Et8kWapmXMYqu6S4cMBKbejEICut8reVwxeb+Oj YB394+UFayke869Y1+ppmtJN+TBE2WDtcA8OA2gDWxW8vV227TeHHLFUXWBH/kIvtY1GjNxHHEGEW 3BKaJxP40zy6VY4aGG/WU6aICA9b9BRTVmIWW6XMqkiIEZuaH6tdY7MAqtIpXdfkb1031bZxYN+YA Rh77icdImp+fUfm+xa3QlWfVLYeX3R01lJ/An7pZWBiUzFa2AjFwRoUyc3cN8fzfhn9bpfQ/TJJIp GMpWZDwRA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQWAA-0007l3-DF; Tue, 14 May 2019 12:04:06 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 086162029F877; Tue, 14 May 2019 14:04:05 +0200 (CEST) Date: Tue, 14 May 2019 14:04:04 +0200 From: Peter Zijlstra To: Yuyang Du Cc: will.deacon@arm.com, Ingo Molnar , Bart Van Assche , ming.lei@redhat.com, Frederic Weisbecker , tglx@linutronix.de, Boqun Feng , LKML Subject: Re: [PATCH 01/17] locking/lockdep: Add lock type enum to explicitly specify read or write locks Message-ID: <20190514120404.GQ2589@hirez.programming.kicks-ass.net> References: <20190513091203.7299-1-duyuyang@gmail.com> <20190513091203.7299-2-duyuyang@gmail.com> <20190513114504.GR2623@hirez.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.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 14, 2019 at 09:31:48AM +0800, Yuyang Du wrote: > Thanks for review. > > On Mon, 13 May 2019 at 19:45, Peter Zijlstra wrote: > > > > On Mon, May 13, 2019 at 05:11:47PM +0800, Yuyang Du wrote: > > > + * Note that we have an assumption that a lock class cannot ever be both > > > + * read and recursive-read. > > > > We have such locks in the kernel... see: > > > > kernel/qrwlock.c:queued_read_lock_slowpath() > > > > And yes, that is somewhat unfortunate, but hard to get rid of due to > > hysterical raisins. > > That is ok, then LOCK_TYPE_RECURSIVE has to be 3 such that > LOCK_TYPE_RECURSIVE & LOCK_TYPE_READ != 0. I thought to do this in the > first place without assuming. Anyway, it is better to know. > > And I guess in a task: > > (1) read(X); > recursive_read(x); /* this is ok ? */ Correct, that is the use-case for that 'funny' construct. > (2) recursive_read(x); > read(x) /* not ok ? */ Indeed, read can block due to a pending writer, while recurise_read will not suffer like that. > Either way, very small change may need to be made. OK, excellent.