Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp399859pxp; Wed, 16 Mar 2022 08:04:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxj84qHH2AxS9KYAN6fQEUgKpzs4gVP1ljIfGHVm+Hy7eK5Gzcnzl8+kRAUh+XWAopgHJp9 X-Received: by 2002:aa7:d1cc:0:b0:416:60c6:9225 with SMTP id g12-20020aa7d1cc000000b0041660c69225mr30170746edp.71.1647443095329; Wed, 16 Mar 2022 08:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647443095; cv=none; d=google.com; s=arc-20160816; b=X3gDpAqPzRjO5sHbQ/NV1CeFTT0T+NpXNAUwnfhnKLWdJcpGOIQewHMMC+W4OuroNL 3IgRbQEhgmPHLZMOEQ+IlrsKqivOENf3KGjQmvSOusoF8jWVVKPmYhGeHgGr7SZgAv49 ZmbINcnOFfPO7GHAbFN5H59pylB35pjyPYjauiNOmfoOvE/MPcLgqOI6oNaFKSidIkUM kX4lKikRuK1Jv5Vkvx2GCc/nB4XLe/DA5kG+ATeJx23AJnOMpvCdy7EId58LpVJYA0zI iEOwSJewE5VlI4Ku4E+u6s9Wzi8oT287lAoC5N5wwMNhDU4oHjR5+KQDm73kDfy1bD/t Uopw== 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=gDzdbmxlsi7/tkPrbJrhN3Df2RFtEyzJ8u3szctAn/w=; b=y8lVf0LAsFdfa6g0rb0PjBi/zk1ARnCVQy5Yc88oz/aMY60SXRiN2N1QyvA9vTHRct OrB6bs/gvlpQcrjKk3y5RZrSVDlniu+lZTdrCCs2j2fO/cqJ1q+BHaGkXwXwNtow1/O9 Hw1Oq3Ih/FL5RsH3OzLmoBv4H8W+HUCkzZrzyCy7HtzsdEZkGXvxWzLrqoi42wwjpjwo vI96J9WxeYVBA0T/UGYWWrsonhLxT6O7kOWMVZ1zj2U2OaSa4b4Sc3V4/C2Aclh8Dm64 Bvvlfzvr3aHtuXVyLlDyhnQZCaeiUin5wImT/jhKNFj05CeZXlimNfeTWrBU3F+Nro/4 Ydvg== 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 l18-20020a1709067d5200b006cfe5e37c68si1285677ejp.302.2022.03.16.08.04.19; Wed, 16 Mar 2022 08:04:54 -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 S229528AbiCPC2k (ORCPT + 99 others); Tue, 15 Mar 2022 22:28:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353083AbiCPC2e (ORCPT ); Tue, 15 Mar 2022 22:28:34 -0400 Received: from lgeamrelo11.lge.com (lgeamrelo13.lge.com [156.147.23.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0C8815E75E for ; Tue, 15 Mar 2022 19:27:11 -0700 (PDT) Received: from unknown (HELO lgemrelse7q.lge.com) (156.147.1.151) by 156.147.23.53 with ESMTP; 16 Mar 2022 11:27:10 +0900 X-Original-SENDERIP: 156.147.1.151 X-Original-MAILFROM: byungchul.park@lge.com Received: from unknown (HELO localhost.localdomain) (10.177.244.38) by 156.147.1.151 with ESMTP; 16 Mar 2022 11:27:10 +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 Subject: [PATCH RFC v5 08/21] dept: Apply Dept to seqlock Date: Wed, 16 Mar 2022 11:26:20 +0900 Message-Id: <1647397593-16747-9-git-send-email-byungchul.park@lge.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1647397593-16747-1-git-send-email-byungchul.park@lge.com> References: <1647397593-16747-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, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 seqlock with adding wait annotation on read side of seqlock. Signed-off-by: Byungchul Park --- include/linux/seqlock.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index 37ded6b..585f45c 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -23,6 +23,31 @@ #include +#ifdef CONFIG_DEPT +#define DEPT_EVT_ALL ((1UL << DEPT_MAX_SUBCLASSES_EVT) - 1) +#define dept_seq_wait(m, ip) dept_wait(m, DEPT_EVT_ALL, ip, __func__, 0) +#define dept_seq_writebegin(m, ip) \ +do { \ + dept_ecxt_enter(m, 1UL, ip, __func__, "write_seqcount_end", 0);\ + dept_ask_event(m); \ +} while (0) +#define dept_seq_writeend(m, ip) \ +do { \ + dept_event(m, 1UL, ip, __func__); \ + dept_ecxt_exit(m, 1UL, ip); \ +} while (0) +#else +#define dept_seq_wait(m, ip) do { } while (0) +#define dept_seq_writebegin(m, ip) do { } while (0) +#define dept_seq_writeend(m, ip) do { } while (0) +#endif + +#ifdef CONFIG_DEPT +#define SEQ_DMAP_INIT(lockname) .dmap = { .name = #lockname } +#else +#define SEQ_DMAP_INIT(lockname) +#endif + /* * The seqlock seqcount_t interface does not prescribe a precise sequence of * read begin/retry/end. For readers, typically there is a call to @@ -82,7 +107,8 @@ static inline void __seqcount_init(seqcount_t *s, const char *name, #ifdef CONFIG_DEBUG_LOCK_ALLOC # define SEQCOUNT_DEP_MAP_INIT(lockname) \ - .dep_map = { .name = #lockname } + .dep_map = { .name = #lockname, \ + SEQ_DMAP_INIT(lockname) } /** * seqcount_init() - runtime initializer for seqcount_t @@ -148,7 +174,7 @@ static inline void seqcount_lockdep_reader_access(const seqcount_t *s) * This lock-unlock technique must be implemented for all of PREEMPT_RT * sleeping locks. See Documentation/locking/locktypes.rst */ -#if defined(CONFIG_LOCKDEP) || defined(CONFIG_PREEMPT_RT) +#if defined(CONFIG_LOCKDEP) || defined(CONFIG_DEPT) || defined(CONFIG_PREEMPT_RT) #define __SEQ_LOCK(expr) expr #else #define __SEQ_LOCK(expr) @@ -203,6 +229,22 @@ static inline void seqcount_lockdep_reader_access(const seqcount_t *s) __SEQ_LOCK(locktype *lock); \ } seqcount_##lockname##_t; \ \ +static __always_inline void \ +__seqprop_##lockname##_wait(const seqcount_##lockname##_t *s) \ +{ \ + __SEQ_LOCK(dept_seq_wait(&(lockmember)->dep_map.dmap, _RET_IP_));\ +} \ + \ +static __always_inline void \ +__seqprop_##lockname##_writebegin(const seqcount_##lockname##_t *s) \ +{ \ +} \ + \ +static __always_inline void \ +__seqprop_##lockname##_writeend(const seqcount_##lockname##_t *s) \ +{ \ +} \ + \ static __always_inline seqcount_t * \ __seqprop_##lockname##_ptr(seqcount_##lockname##_t *s) \ { \ @@ -271,6 +313,21 @@ static inline void __seqprop_assert(const seqcount_t *s) lockdep_assert_preemption_disabled(); } +static inline void __seqprop_wait(seqcount_t *s) +{ + dept_seq_wait(&s->dep_map.dmap, _RET_IP_); +} + +static inline void __seqprop_writebegin(seqcount_t *s) +{ + dept_seq_writebegin(&s->dep_map.dmap, _RET_IP_); +} + +static inline void __seqprop_writeend(seqcount_t *s) +{ + dept_seq_writeend(&s->dep_map.dmap, _RET_IP_); +} + #define __SEQ_RT IS_ENABLED(CONFIG_PREEMPT_RT) SEQCOUNT_LOCKNAME(raw_spinlock, raw_spinlock_t, false, s->lock, raw_spin, raw_spin_lock(s->lock)) @@ -311,6 +368,9 @@ static inline void __seqprop_assert(const seqcount_t *s) #define seqprop_sequence(s) __seqprop(s, sequence) #define seqprop_preemptible(s) __seqprop(s, preemptible) #define seqprop_assert(s) __seqprop(s, assert) +#define seqprop_dept_wait(s) __seqprop(s, wait) +#define seqprop_dept_writebegin(s) __seqprop(s, writebegin) +#define seqprop_dept_writeend(s) __seqprop(s, writeend) /** * __read_seqcount_begin() - begin a seqcount_t read section w/o barrier @@ -360,6 +420,7 @@ static inline void __seqprop_assert(const seqcount_t *s) #define read_seqcount_begin(s) \ ({ \ seqcount_lockdep_reader_access(seqprop_ptr(s)); \ + seqprop_dept_wait(s); \ raw_read_seqcount_begin(s); \ }) @@ -512,6 +573,7 @@ static inline void do_raw_write_seqcount_end(seqcount_t *s) preempt_disable(); \ \ do_write_seqcount_begin_nested(seqprop_ptr(s), subclass); \ + seqprop_dept_writebegin(s); \ } while (0) static inline void do_write_seqcount_begin_nested(seqcount_t *s, int subclass) @@ -538,6 +600,7 @@ static inline void do_write_seqcount_begin_nested(seqcount_t *s, int subclass) preempt_disable(); \ \ do_write_seqcount_begin(seqprop_ptr(s)); \ + seqprop_dept_writebegin(s); \ } while (0) static inline void do_write_seqcount_begin(seqcount_t *s) @@ -554,6 +617,7 @@ static inline void do_write_seqcount_begin(seqcount_t *s) */ #define write_seqcount_end(s) \ do { \ + seqprop_dept_writeend(s); \ do_write_seqcount_end(seqprop_ptr(s)); \ \ if (seqprop_preemptible(s)) \ -- 1.9.1