From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 8F58D418A39 for ; Mon, 17 Aug 2026 14:10:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786975805; cv=none; b=k2BSwL0cPyD36Aajyz+AxBDZTzcimGozYRU5BGDsDwS1iKrR1rX+bnl353jH0Omanu8N+veO0rDONEPSaBcYksBtJ01WSxyVfQD3T5/JcVMJJ/7HwUSfQczpytsHLfajYZ0JmQ+lLL6FiY0DmHLPFtI+TdH3aiq1PLFY4vMhwT4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786975805; c=relaxed/simple; bh=8IDnOBUcoPx547bRYBTR4KUHldQID+VjR0lkpI/78Ag=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mOSFBWMTlyqQJv3c18twsZca4ga/a4Z8YBjNlrbLNR0qve+dKD/NdeGjZxcrsKoGLQ1ObK+HgAapJ1nFZHHx7keNpqdW6S7emE/4IAlX3n0E72Hu9xXZGDB0iKsCExkrv+qt9wOz4EixfVsUmDYIKTW4oMAupAvDPSwmIM7vIvU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=eoQVSLdw; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="eoQVSLdw" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4956242332dso36790005e9.2 for ; Mon, 17 Aug 2026 07:10:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1786975802; x=1787580602; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=8MKoSFy0sjpfHZygpH5fwT4llQ68LAYzLIxwAjtZT14=; b=eoQVSLdw79ijYwViNDJc03PBN8sEa0mXXqOAwUz3sCXHAEZTNAlXtYmr9FPP/34im2 KXEb6lY3hUNDV8XWk9ebxkv+xh2kae30ef/7Ir4W9pxffsDBCk3scVzMIUZV0hi8pzVq NUgbUCsyOnWhAMveFfowR24meh19E/ZSrw8XREq6DVKJfRRyiYVFGdGv/5H0CCRO2m7Z FFLfnxEJR9BcJaSOv62JPDuEOx4CiVRy4d0nKahNnAIdv0KsI4I+OOugEeSnCwPmsimM d9iicZ6aV6Ai0l11Fpwq6t61GWDW6ESRY5s5GbMh6NmvPFJP39EyJgP28f6hQ0DMhqU8 Cisg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786975802; x=1787580602; h=in-reply-to:content-transfer-encoding:content-disposition :content-type: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:content-type; bh=8MKoSFy0sjpfHZygpH5fwT4llQ68LAYzLIxwAjtZT14=; b=jdJuF9N/iFlyBp4SyY/1pKCv54x/eXhD32Q8Bwsgz0M9qiX8yBUDfNz/TfH62+Ufpu aZEY8awuan4zVCb905kacwDKieL0F+lUpege1zJcKcsr+38dzXDA9HGXxPFhHY++4s0v BGPjFfVXb5zc+/JOumt71KuNxL6I/z3z0qCXhE+bpv98fnzLwFeyUwgDEw7umkgDXv++ rhgMAWWL+rp+V2ws2Ua1x2hvi6SgVAOD0flksmklxfoAz+oT8ejMve6cSRjZZGfiA+vo hfit41H3NGhp36iRR2mrj34QTWcKXmdtpVH6UC+mU5pz4yU3NHonbP5fU7nSgLt92m09 1WaA== X-Forwarded-Encrypted: i=1; AHgh+Rr6C/fz8bN+TJM7IV8JkOqpqi+IvFkqV4xEEEVldudffZm3oqnBNEki6zTZcJm3Ymetu9Vag0/kEcOcLns=@vger.kernel.org X-Gm-Message-State: AOJu0YwL3ZKSp/XO7gLUc09C9F803VNTzda8Y4dX3K/i4feH5IyXya6i S2YAotTEr1gWbIMpjcCZgJ9v8DSSEt5idsMHPztoLI9H5/YBEWH8zuBYtwpMrgz0QgM= X-Gm-Gg: AR+sD1001NpT0uODbunTLXFgLyV59Smc0orKRqpRl8BbjMl05pStWt6zpbq0YOh0s5g gVTJEbrGN+S6efGzieAInTdrJLdTU9GetRNVxP2DNgsA+TIJI+3eep5WDyuMfmJtbAZAyIMHW6a PVS7fQpInIFVebHnRxd+jp8nW05zUqe1bfJzGgj8eN4RKNSFQLm6Mi5zAeLV/p46pCUlK1iyQlM /lj855OsN+OPJ90tfIEjFe67+rvy/skqgYxPz/5g1KnrztG54+2btor9nSLzwG8JL351rGKK0b6 UnuQU2fqUGIiOWHX0RzPngsDdpJ1O+BiYFaJq3zdAgbjIeya1ZuPs6i3IR2j122bkRrqqlVW9X4 W1sf6pIafQV6RsirFf4mnkiG3eZBbLB3X2us+KQ63Pz3zZ6hbItZNsxRo8lkHdw7yDsf+1xqhO6 F0Dn8xUpiNf5+geYzz+arbfeTeXi+N3uRJXuUSdXLm+gM90rBzw9C7YBymWWmia1AcdGn969M= X-Received: by 2002:a05:600c:3b8f:b0:495:4491:b8c2 with SMTP id 5b1f17b1804b1-499906ce446mr290282905e9.3.1786975801738; Mon, 17 Aug 2026 07:10:01 -0700 (PDT) Received: from localhost (109-81-86-48.rct.o2.cz. [109.81.86.48]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4999d078523sm45861335e9.6.2026.08.17.07.10.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 07:10:01 -0700 (PDT) Date: Mon, 17 Aug 2026 16:10:00 +0200 From: Michal Hocko To: Song Hu Cc: akpm@linux-foundation.org, audra@redhat.com, bingfangguo@tencent.com, cgroups@vger.kernel.org, hannes@cmpxchg.org, joshua.hahnjy@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, muchun.song@linux.dev, roman.gushchin@linux.dev, shakeel.butt@linux.dev, zhuhui@kylinos.cn Subject: Re: [PATCH] mm: memcg: flush empty per-cpu stock slots on memcg offlining Message-ID: References: <20260817131221.44761-1-husong@kylinos.cn> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon 17-08-26 21:58:39, Song Hu wrote: > Hi,Michal > > 在 2026/8/17 21:29, Michal Hocko 写道: > > On Mon 17-08-26 21:12:21, Song Hu wrote: > >> On Mon 17-08-26, Michal Hocko wrote: > >>> Is there any specific reason why the memcg stays in the cache slot > >>> without any pages? > >> > >> consume_stock() doesn't release the slot when nr_pages hits zero. It > >> is kept for the next charge of the same task and only gets displaced > >> by a charge under a different memcg or by CPU hotplug. The problem is > >> that the offlining drain skips empty slots, so the css reference they > >> hold is never dropped unless something unrelated displaces them. > > > > This doesn't answer my question, really, does it? Is there any good > > reason for this implementation? Why do we need to drop references > > remotely when we can do so when the last cached charge is consumed? > > > > Fair enough. There is no strong reason. Keeping the slot > populated after the last page is consumed only saves a > css_get()/css_put() pair when the same memcg charges again on that > CPU - a micro-optimization from the original single-slot > implementation. This would also allow more effective use of the stock because it wouldn't need to throw other stock away when refilling. -- Michal Hocko SUSE Labs