Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp135521iog; Wed, 29 Jun 2022 20:05:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uvyUrzjx6+HfUJw0vzex5KtmKmqoymo7z+9GMZY+pfzSBNN25MJvMd2EIRbj54+RytclNz X-Received: by 2002:a17:902:ab96:b0:16a:6db6:2715 with SMTP id f22-20020a170902ab9600b0016a6db62715mr12571647plr.141.1656558331110; Wed, 29 Jun 2022 20:05:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656558331; cv=none; d=google.com; s=arc-20160816; b=hboE4IsHoT6KhMFkjyY5rDFEhkD2zu0iIf8ngYuqRb9Mx0yw8gu2f3A8YWyOYLK2Hy 7SRh3EuKrrXkJJv6wQfF73gqMt2XS2ccTGxMYKM42Le7Fj9HEHG0ZjwcfZxiEK4rlU+1 tHVlfj8MsN0zXzQ2bOwvIfibrjDKTwcNKh2RdddIDpmXx5iK8x46Hq9Cb3Lvtw3DVInY GkgrAB0BK6oddoQUFdmoUsDs6weVtZ8kifUITTvWBt9ZsW62Njx4vN5Nafm+ZIcsccvU FJtpsCisgmQKHXv/9QQ2ikF9KobjTurQRe1YTDMrHAlAumXxhwoUvrQrBctTlsa1O977 daTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Oe1Od8PFD93ZZKbmwSHxJr082tXPPcBBe9tUoMeJM2Q=; b=aGeYHBBebSUwJJyZasQMYfZiipj/f6rzzuO1c+Yq+ZvJRcndzibQevbOmPctQD4NRt tUQoUlIp9rhxKx5lUPAUNk4zS4UzwuJ0GCI+c3Y6HLllKGDslwx9Eu9nHdsou4h5/euB YoLNRDBAfkeJ47H4D43OODkCnYbrP69eLQqRdeB2BiaCthBwAtV710d9MzNvomYQBhSU 0psOOAzJQIPoMm/ve46la4nKxGLItxZwM4iJ3qSLSRUx9GCtPodFS8O2UVd1Ze7dBgUf GHGfmMhbBBeLLG//2NOXvmf0mrFe/sg9QwcTyIVZf0iV9uZBFeP3J5uuiqmF2M6H6ekx kD1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=KHQuPbMa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r206-20020a632bd7000000b0041151f28f61si10636381pgr.683.2022.06.29.20.05.19; Wed, 29 Jun 2022 20:05:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=KHQuPbMa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231929AbiF3Cr4 (ORCPT + 99 others); Wed, 29 Jun 2022 22:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231908AbiF3Crv (ORCPT ); Wed, 29 Jun 2022 22:47:51 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCC2E3B02D for ; Wed, 29 Jun 2022 19:47:50 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 701C6B82718 for ; Thu, 30 Jun 2022 02:47:49 +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 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.