From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761701AbXFBBFX (ORCPT ); Fri, 1 Jun 2007 21:05:23 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755277AbXFBBFM (ORCPT ); Fri, 1 Jun 2007 21:05:12 -0400 Received: from smtp1.linux-foundation.org ([207.189.120.13]:42047 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754966AbXFBBFK (ORCPT ); Fri, 1 Jun 2007 21:05:10 -0400 Date: Fri, 1 Jun 2007 18:04:54 -0700 (PDT) From: Linus Torvalds To: Christoph Lameter cc: Andrew Morton , Jeremy Fitzhardinge , Srinivasa Ds , linux-kernel@vger.kernel.org, Srivatsa Vaddagiri , Dinakar Guniguntala , pj@sgi.com, simon.derr@bull.net, clameter@cthulhu.engr.sgi.com, rientjes@google.com Subject: Re: [RFC] [PATCH] cpuset operations causes Badness at mm/slab.c:777 warning In-Reply-To: Message-ID: References: <465FCA79.70207@in.ibm.com> <200706011620.05756.srinivasa@in.ibm.com> <466081DE.70205@goop.org> <20070601135900.ec44b1aa.akpm@linux-foundation.org> <20070601151649.bb23c6f9.akpm@linux-foundation.org> <20070601153328.1118ccaf.akpm@linux-foundation.org> <20070601171612.8194394a.akpm@linux-foundation.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 1 Jun 2007, Christoph Lameter wrote: > > On Fri, 1 Jun 2007, Andrew Morton wrote: > > > I think it'd be better if we kept the WARN_ON_ONCE(size == 0) in there, > > The trouble with the WARN_ON is that it triggers even for code that is > okay like noted by Jeremy. Yes. Sometimes it's just more natural to have ptr = kmalloc(size); .. use it .. free(ptr); and if a *degenerate* case of size=0 happens, who cares? It should just work, as long as we (obviously) don't actually try to access the pointer. So I don't much like the WARN_ON(size == 0). I think it potentially just causes people to write around it, and quite possibly causes the callers to write code that is not at all more readable or maintainable! That's why I'd much rather return BADPTR instead: we'll get an oops for buggy code, but we don't penalize the "natural" and good code! So once you return BADPTR, there really isn't any good reason for the WARN_ON. Linus