[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20230913085907.GB692@noisy.programming.kicks-ass.net>
Date: Wed, 13 Sep 2023 10:59:07 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: "Darrick J. Wong" <djwong@...nel.org>
Cc: Matthew Wilcox <willy@...radead.org>,
Dave Chinner <david@...morbit.com>,
Waiman Long <longman@...hat.com>,
Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Chandan Babu R <chandan.babu@...cle.com>,
linux-xfs@...r.kernel.org
Subject: Re: [PATCH 1/5] locking: Add rwsem_is_write_locked()
On Tue, Sep 12, 2023 at 08:27:15AM -0700, Darrick J. Wong wrote:
> I could live with Longman's suggestion of an rwsem_assert_is_locked that
> only exists if DEBUG_RWSEMS is enabled. Something like:
>
> #ifdef CONFIG_DEBUG_RWSEMS
> static inline bool __rwsem_assert_is_locked(struct rw_semaphore *rwsem,
> const char *file, int line)
> {
> bool ret = rwsem_is_locked(rwsem);
> if (!ret)
> WARN(1, "!rwsem_is_locked(rwsem) at %s line %d", file, line);
> return ret;
> }
> #define rwsem_assert_is_locked(r) \
> __rwsem_assert_is_locked((r), __FILE__, __LINE__)
> #endif
>
> and then XFS could do:
>
> ASSERT(rwsem_assert_is_locked(&VFS_I(ip)->i_rwsem));
>
> Wherein ASSERT is only #defined if CONFIG_XFS_DEBUG, and XFS_DEBUG
> selects DEBUG_RWSEMS, per Longman's suggestion. That's work for what we
> want it for (simple cheap lock checking) without becoming a general
> lockabuse predicate.
Ack.
Powered by blists - more mailing lists