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 11126C28B30 for ; Thu, 20 Mar 2025 15:08:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE7A8280002; Thu, 20 Mar 2025 11:08:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A96C1280001; Thu, 20 Mar 2025 11:08:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95F01280002; Thu, 20 Mar 2025 11:08:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 79070280001 for ; Thu, 20 Mar 2025 11:08:30 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id ED6B4AC263 for ; Thu, 20 Mar 2025 15:08:31 +0000 (UTC) X-FDA: 83242260822.25.F739F3A Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by imf14.hostedemail.com (Postfix) with ESMTP id D3A4F10002E for ; Thu, 20 Mar 2025 15:08:29 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=l4lPL4bF; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf14.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.179 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1742483310; a=rsa-sha256; cv=none; b=bcpxn9S31fnwbMNdw4RumtW9UKdilYtSaHCdy1Id5EBfiEyI3rnDcCDJGa2iGKY/jzcjf3 1M6mG2u2qi8zeYtB/lZ7ysG9JPXSANRUArtKMcXPeJFcVXY5CuewmziQQnXZ5xyZosLoow s/5MRAPP2SZoxJIDNT90X81EgoerfZE= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=l4lPL4bF; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf14.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.179 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1742483310; 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=+wIue+d1fxHnxh1n/pxsYBdiSsRsmFYUmZTnYav+nCg=; b=gojMlnc2OhIdAyn8agPyg0sOEeNy/B/NSsjDhIkS7bP8bxPg+ORbXUypnfZoKxRoJUhIST 6pBRGB80l0aQ93ZeVfcBikqijCrQsnANczAaKvKBhoWr6Fix727Z9fQgtyHkaqW6/PsrHW r6xPL/waEJZtjJrK8yXXqaPS0HCqAdo= Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-476a720e806so8471391cf.0 for ; Thu, 20 Mar 2025 08:08:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1742483309; x=1743088109; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=+wIue+d1fxHnxh1n/pxsYBdiSsRsmFYUmZTnYav+nCg=; b=l4lPL4bF6vzshk1tXTwC3AxKdHfs1i/4ILuGFrQRkLq0075oVF+QAP6xueVJolGhs8 SMEmiC9vIwK6mbbR+a0pg9FaLvTlTT/Ya8VuIxnK4aavnVn7H2oDyf1Ei7Pbuq32a7Xc ficB1lSMbEOoiXHBcceRtUx3czbiD4QsF8KupRzzI3H6UxiGvahhaqKUVR23yDUk1Tf+ NBhjDxOgtRyos/wM+dzJUJGRzxpO7WbJ0sOEGt+9EZ9D/V0R0tW8OvfpT3f/aS3y+yCn oH8jDI+wrm1F0p/KTNHuGOi5tCcwtvVblde6WGSe4twT7teQwtjfqy7M4PUcWgozcct3 cSBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742483309; x=1743088109; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+wIue+d1fxHnxh1n/pxsYBdiSsRsmFYUmZTnYav+nCg=; b=ldBAxN2krVOZoOVz+Jko8GLUj/kC7mF3TXgbAdndwU+cUYzub+/0J2XDl/CIHEx3ZW MGgiqCvRkxJFgYWWSY9V2uPWdsX08+Qnk6u4dhgVjPCXz3v6wsYUJrpl8iBynhBpbb3Z Eef9F9HuyNUATY3tIncRmnntk/shk2iJV4Zm4CGl/NmSYpsPHcDCtbGVsH//mIrrtMZp jAQuEG5rirN3G4aaiQe+ru4bYch3P01mioHvWkQNPoDSBrSu6yCdUuiOd5aR/0I5ecTK abgXakKPssS43psxeXrATGK/KtvtRQ8xAMu/wTC6ks65tWIyQj9unGiCIFyAGFLQ69Ys a4Ug== X-Forwarded-Encrypted: i=1; AJvYcCXKAM6g6v4WTz5m8txN16EF6yLjIlf0Av8PYsRpIbWxAtdvW1IK8aSEwQmuzeFK3SXIX41SQ2KKxg==@kvack.org X-Gm-Message-State: AOJu0YzC2aogMzRgvPi0c0bVIZyvo8sAQR+BV1BITtmiErs+it11oSLq yxWFi+j+Tl1H08cIEjbBfRXM5OO0rutwuTqrSY+45na/Wk3LEG+3q86Q0W5o6RMy9WVyzMkHyhF f X-Gm-Gg: ASbGncuck6WeusRXVGVbamKm6mIQoKN20nfqVB8U98w1VNyKMVFp4CSUrQKO0jzFdhz jkU8GeY+mLoLJ5/H6n8PSHwdvEoTaVaGD1NKqufdgLQBNXsH+R65JqLRXadqUDeEvDJY7/2NQEE gf0MWQ3D8VrYkCHX7kNJN99j17lo8rkBcDsZY0aYRhVYRMV36uDW76q0AmQPDNa5AQkbM6KSeSB LmIv8Mf25Sio0pK8JAMTqKvbhv5+yPqEQgIFvDt9uPljDHOrIQ7OJxydFfyAalUNDht1Rhiwu28 2mrfR6lpUN/LImc3bwD8Ny11dNzR2q8ScXgLfAapxBs= X-Google-Smtp-Source: AGHT+IEqDT7L31lKb+4Vt3imVDG99K/l6IxQtEuRxofKiOxuNW4VzwDmBVYfyocCiaVRZJSQ1vSRuw== X-Received: by 2002:a05:622a:4cc5:b0:476:6d30:8aed with SMTP id d75a77b69052e-4770839bf5emr111115461cf.49.1742483308620; Thu, 20 Mar 2025 08:08:28 -0700 (PDT) Received: from localhost ([2603:7000:c01:2716:da5e:d3ff:fee7:26e7]) by smtp.gmail.com with UTF8SMTPSA id d75a77b69052e-4771d176113sm209421cf.17.2025.03.20.08.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Mar 2025 08:08:27 -0700 (PDT) Date: Thu, 20 Mar 2025 11:08:23 -0400 From: Johannes Weiner To: jingxiang zeng Cc: akpm@linux-foundation.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, kasong@tencent.com, Zeng Jingxiang Subject: Re: [RFC 0/5] add option to restore swap account to cgroupv1 mode Message-ID: <20250320144722.GH1876369@cmpxchg.org> References: <20250319064148.774406-1-jingxiangzeng.cas@gmail.com> <20250319193838.GE1876369@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Queue-Id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FiIu3sW3juNMAgTYJybE/hp7HU9Z872kN0f5b8BaTR405PqRND502EyLOWMXpB3XiRoJsd30hnba8V6VjpTcs13WfZiluRCfwW1gSu7Z9nTwLuwLNvWwINe4lT7R/lFTVHQ+6Agf7HbxunsjjyFDJlvT6FvUmeFKuSrovJ2ojxYLPxPO1eLzZrtWvNpYM7Zcrt4+gAoS70Ejw9tcwIMS8UaYMmjHVXPBD7956FaMs16YF5vinHLuRcK3T6xbYT9eykyTghwfVVPfL8KNwSaFJrP6FPIxgLVXj33o1ULdv2+F6HLznh7aDk81sjZD5rb0cDdga0n+ZJfouZ7E722gMZ9UW4gVDYRYFS/5ruxXhAiSrWSjx2i//Apm6GouKXsFRK4UPDlBd2dMuETmIwWrjc3n4jcngZdx5RqLdEys0uVz/hEGEijMuG2KErXHVxxPIo5LxxGMxM9QG9y9yiTSFIiNS2ByoqaFaWzHyHTzWMp8yCalnK/zcpnCEp7CZ9Xgtk0iGZaHtrBUUssyq/pBJBSpG9fhPKkle3CqTMkVPIf9Qe0tvhmoA== 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 Thu, Mar 20, 2025 at 04:09:29PM +0800, jingxiang zeng wrote: > If both memsw.max and swap.max are provided in cgroupv2, there will be some > issues as follows: > (1. As Shakeel Butt mentioned, currently memsw and swap share the page_counter, > and we need to provide a separate page_counter for memsw. > (2. Currently, the statistics for memsw and swap are mutually > exclusive. For example, > during uncharging, both memsw and swap call the __mem_cgroup_uncharge_swap > function together, and this function currently only selects a single > counter for statistics > based on the static do_memsw_account. My suggestion is to factor out from struct page_counter all the stuff that is not necessary for all users, and then have separate counters for swap and memsw. The protection stuff is long overdue for this. It makes up nearly half of the struct's members, but is only used by the memory counter. Even before your patches this is unnecessary bloat in the swap/memsw, kmem and tcpmem counters. Fix that and having separate counters is a non-issue. Overloading the memory.swap.* controls to mean "combined memory and swap" is unacceptable to me. They have established meaning on v2. It may well become a common setting, and there might well be usecases where people want one setting for one cgroup and another setting for another cgroup. Or maybe even both controls in one group. And why not? This is a user-visible interface that we'll have to support forever, and deployments will be forced to use forever. Tech debt in the current implementation is not a convincing argument to forever trap us all with a suboptimal choice. Nacked-by: Johannes Weiner