--- old/usr/src/common/core/core_shstrtab.c	Tue Feb  1 13:10:47 2022
+++ new/usr/src/common/core/core_shstrtab.c	Tue Feb  1 13:10:47 2022
@@ -46,8 +46,7 @@
 shstrtab_alloc(void)
 {
 #ifdef	_KERNEL
-	return (kmem_zalloc(sizeof (shstrtab_ent_t),
-	    KM_NOSLEEP | KM_NORMALPRI));
+	return (kmem_zalloc(sizeof (shstrtab_ent_t), KM_NOSLEEP_LAZY));
 #else
 	return (calloc(1, sizeof (shstrtab_ent_t)));
 #endif
--- old/usr/src/man/man9f/kmem_alloc.9f	Tue Feb  1 13:10:47 2022
+++ new/usr/src/man/man9f/kmem_alloc.9f	Tue Feb  1 13:10:47 2022
@@ -1,5 +1,6 @@
 '\" te
 .\" Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
+.\" Copyright 2022 Joyent, Inc.
 .\"  Copyright 1989 AT&T
 .\"  Copyright (c) 2006, Sun Microsystems, Inc.,  All Rights Reserved
 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
@@ -46,8 +47,14 @@
 .ad
 .RS 8n
 Determines whether caller can sleep for memory. Possible flags are
-\fBKM_SLEEP\fR to allow sleeping until memory is available, or \fBKM_NOSLEEP\fR
-to return \fINULL\fR immediately if memory is not available.
+\fBKM_SLEEP\fR to allow sleeping until memory is available, \fBKM_NOSLEEP\fR
+to return \fINULL\fR if memory is not available even after some reclamation
+attempts, and \fBKM_NOSLEEP_LAZY\fR to return \fINULL\fR without reclamation
+attempts.  \fBKM_NOSLEEP_LAZY\fR is actually two flags combined:
+(\fBKM_NOSLEEP\fR | \fBKM_NORMALPRI\fR), the latter flag indicating not to
+attempt reclamation before giving up and returning NULL.  If any mention of
+\fBKM_NOSLEEP\fR appears in this man page by itself, it applies equally to
+\fBKM_NOSLEEP_LAZY\fR as well.
 .RE
 
 .sp
@@ -65,9 +72,12 @@
 double-word aligned, so it can hold any C data structure. No greater alignment
 can be assumed. \fIflag\fR determines whether the caller can sleep for memory.
 \fBKM_SLEEP\fR allocations may sleep but are guaranteed to succeed.
-\fBKM_NOSLEEP\fR allocations are guaranteed not to sleep but may fail (return
-\fINULL\fR) if no memory is currently available. The initial contents of memory
-allocated using \fBkmem_alloc()\fR are random garbage.
+\fBKM_NOSLEEP\fR and \fBKM_NOSLEEP_LAZY\fR allocations are guaranteed not to
+sleep but may fail (return \fINULL\fR) if no memory is currently
+available. \fBKM_NOSLEEP\fR will first attempt to aggressively reclaim memory
+from otherwise unused blocks, while \fBKM_NOSLEEP_LAZY\fR will not attempt any
+reclamation. The initial contents of memory allocated using
+\fBkmem_alloc()\fR are random garbage.
 .sp
 .LP
 The \fBkmem_zalloc()\fR function is like \fBkmem_alloc()\fR but returns
@@ -79,13 +89,14 @@
 cannot be returned piecemeal.
 .SH RETURN VALUES
 If successful, \fBkmem_alloc()\fR and \fBkmem_zalloc()\fR return a pointer to
-the allocated memory. If \fBKM_NOSLEEP\fR is set and memory cannot be allocated
-without sleeping, \fBkmem_alloc()\fR and \fBkmem_zalloc()\fR return \fINULL\fR.
+the allocated memory. If \fBKM_NOSLEEP\fR is set and memory cannot be
+allocated without sleeping, \fBkmem_alloc()\fR and \fBkmem_zalloc()\fR return
+\fINULL\fR.
 .SH CONTEXT
 The \fBkmem_alloc()\fR and \fBkmem_zalloc()\fR functions can be called from
-interrupt context only if the \fBKM_NOSLEEP\fR flag is set. They can be called
-from user context with any valid \fIflag\fR. The \fBkmem_free()\fR function can
-be called from from user, interrupt, or kernel context.
+interrupt context only if the \fBKM_NOSLEEP\fR flag is set. They can be
+called from user context with any valid \fIflag\fR. The \fBkmem_free()\fR
+function can be called from from user, interrupt, or kernel context.
 .SH SEE ALSO
 \fBcopyout\fR(9F), \fBfreerbuf\fR(9F), \fBgetrbuf\fR(9F)
 .sp
--- old/usr/src/man/man9f/kmem_cache_create.9f	Tue Feb  1 13:10:47 2022
+++ new/usr/src/man/man9f/kmem_cache_create.9f	Tue Feb  1 13:10:47 2022
@@ -1,5 +1,6 @@
 '\" te
 .\" Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
+.\" Copyright 2022 Joyent, Inc.
 .\" Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved.
 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
@@ -169,12 +170,26 @@
 \fB\fBKM_NOSLEEP\fR\fR
 .ad
 .RS 15n
-Return NULL immediately if memory is not available.
+Return NULL immediately if memory is not available, but after an aggressive
+reclaiming attempt.  Any mention of \fBKM_NOSLEEP\fR without mentioning
+\fBKM_NOSLEEP_LAZY\fR (see below) applies to both values.
 .RE
 
 .sp
 .ne 2
 .na
+\fB\fBKM_NOSLEEP_LAZY\fR\fR
+.ad
+.RS 15n
+Return NULL immediately if memory is not available, without the aggressive
+reclaiming attempt.  This is actually two flags combined:
+(\fBKM_NOSLEEP\fR | \fBKM_NORMALPRI\fR), the latter flag indicating not to
+attempt reclamation before giving up and returning NULL.
+.RE
+
+.sp
+.ne 2
+.na
 \fB\fBKM_PUSHPAGE\fR\fR
 .ad
 .RS 15n
@@ -350,8 +365,8 @@
 .LP
 \fBkmem_cache_alloc()\fR gets an object from the cache. The object will be in
 its constructed state. \fIkmflag\fR has either \fBKM_SLEEP\fR or
-\fBKM_NOSLEEP\fR set, indicating whether it is acceptable to wait for memory if
-none is currently available.
+\fBKM_NOSLEEP\fR set, indicating whether it is acceptable to wait for memory
+if none is currently available.
 .sp
 .LP
 A small pool of reserved memory is available to allow the system to progress
@@ -573,8 +588,8 @@
 .sp
 .LP
 \fBkmem_cache_alloc()\fR can be called from interrupt context only if the
-\fBKM_NOSLEEP\fR flag is set. It can be called from user or kernel context with
-any valid flag.
+\fBKM_NOSLEEP\fR flag is set. It can be called from user or kernel context
+with any valid flag.
 .sp
 .LP
 \fBkmem_cache_free()\fR can be called from user, kernel, or interrupt context.
@@ -709,9 +724,11 @@
 .in -2
 
 .SH RETURN VALUES
-If successful, the constructor function must return \fB0\fR. If KM_NOSLEEP is
-set and memory cannot be allocated without sleeping, the constructor must
-return -\fB1\fR.
+If successful, the constructor function must return \fB0\fR. If
+\fBKM_NOSLEEP\fR or \fBKM_NOSLEEP_LAZY\fR is set and memory cannot be
+allocated without sleeping, the constructor must return -\fB1\fR.  If the
+constructor takes extraordinary steps during a \fBKM_NOSLEEP\fR construction,
+it may not take those for a \fBKM_NOSLEEP_LAZY\fR construction.
 .sp
 .LP
 \fBkmem_cache_create()\fR returns a pointer to the allocated cache.
--- old/usr/src/uts/common/dtrace/dtrace.c	Tue Feb  1 13:10:47 2022
+++ new/usr/src/uts/common/dtrace/dtrace.c	Tue Feb  1 13:10:47 2022
@@ -11603,8 +11603,8 @@
 
 		ASSERT(buf->dtb_xamot == NULL);
 
-		if ((buf->dtb_tomax = kmem_zalloc(size,
-		    KM_NOSLEEP | KM_NORMALPRI)) == NULL)
+		if ((buf->dtb_tomax = kmem_zalloc(size, KM_NOSLEEP_LAZY)) ==
+		    NULL)
 			goto err;
 
 		buf->dtb_size = size;
@@ -11615,8 +11615,8 @@
 		if (flags & DTRACEBUF_NOSWITCH)
 			continue;
 
-		if ((buf->dtb_xamot = kmem_zalloc(size,
-		    KM_NOSLEEP | KM_NORMALPRI)) == NULL)
+		if ((buf->dtb_xamot = kmem_zalloc(size, KM_NOSLEEP_LAZY)) ==
+		    NULL)
 			goto err;
 	} while ((cp = cp->cpu_next) != cpu_list);
 
