From: Li Zetao <lizetao1@huawei.com>
To: <viro@zeniv.linux.org.uk>, <brauner@kernel.org>, <jack@suse.cz>,
<willy@infradead.org>, <akpm@linux-foundation.org>
Cc: <lizetao1@huawei.com>, <linux-fsdevel@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>
Subject: [RFC PATCH -next 1/3] mm: Support scope-based resource management for folio_lock/unlock
Date: Mon, 26 Aug 2024 15:10:34 +0800 [thread overview]
Message-ID: <20240826071036.2445717-2-lizetao1@huawei.com> (raw)
In-Reply-To: <20240826071036.2445717-1-lizetao1@huawei.com>
By introducing the DEFINE_LOCK_GUARD_1 definition, it is possible to
lock and unlock of folio's lock based on scope. At the same time, the
use of folio_trylock is also supported.
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
include/linux/pagemap.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index d9c7edb6422b..ed1831c115cc 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -1537,4 +1537,8 @@ unsigned int i_blocks_per_folio(struct inode *inode, struct folio *folio)
{
return folio_size(folio) >> inode->i_blkbits;
}
+
+DEFINE_LOCK_GUARD_1(folio, struct folio, folio_lock(_T->lock), folio_unlock(_T->lock))
+DEFINE_LOCK_GUARD_1_COND(folio, _try, folio_trylock(_T->lock))
+
#endif /* _LINUX_PAGEMAP_H */
--
2.34.1
next prev parent reply other threads:[~2024-08-26 7:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-26 7:10 [RFC PATCH -next 0/3] fs: Introduce the " Li Zetao
2024-08-26 7:10 ` Li Zetao [this message]
2024-08-26 7:10 ` [RFC PATCH -next 2/3] buffer: Using scope-based resource instead of folio_lock/unlock Li Zetao
2024-08-26 7:10 ` [RFC PATCH -next 3/3] splice: " Li Zetao
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=20240826071036.2445717-2-lizetao1@huawei.com \
--to=lizetao1@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=viro@zeniv.linux.org.uk \
--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