From nobody Sat Apr 4 00:07:09 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 838442BDC0E for ; Sun, 22 Mar 2026 06:11:07 +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=1774159869; cv=none; b=XMrXds/a6jxDe3LBDfZfrONHPO0vCuImlmBW1ZzKWYkpddIhvE0G7yeuhOXT7+j0ICgckNYUYVC16Ts44ZdCbC5s6V6NJQody+qy1uwjMK6dcF4En343jUKb/xD14+7QLiXwf3EAV0m/55EJ7/x9FPf8OiMYYEbVS7JMkNmqLpA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774159869; c=relaxed/simple; bh=bTtTmHzOaXBPfSb93wDC7JBVrSsV7C9Odj5YuC8P8WU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dOQa9xjdij0YAfkF6ul9lCq9/b1tAC6D+LkKGYtlqnTM87k+va7R+DHLgwxPFpZ5k8/c2Nw3daOw8gH2tQPfK1I64qGaT5DPN+MLq/xySIVb7wy0nIXEaYtXe6vwvb5NTPT36L+qwUTvIGgi0CNMOLrks4qiGqe/PeKyp/K8i6s= 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=VQyaVJMN; 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="VQyaVJMN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774159866; 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=vNGT0NUnZrlZkAGbpAJMOumDHRLMeHSt0H7KNvOLnUM=; b=VQyaVJMN9xFMKDgUiazFH4qYr07gaMGAqvt78uVz2t4Ejdk8BNtkJqeI5NMCLl7pLNoYbM bF6FXb770xvqDech8cx9fKID4TtEDBe/AVtZ4uKe9NeEYz1DYOL/+uoULwzrPErk/ldEfP iwolj+zOAYz3CO6VkkNK7iHaq/+V7f4= Received: from mx-prod-mc-06.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-190-FE9ADUPzNtOwM6-JUgdTbg-1; Sun, 22 Mar 2026 02:11:01 -0400 X-MC-Unique: FE9ADUPzNtOwM6-JUgdTbg-1 X-Mimecast-MFC-AGG-ID: FE9ADUPzNtOwM6-JUgdTbg_1774159859 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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8BAD61800365; Sun, 22 Mar 2026 06:10:58 +0000 (UTC) Received: from fedora-laptop-x1.redhat.com (unknown [10.72.112.34]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 223171955F2E; Sun, 22 Mar 2026 06:10:50 +0000 (UTC) From: Li Wang To: akpm@linux-foundation.org, yosry@kernel.org, yosryahmed@google.com, nphamcs@gmail.com, hannes@cmpxchg.org, mhocko@kernel.org, mkoutny@suse.com, muchun.song@linux.dev, tj@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev Cc: longman@redhat.com, liwang@redhat.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v4 1/7] selftests/cgroup: skip test_zswap if zswap is globally disabled Date: Sun, 22 Mar 2026 14:10:32 +0800 Message-ID: <20260322061038.156146-2-liwang@redhat.com> In-Reply-To: <20260322061038.156146-1-liwang@redhat.com> References: <20260322061038.156146-1-liwang@redhat.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="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 test_zswap currently only checks whether zswap is present by testing /sys/module/zswap. This misses the runtime global state exposed in /sys/module/zswap/parameters/enabled. When zswap is built/loaded but globally disabled, the zswap cgroup selftests run in an invalid environment and may fail spuriously. Check the runtime enabled state before running the tests: - skip if zswap is not configured, - fail if the enabled knob cannot be read, - skip if zswap is globally disabled. Also print a hint in the skip message on how to enable zswap. Signed-off-by: Li Wang Cc: Johannes Weiner Cc: Michal Hocko Cc: Michal Koutn=C3=BD Cc: Muchun Song Cc: Nhat Pham Cc: Tejun Heo Cc: Roman Gushchin Cc: Shakeel Butt Cc: Yosry Ahmed Acked-by: Yosry Ahmed Acked-by: Nhat Pham --- Notes: v4: - No changes. =20 v3: - Replace tri-state zswap_enabled() with check_zswap_enabled() for= clearer flow. - Move skip/fail decisions into the helper instead of branching in= main(). - Make read failure reporting more explicit by naming `/sys/module/zswap/parameters/enabled`. - Keep skip hint for enabling zswap: `echo 1 > /sys/module/zswap/parameters/enabled`. =20 v2: - remove enable/disable_zswap functions - skip the test if zswap is not enabled - reporting fail when zswap_enabled return -1 tools/testing/selftests/cgroup/test_zswap.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_zswap.c b/tools/testing/se= lftests/cgroup/test_zswap.c index 64ebc3f3f203..e69d845d3592 100644 --- a/tools/testing/selftests/cgroup/test_zswap.c +++ b/tools/testing/selftests/cgroup/test_zswap.c @@ -589,9 +589,21 @@ struct zswap_test { }; #undef T =20 -static bool zswap_configured(void) +static void check_zswap_enabled(void) { - return access("/sys/module/zswap", F_OK) =3D=3D 0; + char value[2]; + + if (access("/sys/module/zswap", F_OK)) + ksft_exit_skip("zswap isn't configured\n"); + + if (read_text("/sys/module/zswap/parameters/enabled", value, + sizeof(value)) <=3D 0) + ksft_exit_fail_msg("Failed to read " + "/sys/module/zswap/parameters/enabled\n"); + + if (value[0] =3D=3D 'N') + ksft_exit_skip("zswap is disabled (hint: echo 1 > " + "/sys/module/zswap/parameters/enabled)\n"); } =20 int main(int argc, char **argv) @@ -604,8 +616,7 @@ int main(int argc, char **argv) if (cg_find_unified_root(root, sizeof(root), NULL)) ksft_exit_skip("cgroup v2 isn't mounted\n"); =20 - if (!zswap_configured()) - ksft_exit_skip("zswap isn't configured\n"); + check_zswap_enabled(); =20 /* * Check that memory controller is available: --=20 2.53.0 From nobody Sat Apr 4 00:07:09 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 226D237187B for ; Sun, 22 Mar 2026 06:11:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774159871; cv=none; b=QRdEqr4lBzVGdWsAyFRvil47vU1bVNj1iijj4noJVlaETr9+Yq+NUDPdp/KijPC+IW5z2I8GFGHdqFYq1QLAqzvBHS7mAaiwB6N8XPqCbTDvRPb6zmWZvkzubQ69hBztaXmI2EuCkePYFApkuOaZtD5+3fm75BVLNyjzs0gNss0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774159871; c=relaxed/simple; bh=gCX1tknRC73NgxegM2bsYZ0u8r5goUAkekKjF0RFcf8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DxWsq9kmSLuoxtWNP6yfjNfJzqSbLmSGcDgh7+81JnLTIxz6tCzWrITiOdOqUTkXmm5Wub2MLA1G65nL+0XtXTWsviRZmgNAf8t3zm/J3ko2WgroA5L/TavqFzLwYsXZ5X5FO9bMWf15McvIoVabguRB9Jc7godVfoHG0z928+M= 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=W1CdV4FH; arc=none smtp.client-ip=170.10.129.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="W1CdV4FH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774159869; 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=UUxVZ5QRYGf3wyruBKfbexWqyo+rt+qp+DxvL12j5gc=; b=W1CdV4FHIb0teTdyNEBd2kSFhvsXVWOD196ERVVLfJtrPaJVqOpeMPaMfW+1y4gHy0edzh rV53e9b2/gjemml1DwqpCfM+pOHSz5JhJkmzE+iv4tZMtq8pav9K2kIzTmkhrR6uZz7qFY zV1TRwXk92TnNi4XFXGs8L9QkKE76uk= 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-491-Tto4YA5VOyiBhYcZzKet7w-1; Sun, 22 Mar 2026 02:11:07 -0400 X-MC-Unique: Tto4YA5VOyiBhYcZzKet7w-1 X-Mimecast-MFC-AGG-ID: Tto4YA5VOyiBhYcZzKet7w_1774159865 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 82DF1195608B; Sun, 22 Mar 2026 06:11:05 +0000 (UTC) Received: from fedora-laptop-x1.redhat.com (unknown [10.72.112.34]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 40AE31955F21; Sun, 22 Mar 2026 06:10:58 +0000 (UTC) From: Li Wang To: akpm@linux-foundation.org, yosry@kernel.org, yosryahmed@google.com, nphamcs@gmail.com, hannes@cmpxchg.org, mhocko@kernel.org, mkoutny@suse.com, muchun.song@linux.dev, tj@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev Cc: longman@redhat.com, liwang@redhat.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v4 2/7] selftests/cgroup: avoid OOM in test_swapin_nozswap Date: Sun, 22 Mar 2026 14:10:33 +0800 Message-ID: <20260322061038.156146-3-liwang@redhat.com> In-Reply-To: <20260322061038.156146-1-liwang@redhat.com> References: <20260322061038.156146-1-liwang@redhat.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="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 test_swapin_nozswap can hit OOM before reaching its assertions on some setups. The test currently sets memory.max=3D8M and then allocates/reads 32M with memory.zswap.max=3D0, which may over-constrain reclaim and kill the workload process. Replace hardcoded sizes with PAGE_SIZE-based values: - control_allocation_size =3D PAGE_SIZE * 512 - memory.max =3D control_allocation_size * 3 / 4 - minimum expected swap =3D control_allocation_size / 4 This keeps the test pressure model intact (allocate/read beyond memory.max = to force swap-in/out) while making it more robust across different environment= s. The test intent is unchanged: confirm that swapping occurs while zswap rema= ins unused when memory.zswap.max=3D0. =3D=3D=3D Error Logs =3D=3D=3D # ./test_zswap TAP version 13 1..7 ok 1 test_zswap_usage not ok 2 test_swapin_nozswap ... # dmesg [271641.879153] test_zswap invoked oom-killer: gfp_mask=3D0xcc0(GFP_KERNE= L), order=3D0, oom_score_adj=3D0 [271641.879168] CPU: 1 UID: 0 PID: 177372 Comm: test_zswap Kdump: loaded = Not tainted 6.12.0-211.el10.ppc64le #1 VOLUNTARY [271641.879171] Hardware name: IBM,9009-41A POWER9 (architected) 0x4e0202= 0xf000005 of:IBM,FW940.02 (UL940_041) hv:phyp pSeries [271641.879173] Call Trace: [271641.879174] [c00000037540f730] [c00000000127ec44] dump_stack_lvl+0x88= /0xc4 (unreliable) [271641.879184] [c00000037540f760] [c0000000005cc594] dump_header+0x5c/0x= 1e4 [271641.879188] [c00000037540f7e0] [c0000000005cb464] oom_kill_process+0x= 324/0x3b0 [271641.879192] [c00000037540f860] [c0000000005cbe48] out_of_memory+0x118= /0x420 [271641.879196] [c00000037540f8f0] [c00000000070d8ec] mem_cgroup_out_of_m= emory+0x18c/0x1b0 [271641.879200] [c00000037540f990] [c000000000713888] try_charge_memcg+0x= 598/0x890 [271641.879204] [c00000037540fa70] [c000000000713dbc] charge_memcg+0x5c/0= x110 [271641.879207] [c00000037540faa0] [c0000000007159f8] __mem_cgroup_charge= +0x48/0x120 [271641.879211] [c00000037540fae0] [c000000000641914] alloc_anon_folio+0x= 2b4/0x5a0 [271641.879215] [c00000037540fb60] [c000000000641d58] do_anonymous_page+0= x158/0x6b0 [271641.879218] [c00000037540fbd0] [c000000000642f8c] __handle_mm_fault+0= x4bc/0x910 [271641.879221] [c00000037540fcf0] [c000000000643500] handle_mm_fault+0x1= 20/0x3c0 [271641.879224] [c00000037540fd40] [c00000000014bba0] ___do_page_fault+0x= 1c0/0x980 [271641.879228] [c00000037540fdf0] [c00000000014c44c] hash__do_page_fault= +0x2c/0xc0 [271641.879232] [c00000037540fe20] [c0000000001565d8] do_hash_fault+0x128= /0x1d0 [271641.879236] [c00000037540fe50] [c000000000008be0] data_access_common_= virt+0x210/0x220 [271641.879548] Tasks state (memory values in pages): ... [271641.879550] [ pid ] uid tgid total_vm rss rss_anon rss_file= rss_shmem pgtables_bytes swapents oom_score_adj name [271641.879555] [ 177372] 0 177372 571 0 0 = 0 0 51200 96 0 test_zswap [271641.879562] oom-kill:constraint=3DCONSTRAINT_MEMCG,nodemask=3D(null),= cpuset=3D/,mems_allowed=3D0,oom_memcg=3D/no_zswap_test,task_memcg=3D/no_zsw= ap_test,task=3Dtest_zswap,pid=3D177372,uid=3D0 [271641.879578] Memory cgroup out of memory: Killed process 177372 (test_= zswap) total-vm:36544kB, anon-rss:0kB, file-rss:0kB, shmem-rss:0kB, UID:0 p= gtables:50kB oom_score_adj:0 Signed-off-by: Li Wang Cc: Johannes Weiner Cc: Michal Hocko Cc: Michal Koutn=C3=BD Cc: Muchun Song Cc: Nhat Pham Cc: Tejun Heo Cc: Roman Gushchin Cc: Shakeel Butt Acked-by: Yosry Ahmed --- Notes: v4: - print the expected swap amount in KB but not MB. v3: - Replace fixed 8M/32M sizing with PAGE_SIZE-based sizing in test_swapin_nozswap. - Set memory.max to 3/4 of workload size to reduce OOM risk while still forcing reclaim/swap activity. - Derive minimum swap expectation from workload size (1/4) instead of a fixed 8M threshold. v2: - No change. tools/testing/selftests/cgroup/test_zswap.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_zswap.c b/tools/testing/se= lftests/cgroup/test_zswap.c index e69d845d3592..4481db4bc0f6 100644 --- a/tools/testing/selftests/cgroup/test_zswap.c +++ b/tools/testing/selftests/cgroup/test_zswap.c @@ -160,21 +160,25 @@ static int test_zswap_usage(const char *root) static int test_swapin_nozswap(const char *root) { int ret =3D KSFT_FAIL; - char *test_group; - long swap_peak, zswpout; + char *test_group, mem_max_buf[32]; + long swap_peak, zswpout, min_swap; + size_t control_allocation_size =3D sysconf(_SC_PAGESIZE) * 512; + + min_swap =3D control_allocation_size / 4; + snprintf(mem_max_buf, sizeof(mem_max_buf), "%zu", control_allocation_size= * 3/4); =20 test_group =3D cg_name(root, "no_zswap_test"); if (!test_group) goto out; if (cg_create(test_group)) goto out; - if (cg_write(test_group, "memory.max", "8M")) + if (cg_write(test_group, "memory.max", mem_max_buf)) goto out; if (cg_write(test_group, "memory.zswap.max", "0")) goto out; =20 /* Allocate and read more than memory.max to trigger swapin */ - if (cg_run(test_group, allocate_and_read_bytes, (void *)MB(32))) + if (cg_run(test_group, allocate_and_read_bytes, (void *)control_allocatio= n_size)) goto out; =20 /* Verify that pages are swapped out, but no zswap happened */ @@ -184,8 +188,9 @@ static int test_swapin_nozswap(const char *root) goto out; } =20 - if (swap_peak < MB(24)) { - ksft_print_msg("at least 24MB of memory should be swapped out\n"); + if (swap_peak < min_swap) { + ksft_print_msg("at least %ldKB of memory should be swapped out\n", + min_swap / 1024); goto out; } =20 --=20 2.53.0 From nobody Sat Apr 4 00:07:09 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 DA27336C0CF for ; Sun, 22 Mar 2026 06:11:19 +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=1774159881; cv=none; b=ATTGe6hxbpQxtO47UwYjpgHEQ6XgaoIoceg+E6uyg1rLg4DmBSicx96a+ErV7SSYjxQfBXYeiwVa2mqKnwKxvmfAM/31VJwfC3MeceyCiZTeFiCzObbDIfuZjXsOgPdhIJU1ubSqtJrFv/96weykdarNxbePhQNR9g1epcOKsjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774159881; c=relaxed/simple; bh=I6wzHpWI1G2dHKnH1D2apcwr+taBmOI381SYbEpm3vY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EBw745QaT5hIyUIgxwADn6axqJOQLdf9vhoaQIxH1uEWsVV70Y/bu4Fjw6X+8/FH+XhdYTjzF0e8reGQupz1YkvpT1ido5Nd4Z964S1jV0qN08XV39hp+utl/Xt4XPkzRSe41qJH+EwXKm4JZ1e9vQLxY58ZvWWqAVXDNUY1WpY= 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=KbmLS2Xm; 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="KbmLS2Xm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774159879; 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=fSV+/tqM70wKgndqvLBa1N8bfrFGZwvNXk6Fa/4Lros=; b=KbmLS2Xmmt+ZLITe+5/zuEbDeAgw1o9eQGTZs+/NCTXtMB0HvcvjfA2SNFXss4ry5V3hFk 9lWPOfRO6ZFnFU4rXtKzEt4fgn3UzmxpINTYQRyXLt4j0YYy0mU5PdS93Ux9sWfXuGKiZh 43t6yCh1UhSlpNcM5RmPf/EQp/fQkxQ= 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-402-wBx07rGgPOyTWL5happl-Q-1; Sun, 22 Mar 2026 02:11:15 -0400 X-MC-Unique: wBx07rGgPOyTWL5happl-Q-1 X-Mimecast-MFC-AGG-ID: wBx07rGgPOyTWL5happl-Q_1774159873 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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F2FFB1800464; Sun, 22 Mar 2026 06:11:12 +0000 (UTC) Received: from fedora-laptop-x1.redhat.com (unknown [10.72.112.34]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3E2F91955F21; Sun, 22 Mar 2026 06:11:05 +0000 (UTC) From: Li Wang To: akpm@linux-foundation.org, yosry@kernel.org, yosryahmed@google.com, nphamcs@gmail.com, hannes@cmpxchg.org, mhocko@kernel.org, mkoutny@suse.com, muchun.song@linux.dev, tj@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev Cc: longman@redhat.com, liwang@redhat.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v4 3/7] selftests/cgroup: use runtime page size for zswpin check Date: Sun, 22 Mar 2026 14:10:34 +0800 Message-ID: <20260322061038.156146-4-liwang@redhat.com> In-Reply-To: <20260322061038.156146-1-liwang@redhat.com> References: <20260322061038.156146-1-liwang@redhat.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="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 test_zswapin compares memory.stat:zswpin (counted in pages) against a byte threshold converted with PAGE_SIZE. In cgroup selftests, PAGE_SIZE is hardcoded to 4096, which makes the conversion wrong on systems with non-4K base pages (e.g. 64K). As a result, the test requires too many pages to pass and fails spuriously even when zswap is working. Use sysconf(_SC_PAGESIZE) for the zswpin threshold conversion so the check matches the actual system page size. Signed-off-by: Li Wang Cc: Johannes Weiner Cc: Michal Hocko Cc: Michal Koutn=C3=BD Cc: Muchun Song Cc: Nhat Pham Cc: Tejun Heo Cc: Roman Gushchin Cc: Shakeel Butt Reviewed-by: Yosry Ahmed --- tools/testing/selftests/cgroup/test_zswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/cgroup/test_zswap.c b/tools/testing/se= lftests/cgroup/test_zswap.c index 4481db4bc0f6..4982e8c4759c 100644 --- a/tools/testing/selftests/cgroup/test_zswap.c +++ b/tools/testing/selftests/cgroup/test_zswap.c @@ -240,7 +240,7 @@ static int test_zswapin(const char *root) goto out; } =20 - if (zswpin < MB(24) / PAGE_SIZE) { + if (zswpin < MB(24) / sysconf(_SC_PAGESIZE)) { ksft_print_msg("at least 24MB should be brought back from zswap\n"); goto out; } --=20 2.53.0 From nobody Sat Apr 4 00:07:09 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 6621C361DA1 for ; Sun, 22 Mar 2026 06:11:28 +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=1774159889; cv=none; b=ZWy53t+dCxpRkWua54hENVSEa741N7mlOn8seirPNzwJ6mfkuOetiE3EoBtOD2ORw4Ulpb3mXO/bxDYo6ZYFJA2ndGH56TO5iDjdVf/YAA+Mm1jX9TC2dnae/5P5jzEwJTdi3GL0XvbG6MpVehzfjPJAY/aWprhacudevBC3eb4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774159889; c=relaxed/simple; bh=4JEq0xim6x1akSTc3YUYcMej5O5xD3wYlWtzBFff63E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OT3FB8vc5GReuUPQGQeNT7eKAQLifFh3R3lxo1Tl+Lw7bxBjApF0f2r/GiD5WQ9rb2ismqInKRxk3zNknpDCYfcz5duqy3w1zE6zUl+J2wgmNNZZp7I4tqMp1qyEV8ijp/AYOLa+7SV16hEP7jWVXdwKM/Ty+IkJ8hD6NzkmmOI= 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=IgNUbFg9; 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="IgNUbFg9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774159887; 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=BHzuD1Q+ozuE+fNEcVbskPPcDVZUs5YK4U0mB0xkA0M=; b=IgNUbFg97lVh9eZb/BOpDPAnGuGZwjR0HeUMLxFHhza/Cf5M+Gfej1c+D/epI4toosIs1K lJN/KBjIcepFhc14Xs50px7cq+tXMp50ee07uLG2f7Ohgck2G0Y8FdWMoxcW3Q4U8ijraM 5Tc0ifp3f3xL+lKvXstUQhcdtctWgpo= Received: from mx-prod-mc-05.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-550-CjW01H6BN4CvfivfR703GA-1; Sun, 22 Mar 2026 02:11:21 -0400 X-MC-Unique: CjW01H6BN4CvfivfR703GA-1 X-Mimecast-MFC-AGG-ID: CjW01H6BN4CvfivfR703GA_1774159880 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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9EB4A195608D; Sun, 22 Mar 2026 06:11:19 +0000 (UTC) Received: from fedora-laptop-x1.redhat.com (unknown [10.72.112.34]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 86C941955F21; Sun, 22 Mar 2026 06:11:13 +0000 (UTC) From: Li Wang To: akpm@linux-foundation.org, yosry@kernel.org, yosryahmed@google.com, nphamcs@gmail.com, hannes@cmpxchg.org, mhocko@kernel.org, mkoutny@suse.com, muchun.song@linux.dev, tj@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev Cc: longman@redhat.com, liwang@redhat.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v4 4/7] selftests/cgroup: rename PAGE_SIZE to BUF_SIZE in cgroup_util Date: Sun, 22 Mar 2026 14:10:35 +0800 Message-ID: <20260322061038.156146-5-liwang@redhat.com> In-Reply-To: <20260322061038.156146-1-liwang@redhat.com> References: <20260322061038.156146-1-liwang@redhat.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="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 The cgroup utility code defines a local PAGE_SIZE macro hardcoded to 4096, which is used solely as a generic buffer size for reading cgroup and proc files. This is misleading because the value has nothing to do with the actual page size of the system, and on architectures with larger pages (e.g., 64K on arm64 or ppc64) the name suggests a relationship that does not exist. Additionally, the name can shadow or conflict with the PAGE_SIZE definition from system headers, leading to confusion or subtle bugs. Rename it to BUF_SIZE to accurately reflect its purpose as a general I/O buffer size. No functional change. Signed-off-by: Li Wang Cc: Johannes Weiner Cc: Michal Hocko Cc: Michal Koutn=C3=BD Cc: Muchun Song Cc: Nhat Pham Cc: Tejun Heo Cc: Roman Gushchin Cc: Shakeel Butt Cc: Yosry Ahmed --- Notes: v4: - Use page_size instead of BUF_SIZE in test_memcontrol.c =20 v3, v2, v1: - No changes. .../testing/selftests/cgroup/lib/cgroup_util.c | 18 +++++++++--------- .../selftests/cgroup/lib/include/cgroup_util.h | 4 ++-- tools/testing/selftests/cgroup/test_core.c | 2 +- tools/testing/selftests/cgroup/test_freezer.c | 2 +- .../testing/selftests/cgroup/test_memcontrol.c | 15 ++++++++------- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/cgroup/lib/cgroup_util.c b/tools/testi= ng/selftests/cgroup/lib/cgroup_util.c index ce6c2642fd9b..0be525ed11db 100644 --- a/tools/testing/selftests/cgroup/lib/cgroup_util.c +++ b/tools/testing/selftests/cgroup/lib/cgroup_util.c @@ -125,7 +125,7 @@ int cg_read_strcmp(const char *cgroup, const char *cont= rol, =20 int cg_read_strstr(const char *cgroup, const char *control, const char *ne= edle) { - char buf[PAGE_SIZE]; + char buf[BUF_SIZE]; =20 if (cg_read(cgroup, control, buf, sizeof(buf))) return -1; @@ -155,7 +155,7 @@ long cg_read_long_fd(int fd) =20 long cg_read_key_long(const char *cgroup, const char *control, const char = *key) { - char buf[PAGE_SIZE]; + char buf[BUF_SIZE]; char *ptr; =20 if (cg_read(cgroup, control, buf, sizeof(buf))) @@ -191,7 +191,7 @@ long cg_read_key_long_poll(const char *cgroup, const ch= ar *control, =20 long cg_read_lc(const char *cgroup, const char *control) { - char buf[PAGE_SIZE]; + char buf[BUF_SIZE]; const char delim[] =3D "\n"; char *line; long cnt =3D 0; @@ -243,7 +243,7 @@ int cg_write_numeric(const char *cgroup, const char *co= ntrol, long value) static int cg_find_root(char *root, size_t len, const char *controller, bool *nsdelegate) { - char buf[10 * PAGE_SIZE]; + char buf[10 * BUF_SIZE]; char *fs, *mount, *type, *options; const char delim[] =3D "\n\t "; =20 @@ -298,7 +298,7 @@ int cg_create(const char *cgroup) =20 int cg_wait_for_proc_count(const char *cgroup, int count) { - char buf[10 * PAGE_SIZE] =3D {0}; + char buf[10 * BUF_SIZE] =3D {0}; int attempts; char *ptr; =20 @@ -323,7 +323,7 @@ int cg_wait_for_proc_count(const char *cgroup, int coun= t) =20 int cg_killall(const char *cgroup) { - char buf[PAGE_SIZE]; + char buf[BUF_SIZE]; char *ptr =3D buf; =20 /* If cgroup.kill exists use it. */ @@ -533,7 +533,7 @@ int cg_run_nowait(const char *cgroup, =20 int proc_mount_contains(const char *option) { - char buf[4 * PAGE_SIZE]; + char buf[4 * BUF_SIZE]; ssize_t read; =20 read =3D read_text("/proc/mounts", buf, sizeof(buf)); @@ -545,7 +545,7 @@ int proc_mount_contains(const char *option) =20 int cgroup_feature(const char *feature) { - char buf[PAGE_SIZE]; + char buf[BUF_SIZE]; ssize_t read; =20 read =3D read_text("/sys/kernel/cgroup/features", buf, sizeof(buf)); @@ -572,7 +572,7 @@ ssize_t proc_read_text(int pid, bool thread, const char= *item, char *buf, size_t =20 int proc_read_strstr(int pid, bool thread, const char *item, const char *n= eedle) { - char buf[PAGE_SIZE]; + char buf[BUF_SIZE]; =20 if (proc_read_text(pid, thread, item, buf, sizeof(buf)) < 0) return -1; diff --git a/tools/testing/selftests/cgroup/lib/include/cgroup_util.h b/too= ls/testing/selftests/cgroup/lib/include/cgroup_util.h index 77f386dab5e8..ca4a161c17a4 100644 --- a/tools/testing/selftests/cgroup/lib/include/cgroup_util.h +++ b/tools/testing/selftests/cgroup/lib/include/cgroup_util.h @@ -2,8 +2,8 @@ #include #include =20 -#ifndef PAGE_SIZE -#define PAGE_SIZE 4096 +#ifndef BUF_SIZE +#define BUF_SIZE 4096 #endif =20 #define MB(x) (x << 20) diff --git a/tools/testing/selftests/cgroup/test_core.c b/tools/testing/sel= ftests/cgroup/test_core.c index 102262555a59..df7fac7e5554 100644 --- a/tools/testing/selftests/cgroup/test_core.c +++ b/tools/testing/selftests/cgroup/test_core.c @@ -87,7 +87,7 @@ static int test_cgcore_destroy(const char *root) int ret =3D KSFT_FAIL; char *cg_test =3D NULL; int child_pid; - char buf[PAGE_SIZE]; + char buf[BUF_SIZE]; =20 cg_test =3D cg_name(root, "cg_test"); =20 diff --git a/tools/testing/selftests/cgroup/test_freezer.c b/tools/testing/= selftests/cgroup/test_freezer.c index 97fae92c8387..160a9e6ad277 100644 --- a/tools/testing/selftests/cgroup/test_freezer.c +++ b/tools/testing/selftests/cgroup/test_freezer.c @@ -642,7 +642,7 @@ static int test_cgfreezer_ptrace(const char *root) */ static int proc_check_stopped(int pid) { - char buf[PAGE_SIZE]; + char buf[BUF_SIZE]; int len; =20 len =3D proc_read_text(pid, 0, "stat", buf, sizeof(buf)); diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testi= ng/selftests/cgroup/test_memcontrol.c index 2fb096a2a9f9..2a8d887a849f 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -33,7 +33,7 @@ int get_temp_fd(void) =20 int alloc_pagecache(int fd, size_t size) { - char buf[PAGE_SIZE]; + char buf[BUF_SIZE]; struct stat st; int i; =20 @@ -57,10 +57,11 @@ int alloc_pagecache(int fd, size_t size) int alloc_anon(const char *cgroup, void *arg) { size_t size =3D (unsigned long)arg; + size_t page_size =3D sysconf(_SC_PAGESIZE); 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); @@ -69,7 +70,7 @@ int alloc_anon(const char *cgroup, void *arg) =20 int is_swap_enabled(void) { - char buf[PAGE_SIZE]; + char buf[BUF_SIZE]; const char delim[] =3D "\n"; int cnt =3D 0; char *line; @@ -112,7 +113,7 @@ static int test_memcg_subtree_control(const char *root) { char *parent, *child, *parent2 =3D NULL, *child2 =3D NULL; int ret =3D KSFT_FAIL; - char buf[PAGE_SIZE]; + char buf[BUF_SIZE]; =20 /* Create two nested cgroups with the memory controller enabled */ parent =3D cg_name(root, "memcg_test_0"); @@ -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 BUF_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 BUF_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 BUF_SIZE) *ptr =3D 0; =20 mem_current =3D cg_read_long(cgroup, "memory.current"); --=20 2.53.0 From nobody Sat Apr 4 00:07:09 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 1193E36C0CF for ; Sun, 22 Mar 2026 06:11:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774159896; cv=none; b=DU3XNlxKlytPKXAwGO/xgqaU//J/jOxLQVSHZ2SMM8p75yCAzPePD4cB9kuQFUcic9Vh5OX+AsRFYX2snsunsLz0q/9mKsyPtNJkx64iiSak6OpADxctW+srfU9FGnHLlRmKV+sXjaG099IDNzklvpvoHk7pLhlDJYCGEyLkVhg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774159896; c=relaxed/simple; bh=/5SJMslpwqE9AZtD6jAcInepSkwSg68CiVm9j3igxho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UpTLCmiSAxTKz+5a32ZPx5UEWNidMr7cA3owdQWIV8FcAXb8oxY12lfWxCrpx/V3U5P6wOf5jijmFtGquQYpizeh7nSnP42GEcDOhmZ2g2mjNAFMDpFsxS7UgEEp3uuQrvy5xR+sb9CuS9qNyogw1ARSd+8uE4YMR2O99YC/BM8= 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=Ny3dtbRV; arc=none smtp.client-ip=170.10.129.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="Ny3dtbRV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774159893; 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=7dCjpbk9shfMvsTLeYWdQuK6o2QNz7TDr6M6Z2XEj8E=; b=Ny3dtbRVfSBNN7h4nOF6XgVUxsf8may+vP/MnSxWnAccDhGlFtJjrjgJ4d2jLckp6Xhqlj VwXAsdKIYdWU8RwIsIcIoqUGjXChvyNUtppPNF4HXtsachUoUV8EbQmAEezETMv/K+9LZv Pd5yGi7Sebalu80aRqspGR2/jTdM94Q= 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-507-U2Bm-i80O8m2tIqlio_K8Q-1; Sun, 22 Mar 2026 02:11:28 -0400 X-MC-Unique: U2Bm-i80O8m2tIqlio_K8Q-1 X-Mimecast-MFC-AGG-ID: U2Bm-i80O8m2tIqlio_K8Q_1774159886 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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7694E1800345; Sun, 22 Mar 2026 06:11:26 +0000 (UTC) Received: from fedora-laptop-x1.redhat.com (unknown [10.72.112.34]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4B19C1955F21; Sun, 22 Mar 2026 06:11:19 +0000 (UTC) From: Li Wang To: akpm@linux-foundation.org, yosry@kernel.org, yosryahmed@google.com, nphamcs@gmail.com, hannes@cmpxchg.org, mhocko@kernel.org, mkoutny@suse.com, muchun.song@linux.dev, tj@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev Cc: longman@redhat.com, liwang@redhat.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v4 5/7] selftests/cgroup: replace hardcoded page size values in test_zswap Date: Sun, 22 Mar 2026 14:10:36 +0800 Message-ID: <20260322061038.156146-6-liwang@redhat.com> In-Reply-To: <20260322061038.156146-1-liwang@redhat.com> References: <20260322061038.156146-1-liwang@redhat.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="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 test_zswap uses hardcoded values of 4095 and 4096 throughout as page stride and page size, which are only correct on systems with a 4K page size. On architectures with larger pages (e.g., 64K on arm64 or ppc64), these constants cause memory to be touched at sub-page granularity, leading to inefficient access patterns and incorrect page count calculations, which can cause test failures. Replace all hardcoded 4095 and 4096 values with a global pagesize variable initialized from sysconf(_SC_PAGESIZE) at startup, and remove the redundant local sysconf() calls scattered across individual functions. No functional change on 4K page size systems. Signed-off-by: Li Wang Cc: Johannes Weiner Cc: Michal Hocko Cc: Michal Koutn=C3=BD Cc: Muchun Song Cc: Nhat Pham Cc: Tejun Heo Cc: Roman Gushchin Cc: Shakeel Butt Cc: Yosry Ahmed Acked-by: Yosry Ahmed --- tools/testing/selftests/cgroup/test_zswap.c | 22 +++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_zswap.c b/tools/testing/se= lftests/cgroup/test_zswap.c index 4982e8c4759c..407cfb6ae34d 100644 --- a/tools/testing/selftests/cgroup/test_zswap.c +++ b/tools/testing/selftests/cgroup/test_zswap.c @@ -13,6 +13,8 @@ #include "kselftest.h" #include "cgroup_util.h" =20 +static size_t pagesize; + static int read_int(const char *path, size_t *value) { FILE *file; @@ -68,11 +70,11 @@ static int allocate_and_read_bytes(const char *cgroup, = void *arg) =20 if (!mem) return -1; - for (int i =3D 0; i < size; i +=3D 4095) + for (int i =3D 0; i < size; i +=3D pagesize) mem[i] =3D 'a'; =20 /* Go through the allocated memory to (z)swap in and out pages */ - for (int i =3D 0; i < size; i +=3D 4095) { + for (int i =3D 0; i < size; i +=3D pagesize) { if (mem[i] !=3D 'a') ret =3D -1; } @@ -88,7 +90,7 @@ static int allocate_bytes(const char *cgroup, void *arg) =20 if (!mem) return -1; - for (int i =3D 0; i < size; i +=3D 4095) + for (int i =3D 0; i < size; i +=3D pagesize) mem[i] =3D 'a'; free(mem); return 0; @@ -267,7 +269,6 @@ static int test_zswapin(const char *root) */ static int attempt_writeback(const char *cgroup, void *arg) { - long pagesize =3D sysconf(_SC_PAGESIZE); size_t memsize =3D MB(4); char buf[pagesize]; long zswap_usage; @@ -436,7 +437,7 @@ static int test_no_invasive_cgroup_shrink(const char *r= oot) if (cg_enter_current(control_group)) goto out; control_allocation =3D malloc(control_allocation_size); - for (int i =3D 0; i < control_allocation_size; i +=3D 4095) + for (int i =3D 0; i < control_allocation_size; i +=3D pagesize) control_allocation[i] =3D 'a'; if (cg_read_key_long(control_group, "memory.stat", "zswapped") < 1) goto out; @@ -476,7 +477,7 @@ static int no_kmem_bypass_child(const char *cgroup, voi= d *arg) values->child_allocated =3D true; return -1; } - for (long i =3D 0; i < values->target_alloc_bytes; i +=3D 4095) + for (long i =3D 0; i < values->target_alloc_bytes; i +=3D pagesize) ((char *)allocation)[i] =3D 'a'; values->child_allocated =3D true; pause(); @@ -524,7 +525,7 @@ static int test_no_kmem_bypass(const char *root) min_free_kb_low =3D sys_info.totalram / 500000; values->target_alloc_bytes =3D (sys_info.totalram - min_free_kb_high * 10= 00) + sys_info.totalram * 5 / 100; - stored_pages_threshold =3D sys_info.totalram / 5 / 4096; + stored_pages_threshold =3D sys_info.totalram / 5 / pagesize; trigger_allocation_size =3D sys_info.totalram / 20; =20 /* Set up test memcg */ @@ -551,7 +552,7 @@ static int test_no_kmem_bypass(const char *root) =20 if (!trigger_allocation) break; - for (int i =3D 0; i < trigger_allocation_size; i +=3D 4095) + for (int i =3D 0; i < trigger_allocation_size; i +=3D pagesize) trigger_allocation[i] =3D 'b'; usleep(100000); free(trigger_allocation); @@ -562,8 +563,8 @@ static int test_no_kmem_bypass(const char *root) /* If memory was pushed to zswap, verify it belongs to memcg */ if (stored_pages > stored_pages_threshold) { int zswapped =3D cg_read_key_long(test_group, "memory.stat", "zswapped = "); - int delta =3D stored_pages * 4096 - zswapped; - int result_ok =3D delta < stored_pages * 4096 / 4; + int delta =3D stored_pages * pagesize - zswapped; + int result_ok =3D delta < stored_pages * pagesize / 4; =20 ret =3D result_ok ? KSFT_PASS : KSFT_FAIL; break; @@ -616,6 +617,7 @@ int main(int argc, char **argv) char root[PATH_MAX]; int i; =20 + pagesize =3D sysconf(_SC_PAGESIZE); ksft_print_header(); ksft_set_plan(ARRAY_SIZE(tests)); if (cg_find_unified_root(root, sizeof(root), NULL)) --=20 2.53.0 From nobody Sat Apr 4 00:07:09 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 CC9B033F5A2 for ; Sun, 22 Mar 2026 06:11:41 +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=1774159903; cv=none; b=qqexbbruGYNAzFYeQ+33tffI1tO4QVUJ/FLmUJar67llgraDQoTzlvJHhonhMsJqT5kqCX5Wq0sOwaK9VWc+oitzdXlLT+P3floGUx2CZQS9dcbBkgrvbmZxsC0wjazs/vgbwx0JQnfI5cgxloba9G20owcI0OrYNEydA7QujYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774159903; c=relaxed/simple; bh=LJ+zVwF30JYUzhOjxEZNUG57T+Cxg8IS889U6CiR7BU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NhIEE+wUNZA65kxHSWeWdZTCAe9xOHANxmnaAjGnkEJ7sbjxvFXBKb6T8kAPJ0J248t1Z6LnhF8M0Z5iAEESVDqjGnBIv4suE0V6i03yu3EVkYqx+70TXUGgf60zRy6FrNnT35Dw7LzuXWwf9X+0EHXpaObgzrNJsqM7OLOXsa8= 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=CXLkjVr/; 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="CXLkjVr/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774159900; 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=SrL2AX+ceqx9sNAAroe9dHxRWyg67vSJ191ORAP+K8A=; b=CXLkjVr/YmPwDltMJTkkDmHYd0Ks2LTbj8AfKmBCePKL50RZqeUtJdLaAghlZlWvDUt5vo 0owdJWKSD2JfMmHlr082HH2RlAbbL+l+HoZWdTSaQS0LZrM9M5s1ww/KU8GjQpz5eIj6Jr 24E+mS3X3BcCEl1861l5bhbkFjd9vPc= Received: from mx-prod-mc-05.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-572-9gLZOP22NOy9Wgnz9yPBWw-1; Sun, 22 Mar 2026 02:11:35 -0400 X-MC-Unique: 9gLZOP22NOy9Wgnz9yPBWw-1 X-Mimecast-MFC-AGG-ID: 9gLZOP22NOy9Wgnz9yPBWw_1774159893 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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6401E195608A; Sun, 22 Mar 2026 06:11:33 +0000 (UTC) Received: from fedora-laptop-x1.redhat.com (unknown [10.72.112.34]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1EB9F1955F21; Sun, 22 Mar 2026 06:11:26 +0000 (UTC) From: Li Wang To: akpm@linux-foundation.org, yosry@kernel.org, yosryahmed@google.com, nphamcs@gmail.com, hannes@cmpxchg.org, mhocko@kernel.org, mkoutny@suse.com, muchun.song@linux.dev, tj@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev Cc: longman@redhat.com, liwang@redhat.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v4 6/7] selftest/cgroup: fix zswap test_no_invasive_cgroup_shrink on large pagesize system Date: Sun, 22 Mar 2026 14:10:37 +0800 Message-ID: <20260322061038.156146-7-liwang@redhat.com> In-Reply-To: <20260322061038.156146-1-liwang@redhat.com> References: <20260322061038.156146-1-liwang@redhat.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="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 test_no_invasive_cgroup_shrink uses fixed zswap/memory limits and allocation sizes that are too small on systems with large PAGE_SIZE (e.g. 64K). In that case, the test may fail to build enough pressure to trigger zswap writeback reliably, leading to false failures. Make the test size parameters PAGE_SIZE-aware and consistent: - set control_allocation_size to PAGE_SIZE * 1024, - set memory.zswap.max to PAGE_SIZE, - set memory.max of both cgroups to control_allocation_size / 2, - allocate control_allocation_size in wb_group (2x memory.max). This keeps the test behavior stable across 4K and 64K PAGE_SIZE configurations and avoids spurious failures in test_no_invasive_cgroup_shrink. =3D=3D=3D Error Log =3D=3D=3D # getconf PAGESIZE 65536 # ./test_zswap TAP version 13 ... ok 5 test_zswap_writeback_disabled ok 6 # SKIP test_no_kmem_bypass not ok 7 test_no_invasive_cgroup_shrink Signed-off-by: Li Wang Cc: Johannes Weiner Cc: Michal Hocko Cc: Michal Koutn=C3=BD Cc: Muchun Song Cc: Nhat Pham Cc: Tejun Heo Cc: Roman Gushchin Cc: Shakeel Butt Cc: Yosry Ahmed --- Notes: v4: - Use use %zu in print pagesize format. v3: - Make PAGE_SIZE aware instead of using fixed sizing. - Set memory.max for wb_group/control_group to control_allocation_siz= e/2. - Update wb_group pressure allocation to control_allocation_size. - Clarify commit message to focus on this test's sizing issue. v2: - No change. tools/testing/selftests/cgroup/test_zswap.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_zswap.c b/tools/testing/se= lftests/cgroup/test_zswap.c index 407cfb6ae34d..ec7f0bd515e1 100644 --- a/tools/testing/selftests/cgroup/test_zswap.c +++ b/tools/testing/selftests/cgroup/test_zswap.c @@ -421,17 +421,26 @@ static int test_zswap_writeback_disabled(const char *= root) static int test_no_invasive_cgroup_shrink(const char *root) { int ret =3D KSFT_FAIL; - size_t control_allocation_size =3D MB(10); + size_t control_allocation_size =3D pagesize * 1024; + char zswap_max_buf[32], mem_max_buf[32]; char *control_allocation =3D NULL, *wb_group =3D NULL, *control_group =3D= NULL; =20 + snprintf(zswap_max_buf, sizeof(zswap_max_buf), "%zu", pagesize); + snprintf(mem_max_buf, sizeof(mem_max_buf), "%zu", control_allocation_size= / 2); + wb_group =3D setup_test_group_1M(root, "per_memcg_wb_test1"); if (!wb_group) return KSFT_FAIL; - if (cg_write(wb_group, "memory.zswap.max", "10K")) + if (cg_write(wb_group, "memory.zswap.max", zswap_max_buf)) + goto out; + if (cg_write(wb_group, "memory.max", mem_max_buf)) goto out; + control_group =3D setup_test_group_1M(root, "per_memcg_wb_test2"); if (!control_group) goto out; + if (cg_write(control_group, "memory.max", mem_max_buf)) + goto out; =20 /* Push some test_group2 memory into zswap */ if (cg_enter_current(control_group)) @@ -442,8 +451,8 @@ static int test_no_invasive_cgroup_shrink(const char *r= oot) if (cg_read_key_long(control_group, "memory.stat", "zswapped") < 1) goto out; =20 - /* Allocate 10x memory.max to push wb_group memory into zswap and trigger= wb */ - if (cg_run(wb_group, allocate_bytes, (void *)MB(10))) + /* Allocate 2x memory.max to push wb_group memory into zswap and trigger = wb */ + if (cg_run(wb_group, allocate_bytes, (void *)control_allocation_size)) goto out; =20 /* Verify that only zswapped memory from gwb_group has been written back = */ --=20 2.53.0 From nobody Sat Apr 4 00:07:09 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 D610736C0CF for ; Sun, 22 Mar 2026 06:11:49 +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=1774159911; cv=none; b=OAB61Sv8/YcLsFfM0SblWakuP3IgtuVXgY2Du2AEpt9Sz4MfedYy/5Dqy/f48LWjKHKRQgGDm5azxC/IDYnX34jMm2lYYf3mSO+XStVIEiAf28mZeGYe0y21mqZSPeaU8kRF2C4t6kWpnqeFXA1tTBrNiYt+qVbAPF+TvZFCX18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774159911; c=relaxed/simple; bh=fBwQcNCGckBbW5StnisPOyP/m96IC/Xzo0HrgVS5BoU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mQYChhfeIVdOm0ybTKEdYvgCKDjrRyoUhEzQS+bwDyC6K+mpZJ9rVbnFDbqG9c2LW5yWnObpa/9wnx2fxRsMXi08NGVl8hnCkcB/Ha1J10q4b63n0JbICK0AFmBBa7QuVUh1K7sgCn+3AHL+QnCDCXaP2XXJFiyQ8FLVh6vIfps= 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=U2hBDHk9; 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="U2hBDHk9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774159908; 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=lu5jwEEecEkDiX7ux2A/sS85AyKDVmY0PIrDjssqoFY=; b=U2hBDHk9OqCRi1Cuyb4WEwCxuRbJyRk4TovFJwtBzwd9AIBMSc4MFRbiFqLDKfFrTfB5hM H08sIFI48jKHtzovad3gTjFD1qwVRNVWDNf0CSRS3nxhfOObEqwL7ax5kBS+A2sSa5jZEx cyIX9Hy6SRJ++PW66JL6ArJum6M90VM= 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-524-CPQcHYE-NIm0Lz_NxNd6ow-1; Sun, 22 Mar 2026 02:11:42 -0400 X-MC-Unique: CPQcHYE-NIm0Lz_NxNd6ow-1 X-Mimecast-MFC-AGG-ID: CPQcHYE-NIm0Lz_NxNd6ow_1774159900 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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 55590180044D; Sun, 22 Mar 2026 06:11:40 +0000 (UTC) Received: from fedora-laptop-x1.redhat.com (unknown [10.72.112.34]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 10C271955F21; Sun, 22 Mar 2026 06:11:33 +0000 (UTC) From: Li Wang To: akpm@linux-foundation.org, yosry@kernel.org, yosryahmed@google.com, nphamcs@gmail.com, hannes@cmpxchg.org, mhocko@kernel.org, mkoutny@suse.com, muchun.song@linux.dev, tj@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev Cc: longman@redhat.com, liwang@redhat.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v4 7/7] selftest/cgroup: fix zswap attempt_writeback() on 64K pagesize system Date: Sun, 22 Mar 2026 14:10:38 +0800 Message-ID: <20260322061038.156146-8-liwang@redhat.com> In-Reply-To: <20260322061038.156146-1-liwang@redhat.com> References: <20260322061038.156146-1-liwang@redhat.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="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 In attempt_writeback(), a memsize of 4M only covers 64 pages on 64K page size systems. When memory.reclaim is called, the kernel prefers reclaiming clean file pages (binary, libc, linker, etc.) over swapping anonymous pages. With only 64 pages of anonymous memory, the reclaim target can be largely or entirely satisfied by dropping file pages, resulting in very few or zero anonymous pages being pushed into zswap. This causes zswap_usage to be extremely small or zero, making zswap_usage/2 insufficient to create meaningful writeback pressure. The test then fails because no writeback is triggered. On 4K page size systems this is not an issue because 4M covers 1024 pages, and file pages are a small fraction of the reclaim target. Fix this by always allocating 1024 pages regardless of page size. This ensures enough anonymous pages to reliably populate zswap and trigger writeback, while keeping the original 4M allocation on 4K page size systems. =3D=3D=3D Error Log =3D=3D=3D # uname -rm 6.12.0-211.el10.ppc64le ppc64le # getconf PAGESIZE 65536 # ./test_zswap TAP version 13 1..7 ok 1 test_zswap_usage ok 2 test_swapin_nozswap ok 3 test_zswapin not ok 4 test_zswap_writeback_enabled ... Signed-off-by: Li Wang Cc: Johannes Weiner Cc: Michal Hocko Cc: Michal Koutn=C3=BD Cc: Muchun Song Cc: Nhat Pham Cc: Tejun Heo Cc: Roman Gushchin Cc: Shakeel Butt Acked-by: Yosry Ahmed --- Notes: v4, v3: - No changes. v2: - use pagesize * 1024 which clearly shows the page numbers. tools/testing/selftests/cgroup/test_zswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/cgroup/test_zswap.c b/tools/testing/se= lftests/cgroup/test_zswap.c index ec7f0bd515e1..107b20db2fec 100644 --- a/tools/testing/selftests/cgroup/test_zswap.c +++ b/tools/testing/selftests/cgroup/test_zswap.c @@ -269,7 +269,7 @@ static int test_zswapin(const char *root) */ static int attempt_writeback(const char *cgroup, void *arg) { - size_t memsize =3D MB(4); + size_t memsize =3D pagesize * 1024; char buf[pagesize]; long zswap_usage; bool wb_enabled =3D *(bool *) arg; --=20 2.53.0