Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Feb 2003 09:14:29 +0100
From:      phk@phk.freebsd.dk
To:        current@freebsd.org
Subject:   Re: cvs commit: src/sys/alpha/alpha busdma_machdep.c src/sys/alpha/osf1 imgact_osf1.c osf1_misc.c src/sys/cam cam_periph.c cam_sim.c cam_xpt.c src/sys/cam/scsi scsi_cd.c scsi_ch.c scsi_da.c scsi_low.c scsi_sa.c scsi_target.c src/sys/coda cnode.h ... 
Message-ID:  <76449.1045642469@critter.freebsd.dk>
In-Reply-To: Your message of "Tue, 18 Feb 2003 21:47:47 PST." <200302190547.h1J5ll1J064169@repoman.freebsd.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <200302190547.h1J5ll1J064169@repoman.freebsd.org>, 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
phk@FreeBSD.ORG         | 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 majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




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