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 EC5C1C10DAA for ; Thu, 30 Nov 2023 03:09:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6EF978D002E; Wed, 29 Nov 2023 22:09:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 69F248D0001; Wed, 29 Nov 2023 22:09:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 567378D002E; Wed, 29 Nov 2023 22:09:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 463028D0001 for ; Wed, 29 Nov 2023 22:09:54 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 18C441405F8 for ; Thu, 30 Nov 2023 03:09:54 +0000 (UTC) X-FDA: 81513141108.21.83E2920 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf30.hostedemail.com (Postfix) with ESMTP id 5FC2880004 for ; Thu, 30 Nov 2023 03:09:50 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=V9okYb15; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf30.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701313792; h=from:from:sender:reply-to:subject:subject: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:dkim-signature; bh=7ML98wtqX8CZrJ1eNLbEm4KE+4Vgc1oCTvjI+9JGlhk=; b=Gzpl6lmaGieMb9+vp8jwGrzQXxvZtwahccGUZK24nKHZsC1XfnUq7PSlgkV+YIG4qgUYvv myDIL0rs0RaB7Tbgkewqgss9uyIWFWUBG9oK74V9tzCI/UTIiN/j3lvpXZpSDsWJyVyXps N0mc1oumT1zVlOsHAAp0iSuu+4JXsL0= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=V9okYb15; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf30.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701313792; a=rsa-sha256; cv=none; b=n/dgKRVN264eGxhlJWCNj+AfJiCbBhIiBsnSyhLiWD0CgcFwjpt4UqNT9EHbr1QVbOHEwR 4VWfK2Z4xblYnEJU0dU3Xp5ezzKJRdQkk9u5vIamLvboophDf5cRtQoPgIXV/5/hTz2jTM LyQJiDltcGHpGQCJIhYJTlaLc48iGRA= Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6cb90b33c1dso112392b3a.0 for ; Wed, 29 Nov 2023 19:09:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1701313789; x=1701918589; darn=kvack.org; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=7ML98wtqX8CZrJ1eNLbEm4KE+4Vgc1oCTvjI+9JGlhk=; b=V9okYb15SNEo3K8pfIsv93fDd/PZzrbLlY1Id9S+W7mPMlwg7ExsA9v1qMnTDcO6cj DqqyJOt5xjX5uy9EzdJPyMINGNTqbOAZ687EA13YC8TWq/Mre1IcwLSndXMPwpoa20ge 7tZN/0Lva4fT35w6+6onSBTQi42RCAbovKqer5ARcA8no/fAMe1LErsvnB3iUngUVMx9 ZsQnUzfHC8eZPKKh+JanjpOlgq6GvQ5riGOo89zoofHT67wjRj7zpPDd+fT6keXhbwkK ukE+G2mOEE71VgyhSfuM77aDpP22zDIinP7SOjVyyt7ZsgAzl9Bx15KQYcVr2IPIXQGr EzWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701313789; x=1701918589; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7ML98wtqX8CZrJ1eNLbEm4KE+4Vgc1oCTvjI+9JGlhk=; b=O1/GARj68lX6istebZ8Hf2PG618UPOjYoJjVn8PAztmcARhE5695EpkzqR61XVMUgv S42nvKcQ26ihPpyUFRunsXH6eQpAhjCrhik8t9dz4H6AXNtcP8IucUaIYHOtQpLp3EF8 xSKekvhfCGnbQsVJrNFzhoOfOJ96qfjdxIz4ppwLmknbhGZwhKTTjT9IY7Vvg6BWBjoq 3t8/RWx1HzsH3NMpsNiUE8n3xjxZawm92kAo4EmWed+jHFOcRhgocXe3PRrHcRkxxVsR 9lir/9Ub/sht5hSvgNkeo6o6MYJXcnd/02rufxbsrbHPbtb3g/a0ueqYU1VDcvAF/+Wd bqCg== X-Gm-Message-State: AOJu0Yyi1/PoHmd+TbsvFqHYbPcJpywta8n/hGYYiaVniy+04E6j/QGC wT6qc6ifeNK27Q7xnBD6dXNImQ== X-Google-Smtp-Source: AGHT+IGbEKAI2ckRey6HuiOMmR5J9o5OVZLIRUhy/y0C4ca1yY3zVvh5twO90WagW+6P+48d3OvyZg== X-Received: by 2002:a05:6a20:5497:b0:18c:2dad:8201 with SMTP id i23-20020a056a20549700b0018c2dad8201mr20301273pzk.4.1701313788892; Wed, 29 Nov 2023 19:09:48 -0800 (PST) Received: from [10.84.152.29] ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id z19-20020a17090abd9300b00283a0c3df63sm173978pjr.54.2023.11.29.19.09.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Nov 2023 19:09:47 -0800 (PST) Message-ID: <04f63966-af72-43ef-a65c-ff927064a3e4@bytedance.com> Date: Thu, 30 Nov 2023 11:09:42 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/7] mm: shrinker: Add a .to_text() method for shrinkers To: Kent Overstreet Cc: Michal Hocko , Roman Gushchin , Muchun Song , Linux-MM , linux-kernel@vger.kernel.org, Andrew Morton , Dave Chinner References: <20231122232515.177833-3-kent.overstreet@linux.dev> <20231123212411.s6r5ekvkklvhwfra@moria.home.lan> <4caadff7-1df0-45cc-9d43-e616f9e4ddb3@bytedance.com> <20231125003009.tbaxuquny43uwei3@moria.home.lan> <76A1EE85-B62C-49B3-889C-80F9A2A88040@linux.dev> <20231128035345.5c7yc7jnautjpfoc@moria.home.lan> <20231129231147.7msiocerq7phxnyu@moria.home.lan> From: Qi Zheng Content-Language: en-US In-Reply-To: <20231129231147.7msiocerq7phxnyu@moria.home.lan> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5FC2880004 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: qwj568hm46i7sbnkgb8kykshki3bn1g7 X-HE-Tag: 1701313790-505473 X-HE-Meta: U2FsdGVkX19SinM6S66iA3L7nu0Tq0uoUVaHE8M+qew1F0lp3rdCBL4VukuB/xOHCgPaTc2k5fyJVd4aXPDSpH8Do5lvjeNtFcevbGX5xSBMoa29oO51645TxrWc485laVs1bKJUJ2StdGR0WWbrMj+RqWc88Ma6GYSps+4g/Pf4HCgmEvjSXxJJR9tJFyHlQlSllBBD4f6qjj74/qx9h0+THyWY3Pm54zfbitCEQ3zF0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ea2brngdzPy/sOflRdpDHN/hK4Q0oOg9YkBFmBGCgBOpXQ+bDyByBEcqu80fFA2G2GCsKgediL/S/QUW/BMa8qyow1UdZ9WFffCJoLMPaGBSv1VoHjD1c0AdbcEMkNQQYig/KCoc8DR4jloUCY3xND2lvyV91RZK7b13BTi8YcDfF2yI1pQg7Vr44zzb88 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000021, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2023/11/30 07:11, Kent Overstreet wrote: > On Wed, Nov 29, 2023 at 10:14:54AM +0100, Michal Hocko wrote: >> On Tue 28-11-23 16:34:35, Roman Gushchin wrote: >>> On Tue, Nov 28, 2023 at 02:23:36PM +0800, Qi Zheng wrote: >> [...] >>>> Now I think adding this method might not be a good idea. If we allow >>>> shrinkers to report thier own private information, OOM logs may become >>>> cluttered. Most people only care about some general information when >>>> troubleshooting OOM problem, but not the private information of a >>>> shrinker. >>> >>> I agree with that. >>> >>> It seems that the feature is mostly useful for kernel developers and it's easily >>> achievable by attaching a bpf program to the oom handler. If it requires a bit >>> of work on the bpf side, we can do that instead, but probably not. And this >>> solution can potentially provide way more information in a more flexible way. >>> >>> So I'm not convinced it's a good idea to make the generic oom handling code >>> more complicated and fragile for everybody, as well as making oom reports differ >>> more between kernel versions and configurations. >> >> Completely agreed! From my many years of experience of oom reports >> analysing from production systems I would conclude the following categories >> - clear runaways (and/or memory leaks) >> - userspace consumers - either shmem or anonymous memory >> predominantly consumes the memory, swap is either depleted >> or not configured. >> OOM report is usually useful to pinpoint those as we >> have required counters available >> - kernel memory consumers - if we are lucky they are >> using slab allocator and unreclaimable slab is a huge >> part of the memory consumption. If this is a page >> allocator user the oom repport only helps to deduce >> the fact by looking at how much user + slab + page >> table etc. form. But identifying the root cause is >> close to impossible without something like page_owner >> or a crash dump. >> - misbehaving memory reclaim >> - minority of issues and the oom report is usually >> insufficient to drill down to the root cause. If the >> problem is reproducible then collecting vmstat data >> can give a much better clue. >> - high number of slab reclaimable objects or free swap >> are good indicators. Shrinkers data could be >> potentially helpful in the slab case but I really have >> hard time to remember any such situation. >> On non-production systems the situation is quite different. I can see >> how it could be very beneficial to add a very specific debugging data >> for subsystem/shrinker which is developed and could cause the OOM. For >> that purpose the proposed scheme is rather inflexible AFAICS. > > Considering that you're an MM guy, and that shrinkers are pretty much > universally used by _filesystem_ people - I'm not sure your experience > is the most relevant here? > > The general attitude I've been seeing in this thread has been one of > dismissiveness towards filesystem people. Roman too; back when he was Oh, please don't say that, it seems like you are the only one causing the fight. We deeply respect the opinions of file system developers, so I invited Dave to this thread from the beginning. And you didn’t CC linux-fsdevel@vger.kernel.org yourself. > working on his shrinker debug feature I reached out to him, explained > that I was working on my own, and asked about collaborating - got > crickets in response... > > Hmm.. > > Besides that, I haven't seen anything what-so-ever out of you guys to > make our lives easier, regarding OOM debugging, nor do you guys even > seem interested in the needs and perspectives of the filesytem people. > Roman, your feature didn't help one bit for OOM debuging - didn't even > come with documentation or hints as to what it's for. > > BPF? Please. (Disclaimer, no intention to start a fight, here are some objective views.) Why not? In addition to printk, there are many good debugging tools worth trying, such as BPF related tools, drgn, etc. For non-bcachefs developers, who knows what those statistics mean? You can use BPF or drgn to traverse in advance to get the address of the bcachefs shrinker structure, and then during OOM, find the bcachefs private structure through the shrinker->private_data member, and then dump the bcachefs private data. Is there any problem with this? Thanks, Qi > > Anyways. > > Regarding log spam: that's something this patchset already starts to > address. I don't think we needed to be dumping every single slab in the > system, for ~2 pages worth of logs; hence this patchset changes that to > just print the top 10. > > The same approach is taken with shrinkers: more targeted, less spammy > output. > > So now that that concern has been addressed, perhaps some actual meat: > > For one, the patchset adds tracking for when a shrinker was last asked > to free something, vs. when it was actually freed. So right there, we > can finally see at a glance when a shrinker has gotten stuck and which > one. > > Next up, why has a shrinker gotten stuck? > > That's why the .to_text() callback is needed: _shrinkers have internal > state_, and the reasons objects may not be getting freed are specific to > a given shrinker implementation. In bcachefs we added counters for each > individual reason an object may be skipped by the shrinker (io in > flight? that debugged a runaway prefetch issue. too many dirty? that > points to journal reclaim). > > I'm working on a .to_text() function for the struct super_block > shrinker, will post that one soon...