Received: by 2002:ac0:c50a:0:0:0:0:0 with SMTP id y10csp1157826imi; Fri, 1 Jul 2022 04:26:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t39iQmfz1vOtkfyjrkV3H0D53Fuwl5MJkv3XHNxXcpjYh4RyoesTLVICsV9Ty5fE6+kQe2 X-Received: by 2002:a17:902:b286:b0:16a:1006:a871 with SMTP id u6-20020a170902b28600b0016a1006a871mr20739803plr.109.1656674780619; Fri, 01 Jul 2022 04:26:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656674780; cv=none; d=google.com; s=arc-20160816; b=izfUlIKiRWgaCwGcj7RRCJxRCLqdtc8VvrDZ/Ih/9C9ceNJtorcCmytHnnM+GQaEkd POK3y4h580aItrM2EpA+FELHW7B8bs3PYTfNGR+IXuHMwwtoJ7BEaXypShwMGwi88RU+ 4qlkyf5YhYQRm3XsQG36XGSiByeBknmiSdlQizXoM+4dBz27cGcWIFtrpZA9h3Lw9G0x kFtnvy1FsEuA066x8nQNgM1HQ3S8Uy/WtoMnug2e95UAQNBUGscaL0kuL1GyJrFznyDM 2UxkcnaDO7N8JAqDFpmdgTubMFBllXpJIZKRKf4873Dktk45ZxQborVFiUz0c7zlNkOE OJbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+SMWNvUm4lfD3x3vvaVjPsQZBD9J1UhZCbXrN9r0F9Y=; b=1GmAbu0ebFxIgbXNrPAI9gRq0yQ/cI4+D2Zcmk3T9jqoTVtn1IdrYC/NADyHopgKnL K5TX+WZLuEb23X84KDNThAOeAwIb11IaPNvOFDfjO62iCarY7LvmXCs/93DiasL1WzW2 Rhz3FXwBl6+AYjGZboLsp++qRYfV3IligalbHGEA4Tn7NJ6mU8JxYB2J4vH3ur8W7YQb Ii4hWCETfhc1nTGVzkf1PBRLNpk5kq9A07ymQRDU/Fnn5jOrEmF40RwwNiZxN1XiZbWW Dk+6uDhPJVqLa2xtz9d9GgsDH0hzGDeFGoEc5QjvHPhXGUz299N7aWQWPZ4LsKdcwNYs bRdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Q2/c80gg"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q6-20020a635046000000b003fc8c5109adsi30945353pgl.315.2022.07.01.04.26.08; Fri, 01 Jul 2022 04:26:20 -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=@intel.com header.s=Intel header.b="Q2/c80gg"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237328AbiGALN3 (ORCPT + 99 others); Fri, 1 Jul 2022 07:13:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237331AbiGALN1 (ORCPT ); Fri, 1 Jul 2022 07:13:27 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C9CF1570A for ; Fri, 1 Jul 2022 04:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656674006; x=1688210006; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=vlK/qQ4NX1QkT7AEWx80zOij+hlHTc4NLtDoQtrx+IQ=; b=Q2/c80ggi7cPmrWnrM6tqXVl7VzskwQYyjkA/oWkeay64oaIcUfrYxk6 l8rpA0dDgKnM1lmjJEpjKGbr/2fn7NUILfpVfIY+Q3ChA8gObyVXzv2Xr 1fs6Nv6e1Jy6i1+Alif9ExINPb2G7wYMrSkDlS0TZ698/wTmYSP38e5NB HCxDg6zZjmiuLD+ot0v2DcXBrUCnxadoEjlRFcEqurI0Ln7UO3rVcSf7o ikLKGlZQskoXjnRn7evORI8/yAC/PvVPYWoCCwkXSGU9OBluWlR+868oL aOwqwviZyqbmD3yLXkMbtHcSq38i4cTP21m7d6i7oKexE773XJNJB2MRu g==; X-IronPort-AV: E=McAfee;i="6400,9594,10394"; a="280178941" X-IronPort-AV: E=Sophos;i="5.92,236,1650956400"; d="scan'208";a="280178941" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2022 04:13:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,236,1650956400"; d="scan'208";a="694478207" Received: from shbuild999.sh.intel.com (HELO localhost) ([10.239.146.138]) by fmsmga002.fm.intel.com with ESMTP; 01 Jul 2022 04:13:23 -0700 Date: Fri, 1 Jul 2022 19:13:22 +0800 From: Feng Tang To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com Subject: Re: [RFC PATCH] mm/slub: enable debugging memory wasting of kmalloc Message-ID: <20220701111322.GC14806@shbuild999.sh.intel.com> References: <20220630014715.73330-1-feng.tang@intel.com> <20220701022330.GA14806@shbuild999.sh.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,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 Fri, Jul 01, 2022 at 06:29:20PM +0900, Hyeonggon Yoo wrote: > On Fri, Jul 01, 2022 at 10:23:30AM +0800, Feng Tang wrote: [snip] > > > > > And then it has overhead of 'waste' field for every non-kmalloc objects > > > because track is saved per object. Also the field is not used at free. > > > (Maybe that would be okay as it's only for debugging, just noting.) > > > > Yes, the field itself is a 'waste' for non-kmalloc objects :) I do > > have another patch to add an option for this > > > > +config SLUB_DEBUG_KMALLOC_WASTE > > + bool "Enable kmalloc memory waste debug" > > + depends on SLUB_DEBUG && DEBUG_FS > > ... > > > > And didn't post it due to the same debugging thought as you. And I can > > add it back if it's really necessary. > > Let's see how others think :) > I'm okay with current patch. Okay. > > > > mm/slub.c | 45 ++++++++++++++++++++++++++++++--------------- > > > > 1 file changed, 30 insertions(+), 15 deletions(-) [snip] > > > > > > > > l->min_pid = track->pid; > > > > l->max_pid = track->pid; > > > > l->handle = handle; > > > > + l->waste = track->waste; > > > > > > I think this may be fooled when there are different wastes values > > > from same caller (i.e. when a kmalloc_track_caller() is used.) > > > > Yes, with the patch, we found quite some cases that the same caller > > requests different sizes. > > > > > because the array is sorted by caller address, but not sorted by waste. > > > > In the patch we have in add_location(): > > > > + if ((track->addr == caddr) && (handle == chandle) && > > + (track->waste == l->waste)) { > > > > Do you mean the following is missed? > > > > --- a/mm/slub.c > > +++ b/mm/slub.c > > @@ -5176,6 +5176,8 @@ static int add_location(struct loc_track *t, struct kmem_cache *s, > > end = pos; > > else if (track->addr == caddr && handle < chandle) > > end = pos; > > + else if (track->addr == caddr && handle == chandle && track->waste < l->waste) > > + end = pos; > > else > > start = pos; > > > > Yes. Exactly. :) Great, will add it in the next version. Thanks for cathing the errors! - Feng > Thanks, > Hyeonggon