[RFC PATCH -next 1/3] mm: Support scope-based resource management for folio_lock/unlock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux