From owner-cvs-all Tue Jan 21 6:42:48 2003 Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 796C737B401; Tue, 21 Jan 2003 06:42:47 -0800 (PST) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 10B6A43EB2; Tue, 21 Jan 2003 06:42:47 -0800 (PST) (envelope-from mux@freebsd.org) Received: by elvis.mu.org (Postfix, from userid 1920) id C3F6CAE27F; Tue, 21 Jan 2003 06:42:46 -0800 (PST) Date: Tue, 21 Jan 2003 06:42:46 -0800 From: Maxime Henrion To: Robert Watson Cc: Alfred Perlstein , 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> References: <200301210856.h0L8uGF3078830@repoman.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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