Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp713421iob; Wed, 4 May 2022 06:36:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTX+4PvKK01AF5a3fldrGuKxFJ2yCJpyOl1Um9LV7v0q6EswwE6UlmV/XVWt9Q+miV0Q2w X-Received: by 2002:a17:902:bf4c:b0:15c:3d1b:8a47 with SMTP id u12-20020a170902bf4c00b0015c3d1b8a47mr22452016pls.118.1651671419544; Wed, 04 May 2022 06:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651671419; cv=none; d=google.com; s=arc-20160816; b=T0gl7wDPKStcBXN8EBe3rBsEzqDSoy0SFhbSA1PaniB8imk2EQBqHeQ4fzJh0HFV1P QNUmNCu39AXWz9cMumm7IFRjE37k3Z+2tlOZ0D5P6P1Qc8jd/bl5zhsTzXuveEwxTNk4 VdidwfQVGRrFl8MM/QsyB69J35mpyCKPrknXqaNNw0eH+S2apAwGBwY+l8lRXnitZnaY YD/VJX4sBgP+/ykHhvkY8pFN2JZZM9B6sfhnwDx3LcNWmHma+cH+jOHdHFfIukrJiBJu t2itoG1InNRgBMiLej0yeTinxlW+CyPAeXNNv/c4wW83ZKlE+hvnnU1TbO+rmDkiomAM cN7w== 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=CBz8u+mQBiZx3mwzaQX5KiTl8FZTnWsC2BlE20LNlTw=; b=ndAM0EjafO1SrLByX4T+vRxwHs6hAwNiMg3EbJvBpctShrzXV21oV6cf24Az78xcTr TmcjRkDDVnrzGxjhc1q79EQeiPw1Bsv1uY48Y7fcG/LsRqLLcB69RDpsOw8bK7s58UcP 2RgZvafkdyZpQnmcl8ZRJ8lTsznmcNR1YUgIo8LbFvDPBLOZxC9NHWeZzRc4k3jw3Skn j3oMjz2vzYpNp05kzM5ZGufFkBoqAzHdOy8LdGCY7Z1rIJdon7M37TJxGNk2U/LiMJCp eubw9A3gQ1dx4aSbxTIVJ5RXpJyzs7RzDgrKBHbulGhL6THY7iDvw6oUSJtOehaX7kFN virQ== 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 js22-20020a17090b149600b001cbb3f8d111si4770440pjb.68.2022.05.04.06.36.34; Wed, 04 May 2022 06:36:59 -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 S1346687AbiEDIxX (ORCPT + 99 others); Wed, 4 May 2022 04:53:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346586AbiEDIxD (ORCPT ); Wed, 4 May 2022 04:53:03 -0400 Received: from lgeamrelo11.lge.com (lgeamrelo12.lge.com [156.147.23.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C5C3324F27 for ; Wed, 4 May 2022 01:49:20 -0700 (PDT) Received: from unknown (HELO lgeamrelo01.lge.com) (156.147.1.125) by 156.147.23.52 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 07/21] dept: Apply Dept to seqlock Date: Wed, 4 May 2022 17:17:35 +0900 Message-Id: <1651652269-15342-8-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=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 | 60 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index 37ded6b..47c3379 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -23,6 +23,23 @@ #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);\ +} while (0) +#define dept_seq_writeend(m, ip) \ +do { \ + 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 + /* * 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 +99,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, \ + .dmap = DEPT_MAP_INITIALIZER(lockname) } /** * seqcount_init() - runtime initializer for seqcount_t @@ -148,7 +166,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 +221,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 +305,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 +360,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 +412,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 +565,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 +592,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 +609,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