Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10026874ybi; Wed, 10 Jul 2019 22:06:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrDz5rp66jOznID82zKcUtOF3lrc0RZIPJC95CJFrJbjA36kj8ph4Iz5AKfIRXyc34rSUt X-Received: by 2002:a17:90a:9bc5:: with SMTP id b5mr2542582pjw.109.1562821604574; Wed, 10 Jul 2019 22:06:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562821604; cv=none; d=google.com; s=arc-20160816; b=Mf5F8Wf3XgmyKDRGpC/yPIvUCvWIZJAG99+raPp3hCTRocbTgbzmIhO1vWYm5S7Z3H eAvYd+fmaNLOARwyp2eSD9KGVCzhoDVP8wipzMcMrnyNVBqQviuSqOAvDvQMvD9oQbtC Ps6mQd26Z91gH8TwTz9HtVWuh7ZMt3Ps0xV63+JN8sOdx1cjxpnYBqs3F4I/SmU155o4 9OuPI31bR44nbSr8xKsU0P/yZW4jtpev9eMhJmM0pVQPdc6+ej0HQnD3DU2IkOr6MmSu n4VDIVvfiW1JMxe+ghb31wbdDN3YNQmXxyoL0e/mo/tCjZdyvawXH1qAccikXlKzMirz 1Uqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=O7XDUYZ50C5Wivig3QmUbWDaMygc+9d5AOPjUhLcsBo=; b=qDNGb6U1NrpwQzKyCxz1G3DsQ9v111IanIXF4zV0nPnkg/JO2+hbgst+2BK0YdCnSn sRACMyJo1dsAmrMTObW5r5DtJ2pNQt7xSQwei0cS+xrkTL9Rnw3kaZZ8HdEWwvhLbUIU +Bbj1Z57NzPLWWx3Yxj5OQtHfqhR6FAgi0j/vEe+1HLRzUuuNfAsXzwudmDSEKy+YS8j ia/GQowppPhetgOO+Z6aaJe/ULGWfCUBP6OgnPqEPoMT4KFFgY2qDLpS/xaz2u7SsbLh vLDC7yR9lrUB4Urw7JVLmWKoP1H/4eS1AHqSsLv5blyvz6xYLyxZ7ZhXTjzVJ+Rdxxzs Q33A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l3IsQrcB; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v25si4075425pff.274.2019.07.10.22.06.28; Wed, 10 Jul 2019 22:06:44 -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=pass header.i=@gmail.com header.s=20161025 header.b=l3IsQrcB; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727838AbfGKFC0 (ORCPT + 99 others); Thu, 11 Jul 2019 01:02:26 -0400 Received: from mail-yw1-f68.google.com ([209.85.161.68]:35887 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725963AbfGKFC0 (ORCPT ); Thu, 11 Jul 2019 01:02:26 -0400 Received: by mail-yw1-f68.google.com with SMTP id x67so372532ywd.3 for ; Wed, 10 Jul 2019 22:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=O7XDUYZ50C5Wivig3QmUbWDaMygc+9d5AOPjUhLcsBo=; b=l3IsQrcBVy6PrW8UVKVBL2FYEIdjoxNATom3yi4BY+Ol4ai4JZeEdsgjhfDCa+CEvV s1YYWCmvC8dn7ubda+c5nlfGCawIqNAxcLXewDUPpYBgD4uAg9ySqwVUS+9Dwaa999mw rbL1mTPDR4ql0lvYK5biWBL9Eg1dALDgCpg1yfhe4EmRSjE49Ef7O59VTgLFlSBMdd/X KbNqEYPiv9xLr1wiW0D2Ci7yYc4ZoXs54TYtV4J2SarwVIAT30jO48laMJ5+V42SBpZP rHDPhhClysG9EOE9ngvlmIaYb1Ud1GKVURXNUCkPF1m3bAb9ZcUmP06Zmu3XHmbuomSM d+LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=O7XDUYZ50C5Wivig3QmUbWDaMygc+9d5AOPjUhLcsBo=; b=nttr+Ct+FZNVj/gCgvZzcKhJ/HPTE+5RzXUN6ibbrMImO0mySNNp0eG0F2qlGjTclS EYuYlFPrQG0inY2WCisRDsQzo0bm2TjH8kx7s8mIgppbLUXXFLIF+r12lsO9u6kkWIFP qAhD1sF9rznth+AnLOZbVyveUqUbZlu9UuRZp1CRJFL9pJ1ZgTFwoZO81LrLZOtK9UAu OB9zKLpO93QlrNS4d0EVR9kjYpDypZp89n7bk/pPlPqVreWTXaHmvjzNuJvt0tXzVOIA J5qo5kCNNNrq3Lhp4J0m3nu2K1XrKu68Y3J03CXPvrT2+heFyQKxveWVAoQUgFe8Bcfo R7yA== X-Gm-Message-State: APjAAAXOc3aGi5bsv6FSMJWujXE/nDtmvAbqbFJCj5UxebCKstxs6bn3 ERg0Z0SdnVLXKiaPmm1f8FDKwceM0TGPy/IHruI= X-Received: by 2002:ac8:359a:: with SMTP id k26mr1279205qtb.87.1562821345676; Wed, 10 Jul 2019 22:02:25 -0700 (PDT) MIME-Version: 1.0 References: <20190628091528.17059-1-duyuyang@gmail.com> <20190628091528.17059-18-duyuyang@gmail.com> <20190710051830.GB14490@tardis> In-Reply-To: <20190710051830.GB14490@tardis> From: Yuyang Du Date: Thu, 11 Jul 2019 13:02:14 +0800 Message-ID: Subject: Re: [PATCH v3 17/30] locking/lockdep: Add read-write type for a lock dependency To: Boqun Feng Cc: Peter Zijlstra , Will Deacon , Ingo Molnar , Bart Van Assche , ming.lei@redhat.com, Frederic Weisbecker , Thomas Gleixner , LKML , Waiman Long , paulmck@linux.vnet.ibm.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for review. On Wed, 10 Jul 2019 at 13:18, Boqun Feng wrote: > > On Fri, Jun 28, 2019 at 05:15:15PM +0800, Yuyang Du wrote: > > Direct dependencies need to keep track of their read-write lock types. > > Two bit fields, which share the distance field, are added to lock_list > > struct so the types are stored there. > > > > With a dependecy lock1 -> lock2, lock_type1 has the type for lock1 and > > lock_type2 has the type for lock2, where the values are one of the > > lock_type enums. > > > > Signed-off-by: Yuyang Du > > --- > > include/linux/lockdep.h | 15 ++++++++++++++- > > kernel/locking/lockdep.c | 25 +++++++++++++++++++++++-- > > 2 files changed, 37 insertions(+), 3 deletions(-) > > > > diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h > > index eb26e93..fd619ac 100644 > > --- a/include/linux/lockdep.h > > +++ b/include/linux/lockdep.h > > @@ -185,6 +185,8 @@ static inline void lockdep_copy_map(struct lockdep_map *to, > > to->class_cache[i] = NULL; > > } > > > > +#define LOCK_TYPE_BITS 2 > > + > > /* > > * Every lock has a list of other locks that were taken after or before > > * it as lock dependencies. These dependencies constitute a graph, which > > @@ -207,7 +209,17 @@ struct lock_list { > > struct list_head chains; > > struct lock_class *class[2]; > > struct lock_trace trace; > > - int distance; > > + > > + /* > > + * The lock_type fields keep track of the lock type of this > > + * dependency. > > + * > > + * With L1 -> L2, lock_type1 stores the lock type of L1, and > > + * lock_type2 stores that of L2. > > + */ > > + unsigned int lock_type1 : LOCK_TYPE_BITS, > > + lock_type2 : LOCK_TYPE_BITS, > > Bad names ;-) Maybe fw_dep_type and bw_dep_type? Which seems to be > aligned with the naming schema other functions. I think the types are for L1 -> L2 respectively, hence the names in question. Let me reconsider this anyway and maybe hear from others. Thanks, Yuyang