git: 640c2ff8ae9b - stable/13 - ufs: Avoid M_WAITOK allocations when building a dirhash

Mark Johnston markj at FreeBSD.org
Thu May 27 13:06:03 UTC 2021


The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=640c2ff8ae9bdbad91aa25094123bb97e5a92bbf

commit 640c2ff8ae9bdbad91aa25094123bb97e5a92bbf
Author:     Don Morris <dgmorris at earthlink.net>
AuthorDate: 2021-05-20 14:54:38 +0000
Commit:     Mark Johnston <markj at FreeBSD.org>
CommitDate: 2021-05-27 13:05:50 +0000

    ufs: Avoid M_WAITOK allocations when building a dirhash
    
    At this point the directory's vnode lock is held, so blocking while
    waiting for free pages makes the system more susceptible to deadlock in
    low memory conditions.  This is particularly problematic on NUMA systems
    as UMA currently implements a strict first-touch policy.
    
    ufsdirhash_build() already uses M_NOWAIT for other allocations and
    already handled failures for the block array allocation, so just convert
    to M_NOWAIT.
    
    PR:             253992
    Reviewed by:    markj, mckusick, vangyzen
    
    (cherry picked from commit f17a5900850b4d449a91cbe9c61dfb62373c3cd1)
---
 sys/ufs/ufs/ufs_dirhash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/ufs/ufs/ufs_dirhash.c b/sys/ufs/ufs/ufs_dirhash.c
index 13094b5a1c97..d1e1bed0bde4 100644
--- a/sys/ufs/ufs/ufs_dirhash.c
+++ b/sys/ufs/ufs/ufs_dirhash.c
@@ -108,7 +108,7 @@ static uma_zone_t	ufsdirhash_zone;
 
 #define DIRHASHLIST_LOCK() 		mtx_lock(&ufsdirhash_mtx)
 #define DIRHASHLIST_UNLOCK() 		mtx_unlock(&ufsdirhash_mtx)
-#define DIRHASH_BLKALLOC_WAITOK() 	uma_zalloc(ufsdirhash_zone, M_WAITOK)
+#define DIRHASH_BLKALLOC() 		uma_zalloc(ufsdirhash_zone, M_NOWAIT)
 #define DIRHASH_BLKFREE(ptr) 		uma_zfree(ufsdirhash_zone, (ptr))
 #define	DIRHASH_ASSERT_LOCKED(dh)					\
     sx_assert(&(dh)->dh_lock, SA_LOCKED)
@@ -425,7 +425,7 @@ ufsdirhash_build(struct inode *ip)
 	if (dh->dh_blkfree == NULL)
 		goto fail;
 	for (i = 0; i < narrays; i++) {
-		if ((dh->dh_hash[i] = DIRHASH_BLKALLOC_WAITOK()) == NULL)
+		if ((dh->dh_hash[i] = DIRHASH_BLKALLOC()) == NULL)
 			goto fail;
 		for (j = 0; j < DH_NBLKOFF; j++)
 			dh->dh_hash[i][j] = DIRHASH_EMPTY;


More information about the dev-commits-src-all mailing list