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 1DC9FC43334 for ; Thu, 30 Jun 2022 02:47:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 721376B0072; Wed, 29 Jun 2022 22:47:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A9626B0073; Wed, 29 Jun 2022 22:47:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 572758E0001; Wed, 29 Jun 2022 22:47:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4384F6B0072 for ; Wed, 29 Jun 2022 22:47:50 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 13B476017B for ; Thu, 30 Jun 2022 02:47:50 +0000 (UTC) X-FDA: 79633367100.03.1EC16CF Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id 90ED840032 for ; Thu, 30 Jun 2022 02:47:49 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CDE156200A; Thu, 30 Jun 2022 02:47:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4921C34114; Thu, 30 Jun 2022 02:47:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1656557268; bh=q4b1LJ2DwRDteJ3iTMyAFDQxG0jHMQ+puHrfpRpsSCw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=KHQuPbMara6fJJNuTBPMcoIs0XXta5ogWsfuxzDDfaGdl+2yKvMEMvhAdnWo/Bqgs YHCM4qLx2j/0JANzk/mhQxitqSJeEIJICbburn+iHGcMx2IXS7L9EJ1FdTFsO7Uckn ovTRCIFbdeGlqXZlQiwckRC/P/Co3qNfzuRpQ3KI= Date: Wed, 29 Jun 2022 19:47:47 -0700 From: Andrew Morton To: Feng Tang Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com, Joerg Roedel , Robin Murphy Subject: Re: [RFC PATCH] mm/slub: enable debugging memory wasting of kmalloc Message-Id: <20220629194747.62effc10a994f67e26fe96af@linux-foundation.org> In-Reply-To: <20220630023844.GA4668@shbuild999.sh.intel.com> References: <20220630014715.73330-1-feng.tang@intel.com> <20220629193006.77e9f071a5940e882c459cdd@linux-foundation.org> <20220630023844.GA4668@shbuild999.sh.intel.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656557269; a=rsa-sha256; cv=none; b=Gh2aI0hilXBBwg/jgtSjRJn8grVVyqlHla1fz7rTRNBzdfsL+eGkOzGVZDH4OzvBdeNRma TCdY6RXlAL+FE1PYDhcgpn0pemtxLKDh/kEMn96frYacTlxqhwHgo3wL3zrGtDQZgrCAra nYHsp6JmLCxnIBFoZFjFJQeYURCx2Vs= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=KHQuPbMa; dmarc=none; spf=pass (imf07.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656557269; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Oe1Od8PFD93ZZKbmwSHxJr082tXPPcBBe9tUoMeJM2Q=; b=Cc1O+yVSsq1StI+KxYWqhN0JtnDBtal5SOGolOfhUkLCYVE0D6r4/mpa9c0rsZnNowcyTq ZfWvykXzhqZcGEgwP1R25wtF1rxSrGqOk+ITtsf4y/6fsGE60bprJg/gYyQD3keC8U7gLe +bi0e012YmtZXIpPuEIGIRnALxvxpF4= Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=KHQuPbMa; dmarc=none; spf=pass (imf07.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 90ED840032 X-Stat-Signature: drzarjt9t1dqum7xxj6p7jjuc8tfra4n X-Rspam-User: X-HE-Tag: 1656557269-870130 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 Thu, 30 Jun 2022 10:38:44 +0800 Feng Tang wrote: > Hi Andrew, > > Thanks for the review! > > On Wed, Jun 29, 2022 at 07:30:06PM -0700, Andrew Morton wrote: > > On Thu, 30 Jun 2022 09:47:15 +0800 Feng Tang wrote: > > > > > kmalloc's API family is critical for mm, with one shortcoming that > > > its object size is fixed to be power of 2. When user requests memory > > > for '2^n + 1' bytes, actually 2^(n+1) bytes will be allocated, so > > > in worst case, there is around 50% memory space waste. > > > > > > We've met a kernel boot OOM panic, and from the dumped slab info: > > > > > > [ 26.062145] kmalloc-2k 814056KB 814056KB > > > > > > >From debug we found there are huge number of 'struct iova_magazine', > > > whose size is 1032 bytes (1024 + 8), so each allocation will waste > > > 1016 bytes. Though the issue is solved by giving the right(bigger) > > > size of RAM, it is still better to optimize the size (either use > > > a kmalloc friendly size or create a dedicated slab for it). > > > > Well that's nice, and additional visibility is presumably a good thing. > > > > But what the heck is going on with iova_magazine? Is anyone looking at > > moderating its impact? > > Yes, I have a very simple patch at hand > > --- a/drivers/iommu/iova.c > +++ b/drivers/iommu/iova.c > @@ -614,7 +614,7 @@ EXPORT_SYMBOL_GPL(reserve_iova); > * dynamic size tuning described in the paper. > */ > > -#define IOVA_MAG_SIZE 128 > +#define IOVA_MAG_SIZE 127 Well OK. Would benefit from a comment explaining the reasoning. But we still have eleventy squillion of these things in flight. Why? > #define MAX_GLOBAL_MAGS 32 /* magazines per bin */ > > struct iova_magazine { > > I guess changing it from 128 to 127 will not hurt much, and plan to > send it out soon.