Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1083824pxb; Fri, 22 Apr 2022 19:04:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJlsNfAP021tUXgE13WcgVoEXTc616yg6el+f0QKGvFdIKxAbd0ziUtGWYViTuC2dcjdXv X-Received: by 2002:a17:90a:5298:b0:1ca:7fb3:145 with SMTP id w24-20020a17090a529800b001ca7fb30145mr8621611pjh.200.1650679454481; Fri, 22 Apr 2022 19:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650679454; cv=none; d=google.com; s=arc-20160816; b=nlqGWHdHfZPXwTOqI5nOc3oTlVtliH61aGiF3n6pryN5cSqPFYsTLIEiNCbmtJqntz tZIf3H0yyvSg4/sYPVVO8AP0MMkVrC55bjARtQHtyWDARbTFGHlCcYJLkwn0Jg5lZFIl 1sT6E6pIK9Y2vRDvX0U6RkRih7QqAZgkoMbEgzTTE1J3lEYOA2200btZ/eXzd8MxhA0p WA6hz1qqkQxOz04Sw/zLBt9xoWucj9dN+vCfijkPUzmLF3IskMqrmOMT6y++SVkKXvm5 YputciecRlWja+G/NSiWlwTveNJlc+xe4ybotFLm24BvQcZtI/qjPVx7lv8naQKB+n2Y 2UeQ== 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=12Aii0jWw/m/a/Ftf0Ul3RDKgJHLmfcJr6TYwlkHk18=; b=b3xyOTk0zpxImmzh4hPxk5pBXTbDjPz3rhh8o7J2pF0HJfo9DH74/XL08Eq4PTSyLd WEL/qY+K85Oaz2KH+wyp2wLZ8SJy6QovIaS/Sg4xfqMBE7k4Zz3FDmqyW37crPzGxw/n EttjL5eViFNJ0CVvf7cLWzmk+wEwJXWahlgqOJbzaCiIUNx4ZNgki/BQMap+xthcFAK1 DMj0q0ETUX91mpoHaHW/E4G+HYQmrvlgcZul/6dLlPGaW6nohv2kC1gdXhx/wWoY7WiO TnGbjUH8rJOnvCWLubenJ5dq0E6B8YjXINfUVackExxjY+mwbN5rGYCNX1mSos3SCujb LBTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=LgGXXyUC; 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 i15-20020a636d0f000000b003aa52e86ff1si10471320pgc.114.2022.04.22.19.03.23; Fri, 22 Apr 2022 19:04:14 -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=LgGXXyUC; 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 S231211AbiDWB2k (ORCPT + 99 others); Fri, 22 Apr 2022 21:28:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229894AbiDWB2i (ORCPT ); Fri, 22 Apr 2022 21:28:38 -0400 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BACA8249302; Fri, 22 Apr 2022 18:25:42 -0700 (PDT) Date: Fri, 22 Apr 2022 18:25:34 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1650677140; 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=12Aii0jWw/m/a/Ftf0Ul3RDKgJHLmfcJr6TYwlkHk18=; b=LgGXXyUCPiF5DAduAqYEHY34GgdGKvApqAY8LkDtSQR+EirE20cxkNSXZLjhg0cfEgTTqZ jHVO/j1Pj8LMS1RXoHtPVkftzxQg1QhJpCDs7Xq0NmxMkLS3qx0Fo373cMjI3Nqf7HJfNk yMUgGGzRsAee2PuBVAKxuI8Bbt458y0= 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> <20220423004607.q4lbz2mplkhlbyhm@moria.home.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220423004607.q4lbz2mplkhlbyhm@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 08:46:07PM -0400, Kent Overstreet wrote: > On Fri, Apr 22, 2022 at 05:27:41PM -0700, Roman Gushchin wrote: > > 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. > > Not quite following what you're saying here...? > > If you're complaining that my current top-10-shrinker report isn't memcg aware, > that's valid - I can fix that. For memcg-aware shrinkers each memcg has it's own LRU (per node). If you want to print top-10 system-wide lists you need to call ->count_objects() for each shrinker for each memcg for each node. It's quite a lot of work for an oom context. > > > > 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. > > Oh, and the concern is allocator recursion? Yeah, that's a good point. Yes, but not the only problem. > > Do you know if using memalloc_noreclaim_(save|restore) is sufficient for that, > or do we want GFP_ATOMIC? I'm already using GFP_ATOMIC for allocations when we > generate the report on slabs, since we're taking the slab mutex there. And this is another problem: grabbing _any_ locks from the oom context is asking for trouble: you can potentially enter the oom path doing any allocation, so now you have to check that no allocations are ever made holding this lock. And I'm not aware of any reasonable way to test it, so most likely it ends up introducing some very subtle bags, which will be triggered once a year. Thanks!