Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp670753iog; Thu, 30 Jun 2022 08:04:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s43YpU3g0DWiNhUjDNbDT+lSh/Xuf90aNb4DTzhf9cr+sga4iExisttUq4u9JFCyPVs7KQ X-Received: by 2002:aa7:93a5:0:b0:51b:e0f8:97a6 with SMTP id x5-20020aa793a5000000b0051be0f897a6mr15080996pff.44.1656601465279; Thu, 30 Jun 2022 08:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656601465; cv=none; d=google.com; s=arc-20160816; b=OjKg3KlfHuHnwf67+OPNP+G49lHbBaPFnqOCIenYLLx3hkdzRsvSyHaBHcOHL0yFPA Micqnuu40Lt8RcI4yG8/LN9alpju655eV6aI6ODjdi3QVssXe8EkKD4iyhzwnxfOqZBt shzk9zck2MH/rA3aeLgVfdt8SKzJdNugsZGho0O0+TCSt96BNC7EwZsfqyOThVsqY1Ks DKU1jDIIGsRndlmjICWD3BQH3U0gBGgPcvpgCz7HShVEfYVItLIpMdy46hE82NY7HK9T 981srvVzIornqaIZ1UjibLPFGd3vaZ53EguFAN4fZtJU50j+xclM6hsZJYqbwyDbe4nN vtMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ipNBTkHp2jS0+JttebnQfFLWG27OJJNBttsPzJH3qb0=; b=TgcoU0P0rWXY2y3ddUqAG9hBK/ZfSUA13Y4+91rCLnsC38jQCejfu4V/Qqmtx1gKB+ pxGUyWCSWh2VmbbQ5F+yWfPnoV06zdp9BN07QbIp26GGtpzq780ICSoTJ5hBWCuh62Fc fe2K2gRCu77qiYGwdC0Wjvu8IDTT+h/w1dvklIyLuxPkFExFGhsuRr7UjbDQsvxq1+qR vlW8Z+B1m1YJXE/ZoKbe2f7Ff0YRtdTeHzAULDMKiwHnHfZCub0SeF6FvquaSCYOl9FD zoFVQtsLg+2SutSqHXzVAm81zqqOf6RlFN8jNgi7CvbTVa2/6IqcH3seTVkR+ban9MMW YTrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pgF8MbXG; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a24-20020a656558000000b00408a99544b0si26415930pgw.525.2022.06.30.08.04.13; Thu, 30 Jun 2022 08:04:25 -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=@gmail.com header.s=20210112 header.b=pgF8MbXG; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235563AbiF3O4Y (ORCPT + 99 others); Thu, 30 Jun 2022 10:56:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229966AbiF3O4X (ORCPT ); Thu, 30 Jun 2022 10:56:23 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC9DC1BEAD for ; Thu, 30 Jun 2022 07:56:22 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id s10so23433472ljh.12 for ; Thu, 30 Jun 2022 07:56:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ipNBTkHp2jS0+JttebnQfFLWG27OJJNBttsPzJH3qb0=; b=pgF8MbXGCCzbjeNDnKq+15lZDcZpjlPbZ133zcnyP2hhvSfUAm6yVILAKDi0XiiMcI yCFUl0kRtXWtS3przUPtG5c3sWlxKkM63L5r3UEA0VKoNsXCjfTR/HULCXz8K4OkMvnd tJFt94a2qUqPLZ5CpF60K5NrAp+5bTlP/gZkh8ub4itlVXmihRdUYhnTtvY8AGiQdbY/ lF0XeNS2A/mxvuwTNT/2zZcfYVZiZiuYeYFRczsjPquKw/KMMjYZiiD3sI1pFg+Wi68M RKRtDhM93zoHtABy8UsTOs32gguu+E/BaH8wy/56KtZBpYBFfdQ3LEyM6U52wT+lHLIp r3pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ipNBTkHp2jS0+JttebnQfFLWG27OJJNBttsPzJH3qb0=; b=ZQKOhiszvfHk0WplQBsnGuRttyMp4sLioZ5vIl+0EK2ZtA1KR/mg7fnRWLRRnq2uS6 /aPuMpOy0Le6NEIRt5Ua7aWhvVd2sUUZX+sOXfuAVJSjf38Z+flU+t1WqFeMTHo7mRCu zycKqIxClHHExJunbKDeYgnTa9zl3awJ4ad/QHWpcE83oQR5KizHXjGUy9jGgSMk083p 9Y6waRkSF1PmXJfO7hEUcJ3ntHUpOta5Zk/6zG1wZnSCpEVY5Ifgt7vGfhc/6P2tydm+ cGo0ooTQvO6tw31wYPYw1V84ND5JuoevZl99Y5ZF+IFjI/21XEi0yp8zsIykeusecCsZ 6D3w== X-Gm-Message-State: AJIora+RE4MW0evSVAzXLDJSqsNKLSkspGNgsaj0G+jYyaw6JOjO7TeA BYrI7STv7zljUmCdi3oXnJgKK/Pq46YsBBYJZdA= X-Received: by 2002:a2e:804b:0:b0:25a:7502:6bd3 with SMTP id p11-20020a2e804b000000b0025a75026bd3mr5428568ljg.455.1656600980868; Thu, 30 Jun 2022 07:56:20 -0700 (PDT) MIME-Version: 1.0 References: <20220630014715.73330-1-feng.tang@intel.com> In-Reply-To: From: Hyeonggon Yoo <42.hyeyoo@gmail.com> Date: Thu, 30 Jun 2022 23:55:59 +0900 Message-ID: Subject: Re: [RFC PATCH] mm/slub: enable debugging memory wasting of kmalloc To: Feng Tang Cc: Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , Linux Memory Management List , LKML , Dave Hansen Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HK_RANDOM_ENVFROM, HK_RANDOM_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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, Jun 30, 2022 at 11:38 PM Hyeonggon Yoo <42.hyeyoo@gmail.com> wrote: [...] > > @@ -5138,11 +5146,12 @@ static int add_location(struct loc_track *t, struct kmem_cache *s, > > if (pos == end) > > break; > > > > - caddr = t->loc[pos].addr; > > - chandle = t->loc[pos].handle; > > - if ((track->addr == caddr) && (handle == chandle)) { > > + l = &t->loc[pos]; > > + caddr = l->addr; > > + chandle = l->handle; > > + if ((track->addr == caddr) && (handle == chandle) && > > + (track->waste == l->waste)) { > > > > - l = &t->loc[pos]; > > l->count++; > > if (track->when) { > > l->sum_time += age; > > @@ -5190,6 +5199,7 @@ static int add_location(struct loc_track *t, struct kmem_cache *s, > > 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.) > because the array is sorted by caller address, but not sorted by waste. > > And writing this I noticed that it already can be fooled now :) > It's also not sorted by handle. I misread the code. it's not fooled now. the array is also sorted by handle. But will be fooled after this patch. > -- > Thanks, > Hyeonggon