From nobody Mon Apr 6 11:53:28 2026 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 0C276397E77 for ; Thu, 19 Mar 2026 17:39:06 +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=1773941952; cv=none; b=Fni1qkLarLLHxEmcawOZqL7Gj6C7FQQqrkLG2qsMrVWYid5+4614K7pAykYdx/cc2aKarj+SdCtDbKtgseHxHoCL3JPgYFsgXtO602O69J3JHa3MS7Vz3FFHfIhNVYbCnLYRId0UppTUmOCTRKIY/m+iQveqn10ly1r9ZMWhYnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773941952; c=relaxed/simple; bh=6fOqijcWJ1k9krh6jSFHTpRTFII3w5s4YvCh7ae5EhY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lmCpKLgsc4mHMCBMW+8dQg7a4V0TTl3Mahn2mGuioP/LVS255B9HPiDOycbEHS/PF+k5gFPPqrqaxncOx9hzW2FPYGZS+RvQYoDsq7P7ktlwyARiZgLxP/3ogVVRlGX9vm3ZJCphw8D/yhkDb8eNf8RRsuRtj5YVLPyh3Pzmx/E= 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=YlvAWofF; 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="YlvAWofF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773941945; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G/jvmDsSdenM6skBubfPrd0khnqGba7F4XN6aWwL11s=; b=YlvAWofFTrzZHfJnSP1BLDpx2HmGpSZ8LI9BDhMe1Ij0Z2ErOEzVbs2ogRfJ6O67W2E+bM QCJ1xHR8hPsT2g1RpstbXGUKuxduuzTHEUIFkxbsGsQGQx7sw3dEzKhBpRi+tgcyViXwdE unZ2+nqgAcKOYCGfl6yIKN8xywqraFo= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-98-vOcC0yM0NdWBC-rmiE8CEw-1; Thu, 19 Mar 2026 13:39:02 -0400 X-MC-Unique: vOcC0yM0NdWBC-rmiE8CEw-1 X-Mimecast-MFC-AGG-ID: vOcC0yM0NdWBC-rmiE8CEw_1773941939 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3593E1800464; Thu, 19 Mar 2026 17:38:59 +0000 (UTC) Received: from llong-thinkpadp16vgen1.westford.csb (unknown [10.22.80.194]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E99A830002DF; Thu, 19 Mar 2026 17:38:55 +0000 (UTC) From: Waiman Long To: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Tejun Heo , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Shuah Khan , Mike Rapoport Cc: 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 , Waiman Long Subject: [PATCH 3/7] selftests: memcg: Iterate pages based on the actual page size Date: Thu, 19 Mar 2026 13:37:48 -0400 Message-ID: <20260319173752.1472864-4-longman@redhat.com> In-Reply-To: <20260319173752.1472864-1-longman@redhat.com> References: <20260319173752.1472864-1-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" The current test_memcontrol test fault in memory by write a value to the start of a page based on the default value of 4k page size. Micro-optimize it by using the actual system page size to do the iteration. Signed-off-by: Waiman Long Reviewed-by: Li Wang --- tools/testing/selftests/cgroup/test_memcontrol.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testi= ng/selftests/cgroup/test_memcontrol.c index a25eb097b31c..3cc8a432be91 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -25,6 +25,7 @@ =20 static bool has_localevents; static bool has_recursiveprot; +static int page_size; =20 int get_temp_fd(void) { @@ -60,7 +61,7 @@ int alloc_anon(const char *cgroup, void *arg) char *buf, *ptr; =20 buf =3D malloc(size); - for (ptr =3D buf; ptr < buf + size; ptr +=3D PAGE_SIZE) + for (ptr =3D buf; ptr < buf + size; ptr +=3D page_size) *ptr =3D 0; =20 free(buf); @@ -183,7 +184,7 @@ static int alloc_anon_50M_check(const char *cgroup, voi= d *arg) return -1; } =20 - for (ptr =3D buf; ptr < buf + size; ptr +=3D PAGE_SIZE) + for (ptr =3D buf; ptr < buf + size; ptr +=3D page_size) *ptr =3D 0; =20 current =3D cg_read_long(cgroup, "memory.current"); @@ -413,7 +414,7 @@ static int alloc_anon_noexit(const char *cgroup, void *= arg) return -1; } =20 - for (ptr =3D buf; ptr < buf + size; ptr +=3D PAGE_SIZE) + for (ptr =3D buf; ptr < buf + size; ptr +=3D page_size) *ptr =3D 0; =20 while (getppid() =3D=3D ppid) @@ -999,7 +1000,7 @@ static int alloc_anon_50M_check_swap(const char *cgrou= p, void *arg) return -1; } =20 - for (ptr =3D buf; ptr < buf + size; ptr +=3D PAGE_SIZE) + for (ptr =3D buf; ptr < buf + size; ptr +=3D page_size) *ptr =3D 0; =20 mem_current =3D cg_read_long(cgroup, "memory.current"); @@ -1679,6 +1680,7 @@ int main(int argc, char **argv) char root[PATH_MAX]; int i, proc_status; =20 + page_size =3D sysconf(_SC_PAGE_SIZE); ksft_print_header(); ksft_set_plan(ARRAY_SIZE(tests)); if (cg_find_unified_root(root, sizeof(root), NULL)) --=20 2.53.0