According to Ariane van der Steldt (ari...@stack.nl):
> On Thu, Dec 09, 2010 at 10:32:57PM +0100, Wouter Coene wrote:
> > +               addr = uvm_km_kmemalloc(kernel_map, NULL, PAGE_SIZE,
> > +                   UVM_KMF_CANFAIL |  UVM_KMF_ZERO);
> 
> If you specify NULL as your object, you'll be given intr-safe memory.
> You want to use kernel object instead:

Ah, now it makes sense. How about this diff:

Index: uvm.9
===================================================================
RCS file: /cvs/openbsd/src/share/man/man9/uvm.9,v
retrieving revision 1.42
diff -u -a -r1.42 uvm.9
--- uvm.9       9 Nov 2010 16:03:38 -0000       1.42
+++ uvm.9       10 Dec 2010 13:00:05 -0000
@@ -534,7 +534,12 @@
 .Fa size
 bytes of wired memory in the kernel map, zeroing the memory if the
 .Fa zeroit
-argument is non-zero.
+argument is non-zero. Unless called on an interrupt-safe map, if memory is
+currently unavailable,
+.Fn uvm_km_alloc1
+may sleep to wait for resources to be released by other processes. If not
+enough memory is available, this function returns
+.Dv NULL .
 .Pp
 The
 .Fn uvm_km_kmemalloc
@@ -542,6 +547,10 @@
 .Fa size
 bytes of wired kernel memory into
 .Fa obj .
+.Fa obj
+can only be
+.Dv NULL
+when allocating from an interrupt-safe map.
 The flags can be any of:
 .Bd -literal
 #define UVM_KMF_NOWAIT  0x1                     /* matches M_NOWAIT */
@@ -608,9 +617,9 @@
 bytes of memory in the kernel map, starting at address
 .Fa addr .
 .Fn uvm_km_free_wakeup
-calls
-.Fn thread_wakeup
-on the map before unlocking the map.
+wakes up any processes waiting for memory on the map (via 
+.Fn thread_wakeup )
+before unlocking the map.
 .Sh ALLOCATION OF PHYSICAL MEMORY
 .nr nS 1
 .Ft struct vm_page *

Also, maybe a stupid question, but why doesn't the irq-safety of the
allocation depend on the VM_MAP_INTRSAFE flag, like for uvm_km_free()?

Thanks,
Wouter Coene

Reply via email to