From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DBCA367B64 for ; Tue, 9 Jun 2026 03:18:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780975121; cv=none; b=XOglb1zB6hYFbAafZO8JVi6GgBPwdlyLU5ubMH4McEHYNot8HGktmvKGI8jdMJ5UifZTX21t0emwKZoBd5ZJ8lQTeODFBMvqkwE4S6o/Hcm0x99xrX3du48AHgUcRn4C2BDmEvZpU1LDMh0sTqPil1jQLsuCIJJ+GCIT6R7trmQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780975121; c=relaxed/simple; bh=yESwecBwMv/jD2yQrJM4oBpPmBZy0jCTscK7ky2wtrE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mYt34oLxdXCwIRnFs78v91vq0W6dlmFqoD/XxbVllFPTO0dzHh0N9AnlxCKOE1U/vUciwTQaXShWhDVvgJ+6EyjV1eOYBRQ1zF9mlO/ltp/xo+hNMdFJ/QldqAQV97HyBxASPX3XQNbcwtZnBk0lBIuVhDkjFpZjnByYkqgCIVM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=F1DkyNrA; arc=none smtp.client-ip=209.85.216.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="F1DkyNrA" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-36ba706ab46so3395262a91.1 for ; Mon, 08 Jun 2026 20:18:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780975120; x=1781579920; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=w8MhYUiXWRAVVrdhX1Xj1vk/zHhvhBV8KDCeIyuVj2g=; b=F1DkyNrAn358F/khTOVTxqVTN/gI+4PsSZBEeNj6zsve4FaIgH58VGz5i9Bo4+dDgq bQBV4dXk4GO7RgIZbh7D+kzW3/nqEo9laD6GDgeYz/NPLhG2/QqQYhUczc72KZWoNLSE +mPyxnwsfwRYKur6MG6yfS97F+55tOi+HmjcGWQc0ZvtQEF9vCrGic2h7VgmYeJuRkUG lERMzi+CtBUxC8LgdGC1D8xxARX23ahSh1JqIki1wbGopOAsX11MHbwdvvZFTrzEy9f+ XaJ9a1huLjRyT4K4VJwpAvuozAUl2N/QAo3Op8eYUNhRfpa4+ymGQxulj2IxAVaKqcOM DAjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780975120; x=1781579920; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=w8MhYUiXWRAVVrdhX1Xj1vk/zHhvhBV8KDCeIyuVj2g=; b=kKJOIHfGb8ZKUDLfbUyfG9nvutLrVRwOnzHPJrvIydYxHPMkWw1i1aKPuhn37GNrV/ qOI3Al8gelPppQD2U/PK1ILQZbCxr0PIhiDrt94EU5LtMICKe2YklC3tJFS6rPn1ELJp 1JT4T5+QKdu7hPlOd4JusX5Z+n0P8KB9wYmBkifIp2sPxMCqKJZSMHLDcZNa6xFpe18h dmvvqe0BuKXJ1Zl2qBXh1ch3FJtS8355i11U3fMUf533VDh8RJ3IH8O/k8qFUmsZkvQy hGClFzuQKnGDnpruhuO5raEU2vnyA4NOKp65usUu2mBt82xU5bQFKH5eZ5PHInU3kunw ptCw== X-Forwarded-Encrypted: i=1; AFNElJ+EV75dRKxBCrw0+udm7XNA8HLyX0G+u53B2LxGprG7FeAVZEpV5h9Bk3x7UZGt/JIs4GSVgyITihbTjaE=@vger.kernel.org X-Gm-Message-State: AOJu0Ywm8Pd/v8aDNmEZPemUIbqV2FsEn7hBLK9YCWGNo8ccCiC+NuHb wkPaFuAHZOAvBvDFLoK4c+jYUSjXaT6/33CfODV++BBbk0BmFXXTmL88 X-Gm-Gg: Acq92OFOMDIFbLUIUAA+izdUEN2LxojX70Fp8jVKC15WSoeofZRQr+vtdlncbrBdFQC q9d8TAWyLpm8s4Po02o42A5rkQsHu10CXK3eBQIRE/VTCKc91K9b25TwRezZW4Er2HKoQoXX3Z/ izXb7+bZuT0l+ilQsvWyLriexlTE2Gol1bH5K6QvA8CikTPfhTHLruwBlbv6oy1B9C1CrJShM3Z 5OR2HxyndpfaFZTjrocUHPzDY4sPhjJGQihG5gpEqcr1Sf3GYbn24G9F0/Jw0ANTS0wpahkfvrq HtvmUtOQly6MV5hmgG+LdtLxFU4+e2irGG1owKn4OtSMT6WBDHe0AHZDpuBAdPot+fE/Hytd12F ISss4sA5p5pOfdBCUJlxmP/sqfFRkSc3WIGU02TtTOiUBkIrkBlqHrBEBIrevJSYwtfymdddZ6p uOE3yw3mGkBHiUv+wwsYmbKiW+MDGSi/d4wGZH2Yho13jSgyVXnOUFPQ== X-Received: by 2002:a17:90b:1809:b0:368:6998:b49d with SMTP id 98e67ed59e1d1-370eeff6b37mr20150357a91.10.1780975119848; Mon, 08 Jun 2026 20:18:39 -0700 (PDT) Received: from [10.125.192.72] ([210.184.73.204]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c164f8bc5asm204871655ad.27.2026.06.08.20.18.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Jun 2026 20:18:39 -0700 (PDT) Message-ID: <1c25650e-bf98-2863-d505-9b94c385668b@gmail.com> Date: Tue, 9 Jun 2026 11:18:26 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH v3 1/4] mm/zswap: Make shrink_worker writeback cursor per-memcg To: Nhat Pham , Yosry Ahmed , shakeel.butt@linux.dev Cc: akpm@linux-foundation.org, tj@kernel.org, hannes@cmpxchg.org, mhocko@kernel.org, mkoutny@suse.com, chengming.zhou@linux.dev, muchun.song@linux.dev, roman.gushchin@linux.dev, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Hao Jia References: <20260526114601.67041-1-jiahao.kernel@gmail.com> <20260526114601.67041-2-jiahao.kernel@gmail.com> <8c0e60e1-5713-69f0-a687-088c87e75764@gmail.com> <9898f83d-fae9-e284-6b85-c7f4089840a0@gmail.com> <90730fa7-62e7-d5f4-b638-23b22a8509f2@gmail.com> From: Hao Jia In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2026/6/9 02:01, Nhat Pham wrote: > On Mon, Jun 8, 2026 at 9:48 AM Yosry Ahmed wrote: >> >>> But OTOH, this does seem like a recipe for inefficient reclaim. We >>> might exhaust hotter memory of a cgroup while sparing colder memory of >>> another cgroup... But maybe if they're all cold anyway, then who >>> cares, and eventually you'll get to the cold stuff of other child? >> >> Forgot to respond to this part, the unfairness is limited to the batch >> size per-invocation, so it should be fine as long as you don't divide >> the amount over 100 iterations for some reason. Also yes, all memory >> in zswap is cold, the relative coldness is not that important (e.g. >> compared to relative coldness during reclaim). > > Ok then yeah, I think we should shelve per-memcg cursor for the next > version. Down the line, if we have more data that unfairness is an > issue, we can always fix it. One step at a time :) Thanks a lot to Yosry, Nhat, and Shakeel for the great suggestions! Let me summarize what I plan to do in the next version to make sure we are on the same page: - Drop the per-memcg cursor and keep the root cgroup cursor (zswap_next_shrink) logic intact. - Stick to using the zswap_writeback_only key, and change the proactive writeback size to use the compressed size. - Consolidate and reuse the logic between shrink_worker() and shrink_memcg(). Enable batch writeback in the shrink_worker() path, while keeping the writeback behavior in the zswap_store() path unchanged. Please let me know if I missed or misunderstood anything. Thanks again for clearing things up! Thanks, Hao