Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1044638pxb; Fri, 22 Apr 2022 17:44:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNhVXx7Zg+Ut7H0A1k7ad6aCDDC32ivZBIcdJp/+/KZVbK0+5TdbKotIh7hDB1gucu/zRR X-Received: by 2002:a05:6a00:2408:b0:4f7:a8cb:9b63 with SMTP id z8-20020a056a00240800b004f7a8cb9b63mr7741775pfh.33.1650674656173; Fri, 22 Apr 2022 17:44:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650674656; cv=none; d=google.com; s=arc-20160816; b=AtE0XHqoIfGf3PNq9aLvGUYC6Y95eku3Ve2UyccS+1wTAR2lq7UStxJ4kD1CZATLaf 0wxXtFADcdm8rUtWw7w2O+nRg3aLev2WIQiJ1zaewwxZjNF7oWG7RN1Dna7S7Ry6tegY QBBuWE/90+d+wOOrJYrTsb9/RlJONl3FkUtZ1GunZuTg7X7b2vTs3+bS1DzdOjq2fUZ8 RoMl3vzJfzV44U1XlE8LRL+qZu6a32ehnuv/xkkF0ieueyB8YGR2CFfP6sLOmn8Sp5eH qaJ/95bFMxO86VZy3coLSk4uOCAhqhvKEB+2N4/mX0F+NOFLEUC+NIOSmTPCyTuIJ8KF 3Wog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=XwFF1A7SiuFl1/Uh2mJXT54VhE2HR1r71xU373I5YNM=; b=hcmmJ9r2OEDg4jPd6exj83lk8dix2EWrczIyP2V4kdT+8U1SWR0mAdnpG4ld7P/P+6 wzgDnC+NL8ixiecNym6L8eEnIQDbq3950u3m1U3sg++1izxKoFJ6KdBKi4p6+LYghnrw a++xtsE6lFqELuWS1yueSQeWikhVIaSRrbdxXPVC6TGO0QJ26vCKvksF9oXAsah3jVmZ Id4bYj4XXvR6Q40nZqG5sU0uErok+X6AW941PIS4PqEvJib/dc8MgKAo39AyqoNM3Rnc q/1GI+KGWCzL9YKfISv9RGRyAY1ls1mhNTi9XD4CNIyEQBEUOran0WAmreZ0oHXFM49/ 6tog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="l/XGEbFO"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n6-20020a654cc6000000b003990deab146si9970973pgt.595.2022.04.22.17.44.00; Fri, 22 Apr 2022 17:44:16 -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=@linux.dev header.s=key1 header.b="l/XGEbFO"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230231AbiDWAas (ORCPT + 99 others); Fri, 22 Apr 2022 20:30:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230143AbiDWAao (ORCPT ); Fri, 22 Apr 2022 20:30:44 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F3CD6D4E6; Fri, 22 Apr 2022 17:27:48 -0700 (PDT) Date: Fri, 22 Apr 2022 17:27:41 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1650673667; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XwFF1A7SiuFl1/Uh2mJXT54VhE2HR1r71xU373I5YNM=; b=l/XGEbFO7gqD24thsCKUb4MeMMbv4zsqVLfsR7ioqtnTCt61bZnF+V3lhM7Z0vGcL1qtkD osLaWYi8C2cz/4ONfCe8lr6w5zrLod/m6h6wE4MzYngrQezmGMjmNfr2U8LxNJ5Y4qUwlJ JgoRLDStU2Evm83C+zKg1Ck8FeOGO9w= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Kent Overstreet Cc: Michal Hocko , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, hch@lst.de, hannes@cmpxchg.org, akpm@linux-foundation.org, linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org, linux-input@vger.kernel.org, rostedt@goodmis.org Subject: Re: [PATCH v2 8/8] mm: Centralize & improve oom reporting in show_mem.c Message-ID: References: <20220421234837.3629927-1-kent.overstreet@gmail.com> <20220421234837.3629927-14-kent.overstreet@gmail.com> <20220422234820.plusgyixgybebfmi@moria.home.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220422234820.plusgyixgybebfmi@moria.home.lan> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 Fri, Apr 22, 2022 at 07:48:20PM -0400, Kent Overstreet wrote: > On Fri, Apr 22, 2022 at 08:09:48AM -0700, Roman Gushchin wrote: > > To add a concern: largest shrinkers are usually memcg-aware. Scanning > > over the whole cgroup tree (with potentially hundreds or thousands of cgroups) > > and over all shrinkers from the oom context sounds like a bad idea to me. > > Why would we be scanning over the whole cgroup tree? We don't do that in the > vmscan code, nor the new report. If the OOM is for a specific cgroup, we should > probably only be reporting on memory usage for that cgroup (show_mem() is not > currently cgroup aware, but perhaps it should be). You're scanning over a small portion of all shrinker lists (on a machine with cgroups), so the top-10 list has little value. Global ->count_objects() return the number of objects on the system/root_mem_cgroup level, not the shrinker's total. > > > IMO it's more appropriate to do from userspace by oomd or a similar daemon, > > well before the in-kernel OOM kicks in. > > The reason I've been introducing printbufs and the .to_text() method was > specifically to make this code general enough to be available from > sysfs/debugfs - so I see no reasons why a userspace oomd couldn't make use of it > as well. Of course, I've nothing against adding .to_text(). > > > > Last but not least let me echo the concern from the other reply. Memory > > > allocations are not really reasonable to be done from the oom context so > > > the pr_buf doesn't sound like a good tool here. > > > > +1 > > In my experience, it's rare to be _so_ out of memory that small kmalloc > allocations are failing - we'll be triggering the show_mem() report before that > happens. I agree. However the OOM killer _has_ to make the progress even in such rare circumstances.