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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BB85C433EF for ; Wed, 16 Feb 2022 23:12:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71A156B0074; Wed, 16 Feb 2022 18:12:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A1816B0075; Wed, 16 Feb 2022 18:12:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59AD76B0078; Wed, 16 Feb 2022 18:12:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id 4B3596B0074 for ; Wed, 16 Feb 2022 18:12:11 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 087198249980 for ; Wed, 16 Feb 2022 23:12:11 +0000 (UTC) X-FDA: 79150193262.12.8F20AB9 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf31.hostedemail.com (Postfix) with ESMTP id 18E5220004 for ; Wed, 16 Feb 2022 23:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=MHGgiC9rBj6MP0UDuOk7y9noXwqSZMIVzGxEtpgjmyY=; b=KkSwZhxwJCqogQe+g2JbUYMk30 0nALJj3wADcM6qiG1L0mDTzDv9scS8xmeg25ePbT03pUBsXJCduluuDm7/tb3dmCFapy0BehKUBBS +kvB/gDbByb79n82EyRrs55nLeqcZTxM0kfMrVLE59/c3+ZhDaKp8t2ivq+bjsjuRu0OUYzRjWtAD e4y10NaytgEQjUPlbL9ZWtHCZumHZ8SxTJ8jD3tCuR0TJuQrThNgQugHM1jLLQa1KerTLQeUtmrQt GQ10L4IMyzOEsHyXgx+RUeSuvjZ3ofpSbEKdx67DQe6VkInapfFQNsKH/IpFKeKJGX31B2dnOpMH3 vYCpJ9qQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKTSs-00F6qN-AG; Wed, 16 Feb 2022 23:12:02 +0000 Date: Wed, 16 Feb 2022 23:12:02 +0000 From: Matthew Wilcox To: Roman Gushchin Cc: Vasily Averin , Andrew Morton , Linux MM , Vlastimil Babka Subject: Re: tools/cgroup/memcg_slabinfo.py is broken Message-ID: References: <327b9e92-88bb-d66f-e07c-526161db539b@virtuozzo.com> <35486a00-791c-3b1b-14e0-476e6242709b@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 18E5220004 X-Stat-Signature: skqkefqrusdwajeeo16u5rnyurg9zjkj Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=KkSwZhxw; dmarc=none; spf=none (imf31.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1645053129-752266 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000035, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Feb 16, 2022 at 02:26:18PM -0800, Roman Gushchin wrote: > On Wed, Feb 16, 2022 at 09:55:29PM +0000, Matthew Wilcox wrote: > > On Wed, Feb 16, 2022 at 01:44:10PM -0800, Roman Gushchin wrote: > > > On Wed, Feb 16, 2022 at 09:12:01PM +0000, Matthew Wilcox wrote: > > > > On Wed, Feb 16, 2022 at 12:52:36PM -0800, Roman Gushchin wrote: > > > > > The problem can be fixed by explicitly casting struct page * to struct > > > > > slab * for slab pages. The tools works as expected with this fix, e.g.: > > > > > > > > This feels like a quick fix, and not really correct. > > > > > > Do you mind to provide a correct version? > > > > I know nothing about python, nor how to even run this script. But this > > is the kind of thing I was thinking about. > > > > I didn't do the 'skip over tail pages' because I have no idea how > > you'd tell for_each_page() to do that. I don't know where to get > > drgn.helpers.linux from, so I can't look at the implementation. > > Maybe it already does that. > > Is there an actual plan to set the slab flag for tail pages? > If not, why to check both? It's fairly expensive already, so I'd > not add any additional checks if there is no strict necessity. The plan to set the slab flag on tail pages is probably about five years away. There are a lot of moving parts before we get there. I think you could reduce the cost if we had a for_each_folio() loop. Most code doesn't really want to look at every page, so having a shorter list (and iterating over each page within a folio for the few places that really do want to see every page) would be a good tradeoff. > > @@ -145,14 +145,14 @@ def detect_kernel_config(): > > return cfg > > > > > > -def for_each_slab_page(prog): > > +def for_each_slab(prog): > > Here I'd keep _page (or _folio, if you want), because > it makes it clear that the function goes over all pages > (and is expensive therefore). But there's no intrinsic reason that it should. If that's a performance problem, you could keep slabs on a separate list from, eg, file or anon memory.