In message <[EMAIL PROTECTED]>, Warner Losh write
s:
>imp         2003/02/18 21:47:47 PST
>
>  Modified files:
>    [... everything ...]
>                         uma_core.c vm_map.c vm_object.c 
>  Log:
>  Back out M_* changes, per decision of the TRB.
>  
>  Approved by: trb

The attached patch will print a backtrace if any calls to malloc
fail to have either M_WAITOK or M_NOWAIT.

Please put this patch in your tree and help fix any issues.

So far (10 minutes) my disk-less testbox has found no issues.

Poul-Henning


Index: kern/kern_malloc.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_malloc.c,v
retrieving revision 1.116
diff -u -r1.116 kern_malloc.c
--- kern/kern_malloc.c  19 Feb 2003 05:47:25 -0000      1.116
+++ kern/kern_malloc.c  19 Feb 2003 07:55:19 -0000
@@ -167,11 +167,21 @@
 #endif
        register struct malloc_type *ksp = type;
 
+       indx = flags & (M_WAITOK | M_NOWAIT);
+       if (indx == M_NOWAIT) {
+               /* OK */
+       } else if (indx == M_WAITOK) {
+               /* OK */
+       } else {
+               printf("Missing M_WAITOK flag\n");
+               backtrace();
+               flags |= M_WAITOK;
+       }
 #if 0
        if (size == 0)
                Debugger("zero size malloc");
 #endif
-       if (!(flags & M_NOWAIT))
+       if (flags & M_WAITOK)
                KASSERT(curthread->td_intr_nesting_level == 0,
                   ("malloc(M_WAITOK) in interrupt context"));
        if (size <= KMEM_ZMAX) {
Index: sys/malloc.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/malloc.h,v
retrieving revision 1.70
diff -u -r1.70 malloc.h
--- sys/malloc.h        19 Feb 2003 05:47:45 -0000      1.70
+++ sys/malloc.h        19 Feb 2003 07:58:41 -0000
@@ -46,11 +46,11 @@
 /*
  * flags to malloc.
  */
-#define        M_WAITOK        0x0000
 #define        M_NOWAIT        0x0001          /* do not block */
-#define        M_USE_RESERVE   0x0002          /* can alloc out of reserve memory */
-#define        M_ZERO          0x0004          /* bzero the allocation */
-#define        M_NOVM          0x0008          /* don't ask VM for pages */
+#define        M_WAITOK        0x0002          /* do not block */
+#define        M_ZERO          0x0100          /* bzero the allocation */
+#define        M_NOVM          0x0200          /* don't ask VM for pages */
+#define        M_USE_RESERVE   0x0400          /* can alloc out of reserve memory */
 
 #define        M_MAGIC         877983977       /* time when first defined :-) */
 

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
[EMAIL PROTECTED]         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to