linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Schmidt <mschmidt@redhat.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] xarray: add guard definitions for xa_lock
Date: Wed, 28 Feb 2024 14:53:52 +0100	[thread overview]
Message-ID: <20240228135352.14444-1-mschmidt@redhat.com> (raw)

Add DEFINE_GUARD definitions so that xa_lock can be used with guard() or
scoped_guard().

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
---
 include/linux/xarray.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/include/linux/xarray.h b/include/linux/xarray.h
index cb571dfcf4b1..73a8fc0e830a 100644
--- a/include/linux/xarray.h
+++ b/include/linux/xarray.h
@@ -11,6 +11,7 @@
 
 #include <linux/bitmap.h>
 #include <linux/bug.h>
+#include <linux/cleanup.h>
 #include <linux/compiler.h>
 #include <linux/gfp.h>
 #include <linux/kconfig.h>
@@ -1883,4 +1884,19 @@ static inline void *xas_next(struct xa_state *xas)
 	return xa_entry(xas->xa, node, xas->xa_offset);
 }
 
+DEFINE_GUARD(xa_lock, struct xarray *,
+	     xa_lock(_T),
+	     xa_unlock(_T))
+DEFINE_GUARD(xa_lock_bh, struct xarray *,
+	     xa_lock_bh(_T),
+	     xa_unlock_bh(_T))
+DEFINE_GUARD(xa_lock_irq, struct xarray *,
+	     xa_lock_irq(_T),
+	     xa_unlock_irq(_T))
+DEFINE_GUARD_COND(xa_lock, _try, xa_trylock(_T))
+DEFINE_LOCK_GUARD_1(xa_lock_irqsave, struct xarray,
+		    xa_lock_irqsave(_T->lock, _T->flags),
+		    xa_unlock_irqrestore(_T->lock, _T->flags),
+		    unsigned long flags)
+
 #endif /* _LINUX_XARRAY_H */
-- 
2.43.2


                 reply	other threads:[~2024-02-28 13:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240228135352.14444-1-mschmidt@redhat.com \
    --to=mschmidt@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).