Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp199256iog; Fri, 24 Jun 2022 02:13:26 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sCe3PxYyAc/U0sVsDP26O0aYePKm34YSLFMT5+G49acn5zLvraMUjIV9JPYTQI2R7W1j7r X-Received: by 2002:a05:6402:254c:b0:435:c541:fc8d with SMTP id l12-20020a056402254c00b00435c541fc8dmr10716537edb.385.1656062006055; Fri, 24 Jun 2022 02:13:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656062006; cv=none; d=google.com; s=arc-20160816; b=b1ccVqQJt/o0bY5/zIBDs26i8U/9slZb2Znc943xm3prjFHmHAUIpXet5OBa+SUbDy N8RK06YT1ElERl3e6i7TanFmEwdQO5YtK+uk0urU22irIETZiTTEf+SCATi5H4B5XRJa oYv2+K/ZGQoiqya3ykDbbNFpqFn2giLERQPIahO/RnggXSI+J0qazGzgxByq08Hcb8co jb8rXBz17b5dH/HhX3kHvu/BNe9HqjrujGZT1r50B4rLEI9msHeJZfCkRmHjYkte0L7Q bZ50I1ueEpMLCZ7C19ebatJ3aqR2F3dxpfJ5R81J6mFun+2G33sGFAbupECa23yDAbq9 DWDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=I5prPDPC8v4mNhBzFP1CfowAl0viEFJUJ5FoXsjM9BA=; b=BFqN40NUUvbNOOWuXSfMPnYam+tgCGvgkI5qiY90spPxKI/2Ty15q8APgAxRnNpCgO JmWV8fGDLAdAcfCioiUvSs6jN3+1nroSiXZsZSXwMRI+a3h1bkqQpLISeSy+S/BF8QPd ygTdOjG518ws3IHP5dxG3WvPeBoHpW8UaPUSPTNdj7h/U8vQJ/bBV34qvCMm+eVENfkM kwCqhb0LUr8jaRvz3vPXY6S24gB7g5W6DGJqlJ1XrV8t/3jqbhA+C9/ABk41uPc+F52K jzy9w9zUqUUSRf9y15JgwFpKaN9xbYiRo2iDMxuwrTAa2paJUPdOdR3wCDYBi3356Rah YoiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="yTl/KsvE"; dkim=neutral (no key) header.i=@suse.cz; 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 t23-20020aa7d717000000b0042df07451a2si2208783edq.253.2022.06.24.02.13.01; Fri, 24 Jun 2022 02:13:26 -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=@suse.cz header.s=susede2_rsa header.b="yTl/KsvE"; dkim=neutral (no key) header.i=@suse.cz; 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 S230294AbiFXJIz (ORCPT + 99 others); Fri, 24 Jun 2022 05:08:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiFXJIw (ORCPT ); Fri, 24 Jun 2022 05:08:52 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F37C54EDE5; Fri, 24 Jun 2022 02:08:51 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A8EE61F8BD; Fri, 24 Jun 2022 09:08:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1656061730; h=from:from:reply-to: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; bh=I5prPDPC8v4mNhBzFP1CfowAl0viEFJUJ5FoXsjM9BA=; b=yTl/KsvEIdiCfPa5MlcbvyamImobSrJXHFeYtXM6SloqHe1WatHKcELimNody9rd/1KegL 4mNxE/TLV7SaJmmKTCzzHYutq8j61VUIxzYbpKLcfoub447+QNKyLkKwDGvDsXY2K/pVqZ 7mqXFmLAWQ1ffl0FTgwGfkZaQHQhznA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1656061730; h=from:from:reply-to: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; bh=I5prPDPC8v4mNhBzFP1CfowAl0viEFJUJ5FoXsjM9BA=; b=iP7wo0m0m496x+PhW0gpMvQc98uRKgYSu92Ai1GteOO/7gjJCevmBprXHgMKR5kFoKE8wF ZS3ORVE7q/44ShCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 718DF13480; Fri, 24 Jun 2022 09:08:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id hvoIGyJ/tWJGfgAAMHmgww (envelope-from ); Fri, 24 Jun 2022 09:08:50 +0000 Message-ID: <73c277f2-7189-81ee-8d6c-624cbd145d4c@suse.cz> Date: Fri, 24 Jun 2022 11:08:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH RESEND] tools/vm/slabinfo: Handle files in debugfs Content-Language: en-US To: =?UTF-8?Q?St=c3=a9phane_Graber?= , linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Andrew Morton , Faiyaz Mohammed , stable@vger.kernel.org, Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim , Hyeonggon Yoo <42.hyeyoo@gmail.com> References: From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, 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 6/23/22 23:45, Stéphane Graber wrote: > Commit 64dd68497be76 relocated and renamed the alloc_calls and > free_calls files from /sys/kernel/slab/NAME/*_calls over to > /sys/kernel/debug/slab/NAME/*_calls but didn't update the slabinfo tool > with the new location. > > This change will now have slabinfo look at the new location (and filenames) > with a fallback to the prior files. > > Fixes: 64dd68497be76 ("mm: slub: move sysfs slab alloc/free interfaces to debugfs") > Cc: stable@vger.kernel.org > Signed-off-by: Stéphane Graber > Tested-by: Stéphane Graber Thanks, added to slab/for-5.20/debug > --- > tools/vm/slabinfo.c | 26 ++++++++++++++++++++++++-- > 1 file changed, 24 insertions(+), 2 deletions(-) > > diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c > index 9b68658b6bb8..5b98f3ee58a5 100644 > --- a/tools/vm/slabinfo.c > +++ b/tools/vm/slabinfo.c > @@ -233,6 +233,24 @@ static unsigned long read_slab_obj(struct slabinfo *s, const char *name) > return l; > } > > +static unsigned long read_debug_slab_obj(struct slabinfo *s, const char *name) > +{ > + char x[128]; > + FILE *f; > + size_t l; > + > + snprintf(x, 128, "/sys/kernel/debug/slab/%s/%s", s->name, name); > + f = fopen(x, "r"); > + if (!f) { > + buffer[0] = 0; > + l = 0; > + } else { > + l = fread(buffer, 1, sizeof(buffer), f); > + buffer[l] = 0; > + fclose(f); > + } > + return l; > +} > > /* > * Put a size string together > @@ -409,14 +427,18 @@ static void show_tracking(struct slabinfo *s) > { > printf("\n%s: Kernel object allocation\n", s->name); > printf("-----------------------------------------------------------------------\n"); > - if (read_slab_obj(s, "alloc_calls")) > + if (read_debug_slab_obj(s, "alloc_traces")) > + printf("%s", buffer); > + else if (read_slab_obj(s, "alloc_calls")) > printf("%s", buffer); > else > printf("No Data\n"); > > printf("\n%s: Kernel object freeing\n", s->name); > printf("------------------------------------------------------------------------\n"); > - if (read_slab_obj(s, "free_calls")) > + if (read_debug_slab_obj(s, "free_traces")) > + printf("%s", buffer); > + else if (read_slab_obj(s, "free_calls")) > printf("%s", buffer); > else > printf("No Data\n");