From nobody Fri Apr 3 01:22:52 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 B13F6273D6D for ; Thu, 2 Apr 2026 06:37:43 +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=1775111866; cv=none; b=LO5f9D36CSL6C5yXaea2VMtqsiDE3VUeog4wPoMyvKmleeYeG+/sMYaG8XAS+nJmF36uL8ewXuMbnsPbDsgvp+gXA0mDqvz/GI3f8UWop1KfroZNJIKJx+Tm+0Qj3M2r+OEXizlMjtCHyR1QmkURIAcHI3r40RMVHaPeqqm8gZg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775111866; c=relaxed/simple; bh=Y7cvX4iItstxup7jbTx3F/baoeYVtifB8nzEha9pwSg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sDOLKEAYLa8xCzVPZYLszL4AzkTxX9bvdr5YXbN8ClgP8xBt7HuSefNYGCbyIP7QzMmn9GEt0z71lDaSsm+CCbLdWSv3xhL6ExYZNwbQeX6EsJO465N65G7VHPAvtL/g+vAzTL3nnvwppo1wWvX/iuky2EEUGq5L4Va+6fGI4+s= 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=UsnOcBPx; 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="UsnOcBPx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775111862; 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=dW2A0MrwEuJvXNSWOJou7ZrIoh0fBOElxwXftetMLVw=; b=UsnOcBPxGhGPPz/FsfVWtJZhBW0vsRQoR5gfb5iK1L2soTnC7VOUaXemUPwKZnZz4YEw5C 5kYZ1cnLX5EzY14zRjvXMumh9PNPNbWbcvczsdFAxTUJlLLk2nYYQDiCCMjzhmBzoQk4GB su1LxbtQaqZQIIoLXPtwmS2KqHkw3+s= 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-607-Pb50ZLBTOwqFvnA_DynilQ-1; Thu, 02 Apr 2026 02:37:39 -0400 X-MC-Unique: Pb50ZLBTOwqFvnA_DynilQ-1 X-Mimecast-MFC-AGG-ID: Pb50ZLBTOwqFvnA_DynilQ_1775111856 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 3A36319560A7; Thu, 2 Apr 2026 06:37:36 +0000 (UTC) Received: from fedora-laptop-x1.redhat.com (unknown [10.72.112.158]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F0E091800351; Thu, 2 Apr 2026 06:37:26 +0000 (UTC) From: Li Wang To: akpm@linux-foundation.org, rppt@kernel.org, david@kernel.org, hannes@cmpxchg.org, yosry@kernel.org, ljs@kernel.org, Liam.Howlett@oracle.com, mhocko@suse.com, shuah@kernel.org, chengming.zhou@linux.dev, longman@redhat.com, nphamcs@gmail.com Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Michal Hocko , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Muchun Song , Tejun Heo , Roman Gushchin , Shakeel Butt , Yosry Ahmed Subject: [PATCH v6 1/8] selftests/cgroup: skip test_zswap if zswap is globally disabled Date: Thu, 2 Apr 2026 14:37:07 +0800 Message-ID: <20260402063714.55124-2-liwang@redhat.com> In-Reply-To: <20260402063714.55124-1-liwang@redhat.com> References: <20260402063714.55124-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.4.1 on 10.30.177.111 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: v5: - Defined PATH_ZSWAP and PATH_ZSWAP_ENABLED macros to avoid line b= reaks 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..44fa81ef6157 100644 --- a/tools/testing/selftests/cgroup/test_zswap.c +++ b/tools/testing/selftests/cgroup/test_zswap.c @@ -13,6 +13,9 @@ #include "kselftest.h" #include "cgroup_util.h" =20 +#define PATH_ZSWAP "/sys/module/zswap" +#define PATH_ZSWAP_ENABLED "/sys/module/zswap/parameters/enabled" + static int read_int(const char *path, size_t *value) { FILE *file; @@ -589,9 +592,18 @@ 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(PATH_ZSWAP, F_OK)) + ksft_exit_skip("zswap isn't configured\n"); + + if (read_text(PATH_ZSWAP_ENABLED, value, sizeof(value)) <=3D 0) + ksft_exit_fail_msg("Failed to read " PATH_ZSWAP_ENABLED "\n"); + + if (value[0] =3D=3D 'N') + ksft_exit_skip("zswap is disabled (hint: echo 1 > " PATH_ZSWAP_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