From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 359CD3FADE3 for ; Wed, 25 Mar 2026 16:47:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774457264; cv=none; b=rTmoVM40WgtOq/vwl/rQk5EiVajC6y2gl80L1+GGrqwrXtgfh36rXptdSyd6b96+EVaP9KJloJxTJq4YK+W/LiAHPanD89Yu6Wi1XXIajbKfTIQDkjpT5J2/6M5ue/+5uoJsDGqavdlnXRSfjOb9exTFUmhQYVYjjS6UAKH/q+I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774457264; c=relaxed/simple; bh=K4BxcvVT9DOS+ciJJUryQSjfzZ3lt769DJsYGCnCnxA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=rvCAUSekDgd4yhuNwSD1Umgfl/ImbUv275JzoHLJau72dgiL/jArIxm/P1gA4W5dWLsFFuUccejkjCQeNDpG87C9dm8GU9H0AaRmkZpAw7m04FDevgcA9IC5nUlKuRmPi24dQ5zJe4Ds97PyXEgnU7Ktszw6o6SRfIOt6+vHYNg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=a4Rzizqx; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="a4Rzizqx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774457258; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1qr1ol5vgsFYLsTQCwug9Kc0NRV9WjDpLVa+vxqFIkA=; b=a4RzizqxMFvslvxVVkyQXz1r6+BX1xIG36d5kuLHu7fIG65wqKdqxFixCHlXZx299fLvu1 hsm6vhYP2SjxEnx6wCDABX8vcZB8rKaIgMe2Qbn1nsh1KlNnRvztSo0z04/Z2T9DciiUoG 66F3b4A6mXqL6R1szg3lma0EllvxYiw= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-510-LZwgIJoPN5aDYJv_C8P7yg-1; Wed, 25 Mar 2026 12:47:34 -0400 X-MC-Unique: LZwgIJoPN5aDYJv_C8P7yg-1 X-Mimecast-MFC-AGG-ID: LZwgIJoPN5aDYJv_C8P7yg_1774457252 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 73AC2195607A; Wed, 25 Mar 2026 16:47:31 +0000 (UTC) Received: from [10.22.90.27] (unknown [10.22.90.27]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4E61D19560B1; Wed, 25 Mar 2026 16:47:27 +0000 (UTC) Message-ID: Date: Wed, 25 Mar 2026 12:47:26 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/7] memcg: Scale up vmstats flush threshold with int_sqrt(nr_cpus+2) To: Yosry Ahmed , Li Wang Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Tejun Heo , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Shuah Khan , Mike Rapoport , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Sean Christopherson , James Houghton , Sebastian Chlad , Guopeng Zhang , Li Wang References: <20260320204241.1613861-1-longman@redhat.com> <20260320204241.1613861-2-longman@redhat.com> Content-Language: en-US From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 On 3/23/26 8:15 PM, Yosry Ahmed wrote: > On Mon, Mar 23, 2026 at 5:46 AM Li Wang wrote: >> On Fri, Mar 20, 2026 at 04:42:35PM -0400, Waiman Long wrote: >>> The vmstats flush threshold currently increases linearly with the >>> number of online CPUs. As the number of CPUs increases over time, it >>> will become increasingly difficult to meet the threshold and update the >>> vmstats data in a timely manner. These days, systems with hundreds of >>> CPUs or even thousands of them are becoming more common. >>> >>> For example, the test_memcg_sock test of test_memcontrol always fails >>> when running on an arm64 system with 128 CPUs. It is because the >>> threshold is now 64*128 = 8192. With 4k page size, it needs changes in >>> 32 MB of memory. It will be even worse with larger page size like 64k. >>> >>> To make the output of memory.stat more correct, it is better to scale >>> up the threshold slower than linearly with the number of CPUs. The >>> int_sqrt() function is a good compromise as suggested by Li Wang [1]. >>> An extra 2 is added to make sure that we will double the threshold for >>> a 2-core system. The increase will be slower after that. >>> >>> With the int_sqrt() scale, we can use the possibly larger >>> num_possible_cpus() instead of num_online_cpus() which may change at >>> run time. >>> >>> Although there is supposed to be a periodic and asynchronous flush of >>> vmstats every 2 seconds, the actual time lag between succesive runs >>> can actually vary quite a bit. In fact, I have seen time lags of up >>> to 10s of seconds in some cases. So we couldn't too rely on the hope >>> that there will be an asynchronous vmstats flush every 2 seconds. This >>> may be something we need to look into. >>> >>> [1] https://lore.kernel.org/lkml/ab0kAE7mJkEL9kWb@redhat.com/ >>> >>> Suggested-by: Li Wang >>> Signed-off-by: Waiman Long > What's the motivation for this fix? Is it purely to make tests more > reliable on systems with larger page sizes? > > We need some performance tests to make sure we're not flushing too > eagerly with the sqrt scale imo. We need to make sure that when we > have a lot of cgroups and a lot of flushers we don't end up performing > worse. I will include some performance data in the next version. Do you have any suggestion of which readily available tests that I can use for this performance testing purpose. Cheers, Longman