linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yang Xu <xuyang2018.jy@fujitsu.com>
To: <linux-kselftest@vger.kernel.org>, <skhan@linuxfoundation.org>
Cc: <linux-kernel@vger.kernel.org>, <naresh.kamboju@linaro.org>,
	<pvorel@suse.cz>, Yang Xu <xuyang2018.jy@fujitsu.com>
Subject: [PATCH v2 1/3] selftests/zram: Skip max_comp_streams interface on newer kernel
Date: Thu, 27 Jan 2022 17:11:35 +0800	[thread overview]
Message-ID: <1643274697-3393-1-git-send-email-xuyang2018.jy@fujitsu.com> (raw)
In-Reply-To: <590c1f1c-2da1-583a-d055-83c15969cf80@linuxfoundation.org>

Since commit 43209ea2d17a ("zram: remove max_comp_streams internals"), zram
has switched to per-cpu streams. Even kernel still keep this interface for
some reasons, but writing to max_comp_stream doesn't take any effect. So
skip it on newer kernel ie 4.7.

The code that comparing kernel version is from xfstests testsuite ext4/053.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 tools/testing/selftests/zram/zram_lib.sh | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tools/testing/selftests/zram/zram_lib.sh b/tools/testing/selftests/zram/zram_lib.sh
index 6f872f266fd1..f47fc0f27e99 100755
--- a/tools/testing/selftests/zram/zram_lib.sh
+++ b/tools/testing/selftests/zram/zram_lib.sh
@@ -11,6 +11,9 @@ dev_mounted=-1
 
 # Kselftest framework requirement - SKIP code is 4.
 ksft_skip=4
+kernel_version=`uname -r | cut -d'.' -f1,2`
+kernel_major=${kernel_version%.*}
+kernel_minor=${kernel_version#*.}
 
 trap INT
 
@@ -25,6 +28,20 @@ check_prereqs()
 	fi
 }
 
+kernel_gte()
+{
+	major=${1%.*}
+	minor=${1#*.}
+
+	if [ $kernel_major -gt $major ]; then
+		return 0
+	elif [[ $kernel_major -eq $major && $kernel_minor -ge $minor ]]; then
+		return 0
+	fi
+
+	return 1
+}
+
 zram_cleanup()
 {
 	echo "zram cleanup"
@@ -86,6 +103,13 @@ zram_max_streams()
 {
 	echo "set max_comp_streams to zram device(s)"
 
+	kernel_gte 4.7
+	if [ $? -eq 0 ]; then
+		echo "The device attribute max_comp_streams was"\
+		               "deprecated in 4.7"
+		return 0
+	fi
+
 	local i=0
 	for max_s in $zram_max_streams; do
 		local sys_path="/sys/block/zram${i}/max_comp_streams"
-- 
2.23.0


  parent reply	other threads:[~2022-01-27  9:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-15  9:56 [PATCH 1/3] selftests/zram: Remove obsolete max_comp_streams interface Yang Xu
2021-12-15  9:56 ` [PATCH 2/3] selftests/zram01.sh: Fix compression ratio calculation Yang Xu
2022-01-25 20:37   ` Shuah Khan
2022-01-26  6:08     ` xuyang2018.jy
2021-12-15  9:56 ` [PATCH 3/3] selftests/zram: Adapt the situation that /dev/zram0 is being used Yang Xu
2022-01-25 20:40   ` Shuah Khan
2022-01-13  6:26 ` [PATCH 1/3] selftests/zram: Remove obsolete max_comp_streams interface xuyang2018.jy
2022-01-25 20:52   ` Shuah Khan
2022-01-25 20:33 ` Shuah Khan
2022-01-26  5:19   ` xuyang2018.jy
2022-01-26  7:13     ` Petr Vorel
2022-01-26 17:35       ` Shuah Khan
2022-01-26 18:24         ` Petr Vorel
2022-01-26 18:37           ` Shuah Khan
2022-01-27  9:11         ` Yang Xu [this message]
2022-01-27  9:11           ` [PATCH v2 2/3] selftests/zram01.sh: Fix compression ratio calculation Yang Xu
2022-01-27  9:11           ` [PATCH v2 3/3] selftests/zram: Adapt the situation that /dev/zram0 is being used Yang Xu
2022-01-27 18:05           ` [PATCH v2 1/3] selftests/zram: Skip max_comp_streams interface on newer kernel Shuah Khan
2022-01-28  1:17             ` xuyang2018.jy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1643274697-3393-1-git-send-email-xuyang2018.jy@fujitsu.com \
    --to=xuyang2018.jy@fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=naresh.kamboju@linaro.org \
    --cc=pvorel@suse.cz \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).