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 9766BC27C79 for ; Tue, 11 Jun 2024 23:03:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5B3A6B009B; Tue, 11 Jun 2024 19:03:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE47C6B010A; Tue, 11 Jun 2024 19:03:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B87236B010B; Tue, 11 Jun 2024 19:03:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 984686B009B for ; Tue, 11 Jun 2024 19:03:54 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 17495C03D3 for ; Tue, 11 Jun 2024 23:03:54 +0000 (UTC) X-FDA: 82220137188.12.D4309FA Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) by imf21.hostedemail.com (Postfix) with ESMTP id AEA2D1C001E for ; Tue, 11 Jun 2024 23:03:51 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=QipTlLjG; spf=pass (imf21.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.174 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718147032; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MRAlcehmKrH8u2eO41EtyxgbQ0HOlcGAgKUeCSwiCvE=; b=lQifAhhFGnwEZqnin9MNc5f1r9ntwehOIlmxH5Fzq+oZ55YvxI26pVINErQYWbC2tL+jAg h9EZQlyrXrhF1cDXBtgl5MBr5aGkn8Ts9YKkkTKv0QhLnJtVxhfzfye9p2OE72Sofz3pOj DmI6RH/WRAoqrVGwM1bdu7i+R+bH48k= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=QipTlLjG; spf=pass (imf21.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.174 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718147032; a=rsa-sha256; cv=none; b=e9RRSOQFNYXrnEapulFr7GqXrFMYzIKT1TwyO8dkcY2HFVHWrP8DT5dFQtjBHQXXM18RnA 8nnR5buRSWKqswmHcFjXmjkn1VwLRhUzRMPC7DlE94UGI+rLaCsrknUO6EMnV37YvsOFG+ +4k/cN/Y5o6VK5nQVRD+Lmzd8yGZSk0= X-Envelope-To: nphamcs@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1718147029; 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=MRAlcehmKrH8u2eO41EtyxgbQ0HOlcGAgKUeCSwiCvE=; b=QipTlLjG2G3TIGefG8JkL0kQebRpKYyXoKIwHK+5dDUxI1qQW+BCsK3wIHqY/y7dCRYeUB fpV8gx5qA4ty6q6dhhJS5oNVXyacNmsh3b8U6fmZdMSPU7XZJMMJAQZTFfw1lIy3gYwn3Z Pb80J3UaMMdhJea8d6QDRgebMdbtFbw= X-Envelope-To: flintglass@gmail.com X-Envelope-To: hannes@cmpxchg.org X-Envelope-To: yosryahmed@google.com X-Envelope-To: chengming.zhou@linux.dev X-Envelope-To: corbet@lwn.net X-Envelope-To: akpm@linux-foundation.org X-Envelope-To: cerasuolodomenico@gmail.com X-Envelope-To: linux-mm@kvack.org X-Envelope-To: linux-doc@vger.kernel.org X-Envelope-To: linux-kernel@vger.kernel.org Date: Tue, 11 Jun 2024 16:03:43 -0700 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Nhat Pham Cc: Takero Funaki , Johannes Weiner , Yosry Ahmed , Chengming Zhou , Jonathan Corbet , Andrew Morton , Domenico Cerasuolo , linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 1/3] mm: zswap: fix global shrinker memcg iteration Message-ID: References: <20240608155316.451600-1-flintglass@gmail.com> <20240608155316.451600-2-flintglass@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: AEA2D1C001E X-Stat-Signature: 3nn97ji9aepa1gnx41y9bcf1ahiu54dt X-HE-Tag: 1718147031-888449 X-HE-Meta: U2FsdGVkX19HsFv3IIOAsxwVvVpMLXJ7GTgKwMGHAYm99V5UHAFLekkp0Hqy71ZaHKUJzG2RhB6QZZtQFVP0rsuIcAVAN/PPuA6y6M5n/vjoyQMfJ3JOVbJuYWe5BAXxxLLUVqHSKD0RC8l3QVtSfhzRfJTWFHqi6LLdPjhaViZatnhTjbWJwOkn/VaYOXo0TkgAy+OI7fFT9a4wlusjJT6whb9B3zLlBc2xNp4FTFgJ/sRLphu+qbN7MlBoRUR3Rgmub4vjzggR1EMfMHmF60+LNddnGhTKLXDUZhsCMCcbHYkF3jkTp4TujA68OsPt4ZYNy5HyRlpG3xzsyEzZ3xNsZBtW+FTb3X1tQsnZQgjv6N0JfwLH8qizHzZDhNGotr+8JvGcW9zzTKZTDe0eMMLuVgCcdpthaY79ibIrzzMo2KH1TAnyLII9Ddu4inaOlyhAucE1EruELRFmNcLs1Hqcl+byBD8iwv7tGv2OvufLSfGurbH3lAeZLGYnru+g65tEU30o4sJ3FnRJI/d5KgzsJZqyy+alOr/sJPhsygcG1uVFVn8Q9BPEE/BHNq/pNDReWALMRJ4wb8sx9btOQHFaZq8X2oU6f/BTEQgvTqwWmmaF1LajPazfU8opLEZ1fWp8nDjrDtMGctb6ddPAcJO0Le9s9Eza7pdulUnN+mZNZPbbYZAi38fOG+Qj2oxw+d1x9MIWIIBesx1Hzpuzdbg6CgxEF9BErz1QDyCPDA3W7QlPOHjMHyDa5izKsLCdfddQlKpt/FCL0zwfcEUTM7+WFlFwJhZG+cBNkzdVxg3C03qTgmK3pphu3oqCvBZpfo4NxHlv1JWesS6nBI5O2e3sLFY3wNdttEV54slWrGMXNKSI/RY+AGypw0lXyU9hbMrCtWO0Au9xskPhFaxTZYcrVwo63FQJzkVVnqTbDG5JP9ll3IHkaK4rWzxE6EORL8OTfTUzbXZSEd4IEdz hpW2E+rz 74PyaiEIU0LdSbVUECiUxR6cSSUwtBMv0IPkW3j3D+LE+C//aAptrRteRPTjHBDMYqFGghtGJIt+gp24XwIffmZ3KXg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 Tue, Jun 11, 2024 at 11:26:12AM GMT, Nhat Pham wrote: [...] > > Hmmm yeah in the past, I set it to NULL to make sure we're not > replacing zswap_next_shrink with an offlined memcg, after that zswap > offlining callback for that memcg has been completed.. > > I suppose we can just call mem_cgroup_iter(...) on that offlined > cgroup, but I'm not 100% sure what happens when we call this function > on a cgroup that is currently being offlined, and has gone past the > zswap offline callback stage. So I was just playing it safe and > restart from the top of the tree :) > > I think this implementation has that behavior right? We see that the > memcg is offlined, so we drop the lock and go to the beginning of the > loop. We reacquire the lock, and might see that zswap_next_shrink == > memcg, so we call mem_cgroup_iter(...) on it. Is this safe? > > Note that zswap_shrink_lock only orders serializes this memcg > selection loop with memcg offlining after it - there's no guarantee > what's the behavior is for memcg offlining before it (well other than > one reference that we manage to acquire thanks to > mem_cgroup_iter(...), so that memcg has not been freed, but not sure > what we can guarantee regarding its place in the memcg hierarchy > tree?). > > Johannes, do you have any idea what we can expect here? Let me also cc Shakeel. > > > mem_cgroup_iter() does a pre-order traversal, so you can see mixture of online and offlined memcgs during a traversal.