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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A31A1C636D3 for ; Fri, 3 Feb 2023 00:01:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233378AbjBCABT (ORCPT ); Thu, 2 Feb 2023 19:01:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233375AbjBCABP (ORCPT ); Thu, 2 Feb 2023 19:01:15 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED7F2841B3 for ; Thu, 2 Feb 2023 16:01:00 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id on9-20020a17090b1d0900b002300a96b358so3415880pjb.1 for ; Thu, 02 Feb 2023 16:01:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=87LqBY1cmxJIDzlBwcArixEGRBUdoaZyq1gL8jLOlBo=; b=DLV66Jzr/7xWnW/DB5gYUzwmub8DiPYt26/ICu8uqaIhyj/Y69zetvYZjUSTNA7JP4 oVFIW77wI167XlBLdmGFDdBQltemXKC02tY+062ITt7Fz7d2TNa4f42A+jhli5StHy08 4llhwpGMDi0YoGL3ASI82cb0n+Jneqd4L8TQs/k8Bl7K34gebF7CtuiqCdXKrXEMHzWG +78I7Fd6vJv9IAIj+P8oUAjNdRi92lx+gwfIj1aM6vDJk7BZXhxx+xsLu76rYXE4iMux BKyGx4MS/N9hjYr2+vYpvxDJcYByMMdDkUAB25zywwQdmKUb4WsI5MtyEeLjFgjw4eg+ aFbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=87LqBY1cmxJIDzlBwcArixEGRBUdoaZyq1gL8jLOlBo=; b=ljm3u0V6l00z8O3KvY7/6aTUpTFjMFD7vv8mAoM7Tv0yU/duzBv4rGeZBHIB/hYy3V DQb1ZeSQelbwblwGnAfObCzudyWrt7APJ76DBe80puwSdr1Ibe9Gg3ykIQ35znUT+D+H M6tHeZuc0Lr8h3w4Ww2Dkg4Xu5bELA7IzNKYqwdjU+sBtwb8pZzi/O6yuBVgG4tdTUPx 8gWbe8YC5Qwk49ysQ8hPQgvpgWDx4PpME1SRbXvAQ5kaeE6VQp06CUEIvjRl9bqCWfqK qu7sHBCefAk5PItXSqx8B7nTl+XBkYqE9/9Q8e+fsAjz8De3uz6KVrqQVgKasetJdK/C H9jA== X-Gm-Message-State: AO0yUKUY/ooFWqHVl80Lft1ArzF5LFeWx0toJqMqp8jW7UtVnBQOsmtf AcUEcyaejvDxJ/haN3jbCx8fPg== X-Google-Smtp-Source: AK7set9JaCKtnriracbwmug7u2ZHT3TTrBbzfIKwL1tiM1SyRqwMx3ca50uMJGBzPDJ4jy/LfeFDhg== X-Received: by 2002:a17:902:f0d1:b0:198:dec0:c926 with SMTP id v17-20020a170902f0d100b00198dec0c926mr231076pla.21.1675382460437; Thu, 02 Feb 2023 16:01:00 -0800 (PST) Received: from dread.disaster.area (pa49-181-4-128.pa.nsw.optusnet.com.au. [49.181.4.128]) by smtp.gmail.com with ESMTPSA id x190-20020a6263c7000000b00593a1f7c3dbsm292980pfb.10.2023.02.02.16.00.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 16:00:59 -0800 (PST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1pNjVh-00AfBG-Cq; Fri, 03 Feb 2023 11:00:57 +1100 Date: Fri, 3 Feb 2023 11:00:57 +1100 From: Dave Chinner To: Yosry Ahmed Cc: Alexander Viro , "Darrick J. Wong" , Christoph Lameter , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, "Matthew Wilcox (Oracle)" , Miaohe Lin , David Hildenbrand , Johannes Weiner , Peter Xu , NeilBrown , Shakeel Butt , Michal Hocko , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC PATCH v1 0/2] Ignore non-LRU-based reclaim in memcg reclaim Message-ID: <20230203000057.GS360264@dread.disaster.area> References: <20230202233229.3895713-1-yosryahmed@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230202233229.3895713-1-yosryahmed@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 02, 2023 at 11:32:27PM +0000, Yosry Ahmed wrote: > Reclaimed pages through other means than LRU-based reclaim are tracked > through reclaim_state in struct scan_control, which is stashed in > current task_struct. These pages are added to the number of reclaimed > pages through LRUs. For memcg reclaim, these pages generally cannot be > linked to the memcg under reclaim and can cause an overestimated count > of reclaimed pages. This short series tries to address that. Can you explain why memcg specific reclaim is calling shrinkers that are not marked with SHRINKER_MEMCG_AWARE? i.e. only objects that are directly associated with memcg aware shrinkers should be accounted to the memcg, right? If the cache is global (e.g the xfs buffer cache) then they aren't marked with SHRINKER_MEMCG_AWARE and so should only be called for root memcg (i.e. global) reclaim contexts. So if you are having accounting problems caused by memcg specific reclaim on global caches freeing non-memcg accounted memory, isn't the problem the way the shrinkers are being called? > Patch 1 is just refactoring updating reclaim_state into a helper > function, and renames reclaimed_slab to just reclaimed, with a comment > describing its true purpose. > > Patch 2 ignores pages reclaimed outside of LRU reclaim in memcg reclaim. > > The original draft was a little bit different. It also kept track of > uncharged objcg pages, and reported them only in memcg reclaim and only > if the uncharged memcg is in the subtree of the memcg under reclaim. > This was an attempt to make reporting of memcg reclaim even more > accurate, but was dropped due to questionable complexity vs benefit > tradeoff. It can be revived if there is interest. > > Yosry Ahmed (2): > mm: vmscan: refactor updating reclaimed pages in reclaim_state > mm: vmscan: ignore non-LRU-based reclaim in memcg reclaim > > fs/inode.c | 3 +-- Inodes and inode mapping pages are directly charged to the memcg that allocated them and the shrinker is correctly marked as SHRINKER_MEMCG_AWARE. Freeing the pages attached to the inode will account them correctly to the related memcg, regardless of which memcg is triggering the reclaim. Hence I'm not sure that skipping the accounting of the reclaimed memory is even correct in this case; I think the code should still be accounting for all pages that belong to the memcg being scanned that are reclaimed, not ignoring them altogether... -Dave. -- Dave Chinner david@fromorbit.com