Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753736AbbFIILD (ORCPT ); Tue, 9 Jun 2015 04:11:03 -0400 Received: from mga01.intel.com ([192.55.52.88]:20611 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751514AbbFIIKz (ORCPT ); Tue, 9 Jun 2015 04:10:55 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,579,1427785200"; d="scan'208";a="739958518" Message-ID: <55769F85.5060909@linux.intel.com> Date: Tue, 09 Jun 2015 16:10:45 +0800 From: "Zhang, Yanmin" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Catalin Marinas , Christoph Lameter CC: "Liu, XinwuX" , "penberg@kernel.org" , "mpm@selenic.com" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "He, Bo" , "Chen, Lin Z" Subject: Re: [PATCH] slub/slab: fix kmemleak didn't work on some case References: <99C214DF91337140A8D774E25DF6CD5FC89DA2@shsmsx102.ccr.corp.intel.com> <20150608101302.GB31349@e104818-lin.cambridge.arm.com> In-Reply-To: <20150608101302.GB31349@e104818-lin.cambridge.arm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2316 Lines: 58 On 2015/6/8 18:13, Catalin Marinas wrote: > On Mon, Jun 08, 2015 at 10:38:13AM +0100, Christoph Lameter wrote: >> On Mon, 8 Jun 2015, Liu, XinwuX wrote: >> >>> when kernel uses kmalloc to allocate memory, slub/slab will find >>> a suitable kmem_cache. Ususally the cache's object size is often >>> greater than requested size. There is unused space which contains >>> dirty data. These dirty data might have pointers pointing to a block >> dirty? In what sense? > I guess XinwuX meant uninitialised. Uninitialized or dirty data used before being freed. > >>> of leaked memory. Kernel wouldn't consider this memory as leaked when >>> scanning kmemleak object. >> This has never been considered leaked memory before to my knowledge and >> the data is already initialized. > It's not the object being allocated that is considered leaked. But > uninitialised data in this object is scanned by kmemleak and it may look > like valid pointers to real leaked objects. So such data increases the > number of kmemleak false negatives. Yes, indeed. > > As I replied already, I don't think this is that bad, or at least not > worse than what kmemleak already does (looking at all data whether it's > pointer or not). It depends. As for memleak, developers prefers there are false alarms instead of missing some leaked memory. > It also doesn't solve the kmem_cache_alloc() case where > the original object size is no longer available. Such issue around kmem_cache_alloc() case happens only when the caller doesn't initialize or use the full object, so the object keeps old dirty data. This patch is to resolve the redundant unused space (more than object size) although the full object is used by kernel. > >> F.e. The zeroing function in linux/mm/slub.c::slab_alloc_node() zeros the >> complete object and not only the number of bytes specified in the kmalloc >> call. Same thing is true for SLAB. > But that's only when __GFP_ZERO is passed. > Thanks for the kind comments. There is a balance between performance (new memset consumes time) and debug capability. Yanmin -- 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/