Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Jan 2003 06:42:46 -0800
From:      Maxime Henrion <mux@freebsd.org>
To:        Robert Watson <rwatson@FreeBSD.org>
Cc:        Alfred Perlstein <alfred@FreeBSD.org>, cvs-committers@FreeBSD.org, cvs-all@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:  <20030121144246.GO16775@elvis.mu.org>
In-Reply-To: <Pine.NEB.3.96L.1030121092713.60586B-100000@fledge.watson.org>
References:  <200301210856.h0L8uGF3078830@repoman.freebsd.org> <Pine.NEB.3.96L.1030121092713.60586B-100000@fledge.watson.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Robert Watson wrote:
> On Tue, 21 Jan 2003, Alfred Perlstein wrote:
> 
> >   Log:
> >   Remove M_TRYWAIT/M_WAITOK/M_WAIT.  Callers should use 0.
> >   Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
> 
> Hmm.  I guess I missed the discussion; I'm a bit behind on mailing lists. 
> To improve code portability and careful thinking by developers, what I'd
> like to see is something more like the following: M_WAITOK, which
> explicitly requests sleeping indefinitely, M_NOWAIT, which explicitly
> requests no sleeping.  Rather than a "default" value, a
> KASSERT(M_WAITOK^M_NOWAIT, ("Bad malloc sleep flags")).  With the SMP
> kernel work, it's rapidly become clear that we want developers to actually
> think about every allocation and sleep case, rather than relying on a
> default.  One further caveat: with this change, we should be even more
> careful to document that M_WAITOK in the case if malloc() will sleep
> forever, and that with the mbuf code, you can get back NULL.  In principle
> though, I think doing this sort of cleanup is a good idea. 

I probably should have answered to your mail to arch@ when you posted
about this change but I was a bit busy at this time and forgot about it,
so my apologies for this.  Anyways, I fully agree with Robert on this
one.  I think having no default both makes the code more clear (M_WAITOK
is more explicit than 0) and forces malloc() callers to think about which
flags to use.

Also, doing this way only forces you to change code which calls malloc()
with 0, and those are quite rare if I understand correctly.  The way you
did forced you to change a *lot* of kernel files, which will probably cause
a significant amount of CVS conflicts.

Cheers,
Maxime

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




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