From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0E58C05027 for ; Thu, 26 Jan 2023 11:21:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236850AbjAZLVV (ORCPT ); Thu, 26 Jan 2023 06:21:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233130AbjAZLVU (ORCPT ); Thu, 26 Jan 2023 06:21:20 -0500 Received: from gentwo.de (gentwo.de [161.97.139.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20B2C9013 for ; Thu, 26 Jan 2023 03:21:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gentwo.de; s=default; t=1674732074; bh=9OAbb+6Iby7ioZj2GSSudmr2Eanm/bGeive3un3bnO8=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=HpMrgwHjh/rRJnbGwExJkLnSMk1A3L9738oqNYw4K/Jzj2CeLC+ZtJ8f1G568ZN3a dQRbzbetlbHFUH+BpqI3NC2eGyzIqNY8rBj5fj3WwOqz7ZUm39lesHTDjYJ/v8issc iXttVG0uDOIxcVIEfDAk3nGHoeIIiWFI8iO3WaVqJ2pgjnViCIXwD+qEdRajU/fZ9f QXTQXng2LxWW8vWcNhDke+z+006jV+GW/nhBXT6n00K39TbRSxlhQ3g47fOns2erXC pvEfaUe9OuKw4+QFbrBhVazSTqQJt0Ycqbu1tC7Cclv8QzpQIBBRaOoFrIiieI5+vO NkCo3wy+Hjzhg== Received: by gentwo.de (Postfix, from userid 1001) id A067FB0028E; Thu, 26 Jan 2023 12:21:14 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by gentwo.de (Postfix) with ESMTP id 9B095B00137; Thu, 26 Jan 2023 12:21:14 +0100 (CET) Date: Thu, 26 Jan 2023 12:21:14 +0100 (CET) From: Christoph Lameter To: George Prekas cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Catalin Marinas , Andrew Morton , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Thomas Gleixner , "Eric W. Biederman" , Sebastian Andrzej Siewior , Andy Lutomirski , Peter Zijlstra , "Liam R. Howlett" , Fenghua Yu , Andrei Vagin Subject: Re: [PATCH 9/9] mm: kmemleak: fix undetected leaks for page aligned objects In-Reply-To: <20230123170419.7292-10-george@enfabrica.net> Message-ID: References: <20230123170419.7292-1-george@enfabrica.net> <20230123170419.7292-10-george@enfabrica.net> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 23 Jan 2023, George Prekas wrote: > If kmalloc returns a page aligned object, then the object has 2 > references: the pointer returned by kmalloc and page->s_mem of the first > page of the object. Account for this extra reference, so that kmemleak > can correctly detect leaks for page aligned objects. s_mem is a reference to the array of slab objects in a SLAB page. It is not referring to a particular object. s_mem allows access to the Nth object in a slab page. See the function index_to_obj() in slab.c static inline void *index_to_obj(struct kmem_cache *cache, const struct slab *slab, unsigned int idx) { return slab->s_mem + cache->size * idx; }