Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752916AbbFKR0Q (ORCPT ); Thu, 11 Jun 2015 13:26:16 -0400 Received: from resqmta-ch2-03v.sys.comcast.net ([69.252.207.35]:34282 "EHLO resqmta-ch2-03v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751334AbbFKR0N (ORCPT ); Thu, 11 Jun 2015 13:26:13 -0400 Date: Thu, 11 Jun 2015 12:26:11 -0500 (CDT) From: Christoph Lameter X-X-Sender: cl@east.gentwo.org To: Andrew Morton cc: Sergey Senozhatsky , Minchan Kim , Pekka Enberg , Joonsoo Kim , Michal Hocko , David Rientjes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, sergey.senozhatsky.work@gmail.com, Joe Perches Subject: Re: [RFC][PATCH 0/5] do not dereference NULL pools in pools' destroy() functions In-Reply-To: <20150609191755.867a36c3.akpm@linux-foundation.org> Message-ID: References: <1433851493-23685-1-git-send-email-sergey.senozhatsky@gmail.com> <20150609142523.b717dba6033ee08de997c8be@linux-foundation.org> <20150609185150.8c9fed8d.akpm@linux-foundation.org> <20150609191755.867a36c3.akpm@linux-foundation.org> Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1667 Lines: 40 On Tue, 9 Jun 2015, Andrew Morton wrote: > > > More than half of the kmem_cache_destroy() callsites are declining that > > > value by open-coding the NULL test. That's reality and we should recognize > > > it. > > > > Well that may just indicate that we need to have a look at those > > callsites and the reason there to use a special cache at all. > > This makes no sense. Go look at the code. > drivers/staging/lustre/lustre/llite/super25.c, for example. It's all > in the basic unwind/recover/exit code. That is screwed up code. I'd do that without the checks simply with a series of kmem_cache_destroys(). > > If the cache > > is just something that kmalloc can provide then why create a special > > cache. On the other hand if something special needs to be accomplished > > then it would make sense to have special processing on kmem_cache_destroy. > > This has nothing to do with anything. We're talking about a basic "if > I created this cache then destroy it" operation. As you see in this code snipped you cannot continue if a certain operation during setup fails. At that point it is known which caches exist and therefore kmem_cache_destroy() can be called without the checks. > It's a common pattern. mm/ exists to serve client code and as a lot of > client code is doing this, we should move it into mm/ so as to serve > client code better. Doing this seems to encourage sloppy coding practices. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/