@@ -13564,7 +13564,7 @@
 	if (size < (min = dstate->dtds_chunksize + sizeof (dtrace_dynhash_t)))
 		size = min;
 
-	if ((base = kmem_zalloc(size, KM_NOSLEEP | KM_NORMALPRI)) == NULL)
+	if ((base = kmem_zalloc(size, KM_NOSLEEP_LAZY)) == NULL)
 		return (ENOMEM);
 
 	dstate->dtds_size = size;
@@ -14091,7 +14091,7 @@
 	}
 
 	spec = kmem_zalloc(nspec * sizeof (dtrace_speculation_t),
-	    KM_NOSLEEP | KM_NORMALPRI);
+	    KM_NOSLEEP_LAZY);
 
 	if (spec == NULL) {
 		rval = ENOMEM;
@@ -14102,8 +14102,7 @@
 	state->dts_nspeculations = (int)nspec;
 
 	for (i = 0; i < nspec; i++) {
-		if ((buf = kmem_zalloc(bufsize,
-		    KM_NOSLEEP | KM_NORMALPRI)) == NULL) {
+		if ((buf = kmem_zalloc(bufsize, KM_NOSLEEP_LAZY)) == NULL) {
 			rval = ENOMEM;
 			goto err;
 		}
--- old/usr/src/uts/common/fs/bootfs/bootfs_vfsops.c	Tue Feb  1 13:10:48 2022
+++ new/usr/src/uts/common/fs/bootfs/bootfs_vfsops.c	Tue Feb  1 13:10:48 2022
@@ -93,7 +93,7 @@
 	 * there's nothing to be done about that.
 	 */
 	vfs_setresource(vfsp, bootfs_name, 0);
-	bfs = kmem_zalloc(sizeof (bootfs_t), KM_NOSLEEP | KM_NORMALPRI);
+	bfs = kmem_zalloc(sizeof (bootfs_t), KM_NOSLEEP_LAZY);
 	if (bfs == NULL)
 		return (ENOMEM);
 
--- old/usr/src/uts/common/fs/nfs/nfs_auth.c	Tue Feb  1 13:10:48 2022
+++ new/usr/src/uts/common/fs/nfs/nfs_auth.c	Tue Feb  1 13:10:48 2022
@@ -922,7 +922,7 @@
 
 		rw_exit(&exi->exi_cache_lock);
 
-		nc = kmem_alloc(sizeof (*nc), KM_NOSLEEP | KM_NORMALPRI);
+		nc = kmem_alloc(sizeof (*nc), KM_NOSLEEP_LAZY);
 		if (nc == NULL)
 			goto retrieve;
 
@@ -930,8 +930,7 @@
 		 * Initialize the new auth_cache_clnt
 		 */
 		nc->authc_addr = addr;
-		nc->authc_addr.buf = kmem_alloc(addr.maxlen,
-		    KM_NOSLEEP | KM_NORMALPRI);
+		nc->authc_addr.buf = kmem_alloc(addr.maxlen, KM_NOSLEEP_LAZY);
 		if (addr.maxlen != 0 && nc->authc_addr.buf == NULL) {
 			kmem_free(nc, sizeof (*nc));
 			goto retrieve;
@@ -972,8 +971,7 @@
 
 		rw_exit(&c->authc_lock);
 
-		np = kmem_cache_alloc(exi_cache_handle,
-		    KM_NOSLEEP | KM_NORMALPRI);
+		np = kmem_cache_alloc(exi_cache_handle, KM_NOSLEEP_LAZY);
 		if (np == NULL) {
 			rw_exit(&exi->exi_cache_lock);
 			goto retrieve;
@@ -1071,7 +1069,7 @@
 				 * auth_cache entry
 				 */
 				tmpgids = kmem_alloc(tmpngids * sizeof (gid_t),
-				    KM_NOSLEEP | KM_NORMALPRI);
+				    KM_NOSLEEP_LAZY);
 				if (tmpgids != NULL)
 					bcopy(*gids, tmpgids,
 					    tmpngids * sizeof (gid_t));
--- old/usr/src/uts/common/fs/smbsrv/smb2_fsctl_copychunk.c	Tue Feb  1 13:10:48 2022
+++ new/usr/src/uts/common/fs/smbsrv/smb2_fsctl_copychunk.c	Tue Feb  1 13:10:48 2022
@@ -204,7 +204,7 @@
 	 * The client should then fall back to normal copy.
 	 */
 	args->bufsize = smb2_copychunk_max_seg;
-	args->buffer = kmem_alloc(args->bufsize, KM_NOSLEEP | KM_NORMALPRI);
+	args->buffer = kmem_alloc(args->bufsize, KM_NOSLEEP_LAZY);
 	if (args->buffer == NULL) {
 		status = NT_STATUS_INSUFF_SERVER_RESOURCES;
 		goto out;
--- old/usr/src/uts/common/fs/smbsrv/smb2_fsctl_odx.c	Tue Feb  1 13:10:48 2022
+++ new/usr/src/uts/common/fs/smbsrv/smb2_fsctl_odx.c	Tue Feb  1 13:10:48 2022
@@ -667,7 +667,7 @@
 	 * allow the allocation to fail and return an error.
 	 * The client should then fall back to normal copy.
 	 */
-	buffer = kmem_alloc(bufsize, KM_NOSLEEP | KM_NORMALPRI);
+	buffer = kmem_alloc(bufsize, KM_NOSLEEP_LAZY);
 	if (buffer == NULL) {
 		status = NT_STATUS_INSUFF_SERVER_RESOURCES;
 		goto out;
--- old/usr/src/uts/common/fs/zfs/zcp.c	Tue Feb  1 13:10:48 2022
+++ new/usr/src/uts/common/fs/zfs/zcp.c	Tue Feb  1 13:10:48 2022
@@ -718,8 +718,7 @@
 zcp_lua_alloc(void *ud, void *ptr, size_t osize, size_t nsize)
 {
 	zcp_alloc_arg_t *allocargs = ud;
-	int flags = (allocargs->aa_must_succeed) ?
-	    KM_SLEEP : (KM_NOSLEEP | KM_NORMALPRI);
+	int flags = (allocargs->aa_must_succeed) ? KM_SLEEP : KM_NOSLEEP_LAZY;
 
 	if (nsize == 0) {
 		if (ptr != NULL) {
--- old/usr/src/uts/common/inet/ip/ip_attr.c	Tue Feb  1 13:10:48 2022
+++ new/usr/src/uts/common/inet/ip/ip_attr.c	Tue Feb  1 13:10:48 2022
@@ -862,7 +862,7 @@
 	ip_xmit_attr_t *oldixa;
 	ip_xmit_attr_t *ixa;
 
-	ixa = kmem_alloc(sizeof (*ixa), KM_NOSLEEP | KM_NORMALPRI);
+	ixa = kmem_alloc(sizeof (*ixa), KM_NOSLEEP_LAZY);
 	if (ixa == NULL)
 		return (NULL);
 
--- old/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd_scsi.c	Tue Feb  1 13:10:48 2022
+++ new/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd_scsi.c	Tue Feb  1 13:10:48 2022
@@ -2389,7 +2389,7 @@
 	 * Don't sleep for the allocation, and don't make the system
 	 * reclaim memory.  Trade higher I/Os if in a low-memory situation.
 	 */
-	big_buf = kmem_alloc(big_buf_size, KM_NOSLEEP | KM_NORMALPRI);
+	big_buf = kmem_alloc(big_buf_size, KM_NOSLEEP_LAZY);
 
 	if (big_buf == NULL) {
 		/*
--- old/usr/src/uts/common/io/mac/mac_protect.c	Tue Feb  1 13:10:49 2022
+++ new/usr/src/uts/common/io/mac/mac_protect.c	Tue Feb  1 13:10:49 2022
@@ -1469,8 +1469,8 @@
 		return;
 	}
 
-	if ((addr = kmem_zalloc(sizeof (slaac_addr_t),
-	    KM_NOSLEEP | KM_NORMALPRI)) == NULL)
+	if ((addr = kmem_zalloc(sizeof (slaac_addr_t), KM_NOSLEEP_LAZY)) ==
+	    NULL)
 		return;
 
 	bcopy(&po->nd_opt_pi_prefix, &addr->sla_prefix,
--- old/usr/src/uts/common/io/sata/adapters/ahci/ahci.c	Tue Feb  1 13:10:49 2022
+++ new/usr/src/uts/common/io/sata/adapters/ahci/ahci.c	Tue Feb  1 13:10:49 2022
@@ -10766,7 +10766,7 @@
 		return (ENOTSUP);
 	}
 
-	task = kmem_alloc(sizeof (*task), KM_NOSLEEP | KM_NORMALPRI);
+	task = kmem_alloc(sizeof (*task), KM_NOSLEEP_LAZY);
 	if (task == NULL) {
 		return (ENOMEM);
 	}
--- old/usr/src/uts/common/io/ufmtest.c	Tue Feb  1 13:10:49 2022
+++ new/usr/src/uts/common/io/ufmtest.c	Tue Feb  1 13:10:49 2022
@@ -256,7 +256,7 @@
 		ufmt.ufmt_nvl = NULL;
 	}
 
-	nvlbuf = kmem_zalloc(setfw.utsw_bufsz, KM_NOSLEEP | KM_NORMALPRI);
+	nvlbuf = kmem_zalloc(setfw.utsw_bufsz, KM_NOSLEEP_LAZY);
 	if (nvlbuf == NULL)
 		return (ENOMEM);
 
--- old/usr/src/uts/common/io/usb/clients/ccid/ccid.c	Tue Feb  1 13:10:49 2022
+++ new/usr/src/uts/common/io/usb/clients/ccid/ccid.c	Tue Feb  1 13:10:49 2022
@@ -1636,7 +1636,7 @@
 		kmflag = KM_SLEEP;
 		usbflag = USB_FLAGS_SLEEP;
 	} else {
-		kmflag = KM_NOSLEEP | KM_NORMALPRI;
+		kmflag = KM_NOSLEEP_LAZY;
 		usbflag = 0;
 	}
 
--- old/usr/src/uts/common/os/ddi_ufm.c	Tue Feb  1 13:10:49 2022
+++ new/usr/src/uts/common/os/ddi_ufm.c	Tue Feb  1 13:10:49 2022
@@ -181,7 +181,7 @@
 	 */
 	ufmh->ufmh_images =
 	    kmem_zalloc((sizeof (ddi_ufm_image_t) * ufmh->ufmh_nimages),
-	    KM_NOSLEEP | KM_NORMALPRI);
+	    KM_NOSLEEP_LAZY);
 	if (ufmh->ufmh_images == NULL)
 		return (ENOMEM);
 
@@ -201,7 +201,7 @@
 
 		img->ufmi_slots =
 		    kmem_zalloc((sizeof (ddi_ufm_slot_t) * img->ufmi_nslots),
-		    KM_NOSLEEP | KM_NORMALPRI);
+		    KM_NOSLEEP_LAZY);
 		if (img->ufmi_slots == NULL) {
 			ret = ENOMEM;
 			goto cache_fail;
--- old/usr/src/uts/common/os/vm_pageout.c	Tue Feb  1 13:10:49 2022
+++ new/usr/src/uts/common/os/vm_pageout.c	Tue Feb  1 13:10:49 2022
@@ -133,7 +133,7 @@
  *   v allocations (e.g., KM_SLEEP) are held here while we wait for
  *   | more memory.  Non-sleeping allocations are generally allowed to
  *   | proceed, unless their priority is explicitly lowered with
- *   | KM_NORMALPRI.
+ *   | KM_NORMALPRI (Note: KM_NOSLEEP_LAZY == (KM_NOSLEEP | KM_NORMALPRI).).
  *   |
  *   +------- pageout_reserve (3/4 of throttlefree, 0.44% of physmem, min. 4MB)
  *   |
--- old/usr/src/uts/common/sys/kmem.h	Tue Feb  1 13:10:49 2022
+++ new/usr/src/uts/common/sys/kmem.h	Tue Feb  1 13:10:49 2022
@@ -23,7 +23,7 @@
  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012 by Delphix. All rights reserved.
  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
- * Copyright 2018, Joyent, Inc.
+ * Copyright 2022 Joyent, Inc.
  */
 
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -49,6 +49,7 @@
 #define	KM_PANIC	0x0002	/* if memory cannot be allocated, panic */
 #define	KM_PUSHPAGE	0x0004	/* can block for memory; may use reserve */
 #define	KM_NORMALPRI	0x0008  /* with KM_NOSLEEP, lower priority allocation */
+#define	KM_NOSLEEP_LAZY	(KM_NOSLEEP | KM_NORMALPRI)  /* Syntactic sugar. */
 #define	KM_VMFLAGS	0x00ff	/* flags that must match VM_* flags */
 
 #define	KM_FLAGS	0xffff	/* all settable kmem flags */
--- old/usr/src/uts/intel/io/imc/imc.c	Tue Feb  1 13:10:50 2022
+++ new/usr/src/uts/intel/io/imc/imc.c	Tue Feb  1 13:10:50 2022
@@ -1405,7 +1405,7 @@
 	if (sleep) {
 		kmflag = KM_SLEEP;
 	} else {
-		kmflag = KM_NOSLEEP | KM_NORMALPRI;
+		kmflag = KM_NOSLEEP_LAZY;
 	}
 
 	if (nvlist_pack(sock->isock_nvl, &buf, &len, NV_ENCODE_XDR,
@@ -1432,7 +1432,7 @@
 	}
 
 	if (nvlist_pack(imc->imc_decoder_dump, &buf, &len, NV_ENCODE_XDR,
-	    KM_NOSLEEP | KM_NORMALPRI) != 0) {
+	    KM_NOSLEEP_LAZY) != 0) {
 		return;
 	}
 
