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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE6F3C433F5 for ; Fri, 19 Nov 2021 10:42:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6A0BE61260 for ; Fri, 19 Nov 2021 10:42:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6A0BE61260 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 00B4B6B006C; Fri, 19 Nov 2021 05:41:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EFCFD6B0071; Fri, 19 Nov 2021 05:41:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E12456B0073; Fri, 19 Nov 2021 05:41:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id D51636B006C for ; Fri, 19 Nov 2021 05:41:50 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A0D2081CEF for ; Fri, 19 Nov 2021 10:41:40 +0000 (UTC) X-FDA: 78825338760.22.5F7405D Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf30.hostedemail.com (Postfix) with ESMTP id 69961E0019A2 for ; Fri, 19 Nov 2021 10:41:37 +0000 (UTC) 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-out1.suse.de (Postfix) with ESMTPS id 9470B212CB; Fri, 19 Nov 2021 10:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637318498; 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=FEdjSkcmqgaAJi5NZaLQUL1ZPtQeDbsPBnmJqoG7GyY=; b=hnNBpFWw3qJyIJ7hHxIHxLiQDIj0zFoerwi5hKzkRQVU9YTH9VdoLiJiAwz8Yk88ywGLi6 Lw70SQrqwr77sfoISW6jtmQDPLLQ2Zdapj0VN1UhaQJ01ocoMjc8ekWxtw/oBGaGl4WOSa yP1FevKDIKxxWoSFBOUKO7uN8Flp0ZM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637318498; 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=FEdjSkcmqgaAJi5NZaLQUL1ZPtQeDbsPBnmJqoG7GyY=; b=c7eokoxvgRpeHLPNoSsti1DkLyN/RLz/qm+Uo9WUiX9ui4DSbHkg8V768vczNg/VIUeskN +a3u1BK6qO6i81Dg== 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 74DA213A8A; Fri, 19 Nov 2021 10:41:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KkzqG2J/l2GtFQAAMHmgww (envelope-from ); Fri, 19 Nov 2021 10:41:38 +0000 Message-ID: <9a4367c0-8141-f03c-e5a1-13483794d3e8@suse.cz> Date: Fri, 19 Nov 2021 11:41:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 Content-Language: en-US To: Gerald Schaefer , Faiyaz Mohammed Cc: linux-mm , LKML , linux-s390 , Greg Kroah-Hartman , Andrew Morton References: <20211117193932.4049412-1-gerald.schaefer@linux.ibm.com> <20211117193932.4049412-2-gerald.schaefer@linux.ibm.com> From: Vlastimil Babka Subject: Re: [RFC PATCH 1/1] mm/slub: fix endless "No data" printing for alloc/free_traces attribute In-Reply-To: <20211117193932.4049412-2-gerald.schaefer@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 69961E0019A2 X-Stat-Signature: 9cu39bnc141uwh514km8wehx3n56uo6f Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=hnNBpFWw; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=c7eokoxv; dmarc=none; spf=pass (imf30.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-HE-Tag: 1637318497-230216 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: On 11/17/21 20:39, Gerald Schaefer wrote: > Reading from alloc/free_traces attribute in /sys/kernel/debug/slab/ results > in an endless sequence of "No data". This is because slab_debugfs_start() > does not check for a "past end of file" condition and return NULL. I still have no idea how that endless sequence happens. To get it, we would have to call slab_debugfs_show() repeatedly with such v that *v == 0. Which should only happen with slab_debugfs_start() with *ppos == 0. Which your patch won't change because you add a '*ppos > t->count' condition, so *ppos has to be at least 1 to trigger this. But yeah, AFAIK we should detect this in slab_debugfs_start() anyway. But I think the condition should be something like below, because we are past end of file already with *ppos == t->count. But if both are 0, we want to proceed for the "No data" output. // to show the No data if (!*ppos && !t->count) return ppos; if (*ppos >= t->count) return ppos; return ppos; > Fix it by adding such a check and return NULL. > > Fixes: 64dd68497be7 ("mm: slub: move sysfs slab alloc/free interfaces to debugfs") > Cc: # v5.14+ > Reported-by: Steffen Maier > Signed-off-by: Gerald Schaefer > --- > mm/slub.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/mm/slub.c b/mm/slub.c > index f7368bfffb7a..336609671bc2 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -6115,6 +6115,11 @@ static void *slab_debugfs_next(struct seq_file *seq, void *v, loff_t *ppos) > > static void *slab_debugfs_start(struct seq_file *seq, loff_t *ppos) > { > + struct loc_track *t = seq->private; > + > + if (*ppos > t->count) > + return NULL; > + > return ppos; > } > >