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 F2521C43334 for ; Thu, 30 Jun 2022 02:38:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F2AD8E0003; Wed, 29 Jun 2022 22:38:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A2FC8E0001; Wed, 29 Jun 2022 22:38:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 769F18E0003; Wed, 29 Jun 2022 22:38:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 65DD78E0001 for ; Wed, 29 Jun 2022 22:38:51 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 384EA80CA7 for ; Thu, 30 Jun 2022 02:38:51 +0000 (UTC) X-FDA: 79633344462.22.280429B Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf12.hostedemail.com (Postfix) with ESMTP id 3A9E340036 for ; Thu, 30 Jun 2022 02:38:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656556730; x=1688092730; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=zwlsCioRpw1uFafDOCGVO1n7Aos4RJziHab6JNVMCos=; b=DTjX8iLOcNZmoCn+EVjfUBhT6qTySLA6lnZuNcKBVWjkv3sR5F+k00Oh T4MK5gxeEeQYEGVvickIjNEnoBsKJMSsN/vgFuzI8cJzzNAS4MLbkzgRz +9hsCi10pzi7noxH4Ig6kLuSZfyfMI2cEGivsCgNymGswkzUzg+qXHhbR hsknaw4agBEsb/SUxk46fw5tDEv+qjtsa/SZyyM2L46i6seBioG6AK6N5 a9ioFMJMNR3zNX8NGAzxB1a1Xj9MPcOjFYK8qzkgkbH6kt0qoFAW0AchQ PxVGcuGzm0XUt5BmuqRoTOBj6O9SgOKd8umrThvHdNvV3DQh3lWxc6seB Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10393"; a="346212170" X-IronPort-AV: E=Sophos;i="5.92,232,1650956400"; d="scan'208";a="346212170" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2022 19:38:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,232,1650956400"; d="scan'208";a="917854750" Received: from shbuild999.sh.intel.com (HELO localhost) ([10.239.146.138]) by fmsmga005.fm.intel.com with ESMTP; 29 Jun 2022 19:38:44 -0700 Date: Thu, 30 Jun 2022 10:38:44 +0800 From: Feng Tang To: Andrew Morton 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: <20220630023844.GA4668@shbuild999.sh.intel.com> References: <20220630014715.73330-1-feng.tang@intel.com> <20220629193006.77e9f071a5940e882c459cdd@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220629193006.77e9f071a5940e882c459cdd@linux-foundation.org> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656556730; a=rsa-sha256; cv=none; b=ILF9PPzN/3my7k+kJgntlWLZr7G8/1A323MVuvzz9qC8ZUprfxLxSL3lC5QYcIgEtSV9Rl CjF9nIk81HJwVJboRQuVZVC+1Yp0eilDVRPx3Hssz/yQsvAbBvmkgadxOty1juDorE2ZV6 N+E4aynFpN8bJANu+QNOJeu4Tgbl/MA= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=DTjX8iLO; spf=none (imf12.hostedemail.com: domain of feng.tang@intel.com has no SPF policy when checking 134.134.136.100) smtp.mailfrom=feng.tang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656556730; 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=ok84hv1GzQ4P9m5EkvR3P7FCcEK7oLeQOrteleS0OMY=; b=ppOM/PKbpZj4GAr2ZsvKa8qdYKu3NiYVPE7HbPk6VsfIfBUzvzPP2XEvixE7V2LX5jA4Pj wlkA4nOWL5+MKwekOZjo8zdxYskUqLmRxUdd8fPcjlC9FipDrxkELsFNJGl3FnkRvguQ9B 9buC0E4j9P7rJwegjXfIVPTaMOtB2JE= X-Rspam-User: X-Rspamd-Server: rspam04 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=DTjX8iLO; spf=none (imf12.hostedemail.com: domain of feng.tang@intel.com has no SPF policy when checking 134.134.136.100) smtp.mailfrom=feng.tang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Stat-Signature: esywiw64p4drurqzy4151rbmjhmr196y X-Rspamd-Queue-Id: 3A9E340036 X-HE-Tag: 1656556729-738206 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: 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 diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index db77aa675145..5422e67bb4b5 100644 --- 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 #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. Thanks, Feng