Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Apr 2021 13:08:31 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: e1d7503d6cf7 - stable/12 - libnv: Allow use in non-sleepable contexts
Message-ID:  <202104141308.13ED8VnS019405@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by kp:

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

commit e1d7503d6cf7ff18f29e7b3b0a8a3525b43414b8
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2021-03-25 12:59:14 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2021-04-14 08:17:25 +0000

    libnv: Allow use in non-sleepable contexts
    
    44c125c4cebc2fd87c6260b90eddae11201f5232 switched the nvlist allocations
    to be M_WAITOK, but this precludes the use in non-sleepable contexts.
    (E.g. with a nonsleepable lock held).
    
    All callers for these allocation functions already cope with memory
    alloation failures, so there's no reason to allow sleeping during
    allocations.
    
    Reviewed by:    melifaro, oshogbo
    MFC after:      1 week
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D29556
    
    (cherry picked from commit ab8d25880ebc9ddca1ae6af938680036349edf3f)
---
 sys/contrib/libnv/nv_impl.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/contrib/libnv/nv_impl.h b/sys/contrib/libnv/nv_impl.h
index 56e01a2bfb31..a67cc2ca0883 100644
--- a/sys/contrib/libnv/nv_impl.h
+++ b/sys/contrib/libnv/nv_impl.h
@@ -52,13 +52,13 @@ typedef struct nvpair nvpair_t;
 #define	NV_FLAG_IN_ARRAY		0x100
 
 #ifdef _KERNEL
-#define	nv_malloc(size)			malloc((size), M_NVLIST, M_WAITOK)
+#define	nv_malloc(size)			malloc((size), M_NVLIST, M_NOWAIT)
 #define	nv_calloc(n, size)		mallocarray((n), (size), M_NVLIST, \
-					    M_WAITOK | M_ZERO)
+					    M_NOWAIT | M_ZERO)
 #define	nv_realloc(buf, size)		realloc((buf), (size), M_NVLIST, \
-					    M_WAITOK)
+					    M_NOWAIT)
 #define	nv_free(buf)			free((buf), M_NVLIST)
-#define	nv_strdup(buf)			strdup((buf), M_NVLIST)
+#define	nv_strdup(buf)			strdup_flags((buf), M_NVLIST, M_NOWAIT)
 #define	nv_vasprintf(ptr, ...)		vasprintf(ptr, M_NVLIST, __VA_ARGS__)
 
 #define	ERRNO_SET(var)			do { } while (0)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104141308.13ED8VnS019405>