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 600E3C4332F for ; Fri, 19 Nov 2021 09:43:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E638C61241 for ; Fri, 19 Nov 2021 09:43:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E638C61241 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 223706B006C; Fri, 19 Nov 2021 04:43:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D2C46B0071; Fri, 19 Nov 2021 04:43:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 09B706B0073; Fri, 19 Nov 2021 04:43:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id EFF046B006C for ; Fri, 19 Nov 2021 04:43:21 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B59B782DCA4B for ; Fri, 19 Nov 2021 09:43:11 +0000 (UTC) X-FDA: 78825191382.26.A47DB2E Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf24.hostedemail.com (Postfix) with ESMTP id 3635BB0000B2 for ; Fri, 19 Nov 2021 09:43:09 +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 D512A212CC; Fri, 19 Nov 2021 09:43:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637314989; 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=VX3PGrE+25kT7jUiLyGbGWn7NLwxIdCLfX6UOewXBmE=; b=E2In/Fm7l/NySQZPBXGCz+1MVCMUBys0KjhqF42c3F/eagxa54Evufx67NQuEjNJ8rpvlW jIaDJ9NOb+CzINbWZcODY11QpM+Sks7nxkDw86XK2ZA/McC6WHuqZlg1qx2GWiazdOLN4a lC8ud/jObIQ4aoD7vO903PSs8nnYzHk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637314989; 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=VX3PGrE+25kT7jUiLyGbGWn7NLwxIdCLfX6UOewXBmE=; b=uKGznVZ3f3rOSyuiO2MEoW3cDiSChGoZU5on37c4gMRmp9H3zmFFLLCoMAl7Of/p4yHVSv FRDMeOLz4nvkreCA== 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 AA5C913A5E; Fri, 19 Nov 2021 09:43:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YG86KK1xl2HNeQAAMHmgww (envelope-from ); Fri, 19 Nov 2021 09:43:09 +0000 Message-ID: <48b1acd4-21fe-2d6c-ba68-a95cef86d176@suse.cz> Date: Fri, 19 Nov 2021 10:43:09 +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> From: Vlastimil Babka Subject: Re: [RFC PATCH 0/1] mm/slub: endless "No data" printing for alloc/free_traces attribute In-Reply-To: <20211117193932.4049412-1-gerald.schaefer@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 3635BB0000B2 X-Stat-Signature: 36ng3xibdxgrxeach3ri5xtthzz73bcb Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="E2In/Fm7"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=uKGznVZ3; spf=pass (imf24.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-HE-Tag: 1637314989-234866 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: > Steffen reported endless printing of "No data" when reading from > alloc/free_traces attribute in /sys/kernel/debug/slab/, at least on > s390, but I don't see how this could be arch-specific. > > I must admit that I am completely confused by the seq_file interface Me too, everytime I have to deal with it I relearn it. > in general, but even more so from this specific implementation. Right. > First I suspected a bug in slab_debugfs_next(), because of its very > weird usage of the *v parameter, which seems totally useless, but not > responsible for this bug. Still, out of curiosity, does anybody have a > clue why it is done this way, and not e.g. like this? > > diff --git a/mm/slub.c b/mm/slub.c > index f7368bfffb7a..0b1832b16f5b 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -6105,10 +6105,9 @@ static void *slab_debugfs_next(struct seq_file *seq, void *v, loff_t *ppos) > { > struct loc_track *t = seq->private; > > - v = ppos; > ++*ppos; > if (*ppos <= t->count) > - return v; > + return ppos; > > return NULL; > } Yeah that should work and make it a bit less confusing. > > Anyway, NULL is returned for the "*ppos > t->count" case, as described > in Documentation/filesystems/seq_file.rst, for "if the sequence is > complete", so that should be ok, but still very confusing. Unfortunately, > the documentation does not seem to explain that *v parameter at all, or > I missed it, but in this case here it seems to be simply ignored and > misused w/o any need. > > The documentation does mention that "in most cases the start() function > should check for a "past end of file" condition and return NULL if need > be". So I just added a similar check to slab_debugfs_start() and return > NULL for "*ppos > t->count", which apparently fixed the bug. "No data" > is now only printed once, like it was before commit 64dd68497be7 > ("mm: slub: move sysfs slab alloc/free interfaces to debugfs"). > > However, since I obviously do not really understand the seq_file > documentation, and also not the alloc/free_traces stuff in general, > that fix might be wrong or incomplete. Comments are welcome. > > Gerald Schaefer (1): > mm/slub: fix endless "No data" printing for alloc/free_traces > attribute > > mm/slub.c | 5 +++++ > 1 file changed, 5 insertions(+) >