From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) (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 7E11E22B8B6 for ; Fri, 13 Feb 2026 20:09:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771013349; cv=none; b=RmsF/c+ddemsHQd5s0uuSLXTaEzj4SHAF89SoJPOtP0SDJwQ2ZQrVMB7CaJDRqbNGPP6mUmpED9TuSMNlm2/vE3IH7GrHMCyvjhp9BL80ew715B1TuDMkxcq7jktA2E2DAsUmULm+rd03RKPsseWdm9o6Ajuk1cBfn7OFrAoVEE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771013349; c=relaxed/simple; bh=grx87uhUn214R0/16Oz25CTUsC7j9HEq906lrr+h3BU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=prQ3nYVgGq/bwgwOxIRYB219SJbYmrNgWnQ5u+1ZYhVZxOV3WP7C97/+ZssAqRZCnAiiYAQSij8IpOKys2XuWKxnE3I4M0aKOEdz4M6YL1ImYGtvQ1smakBgI1tl/RuWzH530TIvSecAefHFMruAbjrL+dXTgEpX/ay1mPHU6iE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=ISJN1gNM; arc=none smtp.client-ip=209.85.222.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="ISJN1gNM" Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-8cb4097794dso112124085a.3 for ; Fri, 13 Feb 2026 12:09:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1771013346; x=1771618146; darn=vger.kernel.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=7qPVnjkUUN7g5ZDl/2W4jZj/HTnTNtx2ZZEtCyQsavo=; b=ISJN1gNMABWfEcEWMcyhsdgo47V34/ALFe2OAjLgxd/QJYVOTlYx21N0K4YvOGsqGR IMNoqTAU3j+qVs3ypYQozP+fIIiluWv5w8z3ItT32q4wLYJe3FOrp888OS9i2y/mcQru 2DuTAyahPq6QW2lrZBTHL0tJZ+hKa/9SpZ2hT3dxo3//u2qGrRn6h7/+54kQCmD8PDzG 0Z5/gdoUt/Kl9cFEJWy/15pvyIKMxIuodSRhjJob82yLXFdaUU4xtJyp9MBNt8K9vhF/ dgEvRKvIhxRVyPFKiHHsHAB0p0ul3khzh/0edKI8myov36ARug9WOo98onbK2FuICTnC qaPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771013346; x=1771618146; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7qPVnjkUUN7g5ZDl/2W4jZj/HTnTNtx2ZZEtCyQsavo=; b=iN1SnB+pLfHBQjWrxppx+s6117T1mJ6nE2/WeQReL8Q97M7QqKdxCm7C5/AUWR2PqK aJ8/sEkXUF5Ffa2dhhi0tQBMU5dEhB7wbfz2oGtXgqkGcREdqk4wzIh4Z3mLw+wPx07X T2buUUQJnMyQMoGIPhEFg0oUqXlicHDnMkj/++5Dgx0QF/Itn6NdpzzyuqmEFgwi529e a92fQeT+NX2Cyn//OmRPX7UN2PykbD6KO8coC5q0Z48haBAGsJYydQHJt8BZtNjgcyX+ hC2Rn1pRjCGXzFNpo1b9fL5RdTO5+cmTdEnG5G35HbvyUlvgapap1sBT3bT+JGuaxDfZ gOOw== X-Forwarded-Encrypted: i=1; AJvYcCW27xxWVP+uj3V76Kd/YvHCv1bN9+HNKOd7pnnWwWVlBUTd4C+dUTLM2DUUyWaz2ng0UC6/FTRU0QHMjxU=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9d08otJTx/Xlx3ADbZoh5aLhnZgB+FRwBuSxGJBBJiswaEubb Zeku8a8uNmXMyrA3XNrbFLHMU0XQmnuwAVmRthTFsdSX97xyAiNzEwttInli7n4LcSE= X-Gm-Gg: AZuq6aJHAHGqrvZdAW2JV1yk+A/XQDcOa5yu4doeBnChZy+CEp1VCaJGJRQfJeti8VL AC+SUQ+RZEJE7qbQIe2tcZNUJdbAXpwJYWUJwywDxYiOOlKZUnoL5NXGiIWBfoTJ4w9b54Rs6Zs RqmmCLcSywPzl38j6O8ImVEeCkVUQEOAb8YlkXcRwKCOD/NEk6awwAYI/9Vh0zsJDwednHHVW6V rv5Ij4+ELbJCoHz59VIhNQPQ9Ygssuxm05GJ2Qz1w9uvAWaSJlLbx7Bn2TMcu29RES2GE/kSZ47 rF67gFmi/5Q/kh6lvkvIQRjPT6SVYUdVI92Q3+a/pysXK2AsKGiRLX9BVGosP9Ipfedly8152TV 5S9fBEgT8AW2Y2bHF6JwK+KOFQ2et27KcuTlJuvZpjFVRL2rAP2eUkKbUV9fwOHkH4Rp2AOqaZe 4z7WxqSHxMzCMuXGPQinROng== X-Received: by 2002:a05:620a:1a13:b0:8cb:3bca:bb3a with SMTP id af79cd13be357-8cb4249f104mr378592785a.67.1771013346200; Fri, 13 Feb 2026 12:09:06 -0800 (PST) Received: from localhost ([2603:7000:c00:3a00:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8cb2b1c7ef7sm723625085a.28.2026.02.13.12.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Feb 2026 12:09:05 -0800 (PST) Date: Fri, 13 Feb 2026 15:08:57 -0500 From: Johannes Weiner To: Kairui Song Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , linux-kernel@vger.kernel.org, Kairui Song Subject: Re: [PATCH] memcg: consolidate private id refcount get/put helpers Message-ID: References: <20260213-memcg-privid-v1-1-d8cb7afcf831@tencent.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260213-memcg-privid-v1-1-d8cb7afcf831@tencent.com> On Fri, Feb 13, 2026 at 06:03:32PM +0800, Kairui Song wrote: > From: Kairui Song > > We currently have two different sets of helpers for getting or putting > the private IDs' refcount for order 0 and large folios. This is > redundant. Just use one and always acquire the refcount of the swapout > folio size unless it's zero, and put the refcount using the folio size > if the charge failed, since the folio size can't change. Then there is > no need to update the refcount for tail pages. > > Same for freeing, then only one pair of get/put helper is needed now. > > The performance might be slightly better, too: both "inc unless zero" > and "add unless zero" use the same cmpxchg implementation. For large > folios, we saved an atomic operation. And for both order 0 and large > folios, we saved a branch. > > Signed-off-by: Kairui Song Nice improvement! Acked-by: Johannes Weiner