Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp911726iob; Wed, 4 May 2022 10:28:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5C4IeZGY720bfXZDFzVyXQuG5DGg9XpIlum0keSnK6gcWIMQew3P1BOTySsMqN9sdcpU3 X-Received: by 2002:a17:90a:eb93:b0:1d9:a003:3f93 with SMTP id o19-20020a17090aeb9300b001d9a0033f93mr633824pjy.50.1651685294872; Wed, 04 May 2022 10:28:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651685294; cv=none; d=google.com; s=arc-20160816; b=swj0VsOc2I7tWnXsbB5NxU0aAS121DUahoEjPEAI0kVhC5MS7sth7aTvne2Ss/NZHt J+6OmODXp1SiLGTxhPI5E7jW8/8Vkck/Ky2EXNO+kuqliLfF6yb8X6XEY7pk4ZFqUdX4 RTPMqnWMCa6zmiKyKtlYG4JDVfwvqoHYaZfOLL48NNj/FW58lQ7DiSdfA3SM5BHrVLUq U0y7YOXfNlmCRwOZyroozx+TsjIef0SumMhp0UIa/x03bT96f+cCU5vxpnDdNHrBVLd3 At+UBfXPLl18Cf9fY8UdzhC8lXonRABiJd9dGNRyrcTEOkL1EfP8rOZCbtmIU702Prn4 v9pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=Hs1y4gd3025O9tHQpdLk9Ppc7JjpL2fhCLOJ7E0CVO0=; b=Vi72ibFbOOOySJMajN/S4RoQqj4QgrZ/J8t4Udcc9DNWoZG8sfVMM5GwbghyT1Fdt2 7ua1xLFRVgVIX+OIqSS5c7wDeF8pNG2ik4Re4bGs5ulOuc7L1uB2s3/va/5R9NqmHOFs rJHQ5GseDZvV63uKaGwbCTWxjOx+G8c1kzc7jX5fVucR4BO8H2syDDWd/gSTeteBnFLP rOI433uZGMvyY+sVk4y8Gv/D67sWwChXhVgm1MKjYs1ENoZCzSHdSThrAh7r2+4rOjtQ lThTVdLGkFEzJJapsVAmb6Ln1IAcg/XBNXCfRa6ocDcJFSGidclE5iSW0CAoYyMkkkoV 1Vdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n24-20020a635918000000b0039d54720b7fsi20253157pgb.778.2022.05.04.10.28.00; Wed, 04 May 2022 10:28:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346796AbiEDIxf (ORCPT + 99 others); Wed, 4 May 2022 04:53:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346658AbiEDIxD (ORCPT ); Wed, 4 May 2022 04:53:03 -0400 Received: from lgeamrelo11.lge.com (lgeamrelo13.lge.com [156.147.23.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E1ADF24F35 for ; Wed, 4 May 2022 01:49:21 -0700 (PDT) Received: from unknown (HELO lgeamrelo01.lge.com) (156.147.1.125) by 156.147.23.53 with ESMTP; 4 May 2022 17:19:20 +0900 X-Original-SENDERIP: 156.147.1.125 X-Original-MAILFROM: byungchul.park@lge.com Received: from unknown (HELO localhost.localdomain) (10.177.244.38) by 156.147.1.125 with ESMTP; 4 May 2022 17:19:20 +0900 X-Original-SENDERIP: 10.177.244.38 X-Original-MAILFROM: byungchul.park@lge.com From: Byungchul Park To: torvalds@linux-foundation.org Cc: damien.lemoal@opensource.wdc.com, linux-ide@vger.kernel.org, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, mingo@redhat.com, linux-kernel@vger.kernel.org, peterz@infradead.org, will@kernel.org, tglx@linutronix.de, rostedt@goodmis.org, joel@joelfernandes.org, sashal@kernel.org, daniel.vetter@ffwll.ch, chris@chris-wilson.co.uk, duyuyang@gmail.com, johannes.berg@intel.com, tj@kernel.org, tytso@mit.edu, willy@infradead.org, david@fromorbit.com, amir73il@gmail.com, bfields@fieldses.org, gregkh@linuxfoundation.org, kernel-team@lge.com, linux-mm@kvack.org, akpm@linux-foundation.org, mhocko@kernel.org, minchan@kernel.org, hannes@cmpxchg.org, vdavydov.dev@gmail.com, sj@kernel.org, jglisse@redhat.com, dennis@kernel.org, cl@linux.com, penberg@kernel.org, rientjes@google.com, vbabka@suse.cz, ngupta@vflare.org, linux-block@vger.kernel.org, paolo.valente@linaro.org, josef@toxicpanda.com, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, jack@suse.com, jlayton@kernel.org, dan.j.williams@intel.com, hch@infradead.org, djwong@kernel.org, dri-devel@lists.freedesktop.org, airlied@linux.ie, rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com, hamohammed.sa@gmail.com, 42.hyeyoo@gmail.com Subject: [PATCH RFC v6 08/21] dept: Apply Dept to rwsem Date: Wed, 4 May 2022 17:17:36 +0900 Message-Id: <1651652269-15342-9-git-send-email-byungchul.park@lge.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1651652269-15342-1-git-send-email-byungchul.park@lge.com> References: <1651652269-15342-1-git-send-email-byungchul.park@lge.com> X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Makes Dept able to track dependencies by rwsem. Signed-off-by: Byungchul Park --- include/linux/lockdep.h | 24 ++++++++++++++++++++---- include/linux/percpu-rwsem.h | 4 +++- include/linux/rwsem.h | 22 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index b59d8f3..b0e097f 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -634,10 +634,26 @@ static inline void print_irqtrace_events(struct task_struct *curr) dept_mutex_unlock(&(l)->dmap, i); \ } while (0) -#define rwsem_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i) -#define rwsem_acquire_nest(l, s, t, n, i) lock_acquire_exclusive(l, s, t, n, i) -#define rwsem_acquire_read(l, s, t, i) lock_acquire_shared(l, s, t, NULL, i) -#define rwsem_release(l, i) lock_release(l, i) +#define rwsem_acquire(l, s, t, i) \ +do { \ + lock_acquire_exclusive(l, s, t, NULL, i); \ + dept_rwsem_lock(&(l)->dmap, s, t, NULL, "up_write", i); \ +} while (0) +#define rwsem_acquire_nest(l, s, t, n, i) \ +do { \ + lock_acquire_exclusive(l, s, t, n, i); \ + dept_rwsem_lock(&(l)->dmap, s, t, (n) ? &(n)->dmap : NULL, "up_write", i);\ +} while (0) +#define rwsem_acquire_read(l, s, t, i) \ +do { \ + lock_acquire_shared(l, s, t, NULL, i); \ + dept_rwsem_lock(&(l)->dmap, s, t, NULL, "up_read", i); \ +} while (0) +#define rwsem_release(l, i) \ +do { \ + lock_release(l, i); \ + dept_rwsem_unlock(&(l)->dmap, i); \ +} while (0) #define lock_map_acquire(l) lock_acquire_exclusive(l, 0, 0, NULL, _THIS_IP_) #define lock_map_acquire_read(l) lock_acquire_shared_recursive(l, 0, 0, NULL, _THIS_IP_) diff --git a/include/linux/percpu-rwsem.h b/include/linux/percpu-rwsem.h index 5fda40f..9a0603d 100644 --- a/include/linux/percpu-rwsem.h +++ b/include/linux/percpu-rwsem.h @@ -21,7 +21,9 @@ struct percpu_rw_semaphore { }; #ifdef CONFIG_DEBUG_LOCK_ALLOC -#define __PERCPU_RWSEM_DEP_MAP_INIT(lockname) .dep_map = { .name = #lockname }, +#define __PERCPU_RWSEM_DEP_MAP_INIT(lockname) .dep_map = { \ + .name = #lockname, \ + .dmap = DEPT_MAP_INITIALIZER(lockname) }, #else #define __PERCPU_RWSEM_DEP_MAP_INIT(lockname) #endif diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index efa5c32..ed4c34e 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h @@ -21,6 +21,7 @@ .dep_map = { \ .name = #lockname, \ .wait_type_inner = LD_WAIT_SLEEP, \ + .dmap = DEPT_MAP_INITIALIZER(lockname) \ }, #else # define __RWSEM_DEP_MAP_INIT(lockname) @@ -32,6 +33,27 @@ #include #endif +#ifdef CONFIG_DEPT +#define dept_rwsem_lock(m, ne, t, n, e_fn, ip) \ +do { \ + if (t) { \ + dept_ecxt_enter(m, 1UL, ip, __func__, e_fn, ne); \ + } else if (n) { \ + dept_ecxt_enter_nokeep(m); \ + } else { \ + dept_wait(m, 1UL, ip, __func__, ne); \ + dept_ecxt_enter(m, 1UL, ip, __func__, e_fn, ne); \ + } \ +} while (0) +#define dept_rwsem_unlock(m, ip) \ +do { \ + dept_ecxt_exit(m, 1UL, ip); \ +} while (0) +#else +#define dept_rwsem_lock(m, ne, t, n, e_fn, ip) do { } while (0) +#define dept_rwsem_unlock(m, ip) do { } while (0) +#endif + /* * For an uncontended rwsem, count and owner are the only fields a task * needs to touch when acquiring the rwsem. So they are put next to each -- 1.9.1