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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D660C19F21 for ; Wed, 27 Jul 2022 10:20:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F284D940009; Wed, 27 Jul 2022 06:20:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ED84C6B0078; Wed, 27 Jul 2022 06:20:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC75D940009; Wed, 27 Jul 2022 06:20:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CC9F86B0073 for ; Wed, 27 Jul 2022 06:20:50 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 97C55AB4C2 for ; Wed, 27 Jul 2022 10:20:50 +0000 (UTC) X-FDA: 79732486260.04.3A4BEC3 Received: from gentwo.de (gentwo.de [161.97.139.209]) by imf01.hostedemail.com (Postfix) with ESMTP id C02CE400BB for ; Wed, 27 Jul 2022 10:20:49 +0000 (UTC) Received: by gentwo.de (Postfix, from userid 1001) id 66F50B00264; Wed, 27 Jul 2022 12:20:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gentwo.de; s=default; t=1658917247; bh=iiWn5QMcngKlLYivm+GA6lb+fbbu7FPY3WiuGWJO0is=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=g1EsMqUgJ6SkuH7Eop/o2cEKrnNldDGecwPmkcRY0hT7aRg5qpLjl10a8TBQDHOHn WKvVxXeJV8Zlyeuxtnta8PfE79flIEwy989p9XS7k2EMr4mShx07z8+Wmg7nhUDbzv B/pvzrlumA9m+u2PO+Vg6wJxn2UcQxDWkPRc9p9otVT/mQZT/oMeTAF1g/etzQErGx 4IdKuqREezU/TuQdcC39B3KANaPyogBEvfbjgmMt48o9wx7+s9oRPbSbd+nZK1uvXa CPTLNB9m6yNobbqyWG2ekLUO3ZEKRzo+VvpYELm3zskRz9gxBel8MoCmLPIWCB5PP+ 738RKcnKuUZCA== Received: from localhost (localhost [127.0.0.1]) by gentwo.de (Postfix) with ESMTP id 62911B00224; Wed, 27 Jul 2022 12:20:47 +0200 (CEST) Date: Wed, 27 Jul 2022 12:20:47 +0200 (CEST) From: Christoph Lameter To: Feng Tang cc: Andrew Morton , Vlastimil Babka , Pekka Enberg , David Rientjes , Joonsoo Kim , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dave Hansen , Robin Murphy , John Garry , Kefeng Wang Subject: Re: [PATCH v3 1/3] mm/slub: enable debugging memory wasting of kmalloc In-Reply-To: <20220727071042.8796-2-feng.tang@intel.com> Message-ID: References: <20220727071042.8796-1-feng.tang@intel.com> <20220727071042.8796-2-feng.tang@intel.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none ("invalid DKIM record") header.d=gentwo.de header.s=default header.b=g1EsMqUg; spf=pass (imf01.hostedemail.com: domain of cl@gentwo.de designates 161.97.139.209 as permitted sender) smtp.mailfrom=cl@gentwo.de; dmarc=pass (policy=none) header.from=gentwo.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658917250; a=rsa-sha256; cv=none; b=MXzg0BDt/dn6xSVJ7Xig8uU4f1tPLvoyRrVfHDd2tUAJoFASjWMueaOrI+53Eymf1nJm9y GE2CxTzbIXj6w+O1nemdvX+mGmLcl/oXMibrN5T4xHsN5nFcivjs1qGN9HcROcR7VNcajZ T0timD06dvLCURjjpGclOA503I43/90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658917250; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZtS03xkK4QNWKMbdoiivZ4QBWphBTXlyntGOGANgyRw=; b=5/mW1ZDHUhL9U3sRjC6go71Fo3ptNnEafg8+wx12eluhAj5Mr+YwH/oyx1D3im1BzVwcRC r0lL2/iLk8UDNEUl/hWiODIK3Tlu3ojSC7rsGMMHbZo0i1sCImzT5WI0n3BtYYLZTssrNy 4Pcel//zkqIpnjaZeDoAdsW1UiTnCFY= X-Rspamd-Server: rspam10 X-Rspam-User: Authentication-Results: imf01.hostedemail.com; dkim=none ("invalid DKIM record") header.d=gentwo.de header.s=default header.b=g1EsMqUg; spf=pass (imf01.hostedemail.com: domain of cl@gentwo.de designates 161.97.139.209 as permitted sender) smtp.mailfrom=cl@gentwo.de; dmarc=pass (policy=none) header.from=gentwo.de X-Stat-Signature: ipb5ha8ji5pjsb5j9rdcsdijrqbazjge X-Rspamd-Queue-Id: C02CE400BB X-HE-Tag: 1658917249-147317 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, 27 Jul 2022, Feng Tang wrote: > @@ -2905,7 +2950,7 @@ static inline void *get_freelist(struct kmem_cache *s, struct slab *slab) > * already disabled (which is the case for bulk allocation). > */ > static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, > - unsigned long addr, struct kmem_cache_cpu *c) > + unsigned long addr, struct kmem_cache_cpu *c, unsigned int orig_size) > { > void *freelist; > struct slab *slab; > @@ -3102,7 +3147,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, > * pointer. > */ > static void *__slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, > - unsigned long addr, struct kmem_cache_cpu *c) > + unsigned long addr, struct kmem_cache_cpu *c, unsigned int orig_size) > { > void *p; > > @@ -3115,7 +3160,7 @@ static void *__slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, > c = slub_get_cpu_ptr(s->cpu_slab); > #endif > > - p = ___slab_alloc(s, gfpflags, node, addr, c); > + p = ___slab_alloc(s, gfpflags, node, addr, c, orig_size); > #ifdef CONFIG_PREEMPT_COUNT > slub_put_cpu_ptr(s->cpu_slab); This is modifying and making execution of standard slab functions more expensive. Could you restrict modifications to the kmalloc subsystem? kmem_cache_alloc() and friends are not doing any rounding up to power of two sizes. What is happening here is that you pass kmalloc object size info through the kmem_cache_alloc functions so that the regular allocation functions debug functionality can then save the kmalloc specific object request size. This is active even when no debugging options are enabled. Can you avoid that? Have kmalloc do the object allocation without passing through the kmalloc request size and then add the original size info to the debug field later after execution continues in the kmalloc functions?