diff mbox series

[v2,1/3] selftests/zram: Skip max_comp_streams interface on newer kernel

Message ID 1643274697-3393-1-git-send-email-xuyang2018.jy@fujitsu.com
State Accepted
Commit fc4eb486a59d70bd35cf1209f0e68c2d8b979193
Headers show
Series [v2,1/3] selftests/zram: Skip max_comp_streams interface on newer kernel | expand

Commit Message

Yang Xu Jan. 27, 2022, 9:11 a.m. UTC
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(+)

Comments

Shuah Khan Jan. 27, 2022, 6:05 p.m. UTC | #1
On 1/27/22 2:11 AM, Yang Xu wrote:
> 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>
> ---

Thank you. This and the other 2 patches are in linux-kselftest fixes branch
for rc3.

thanks,
-- Shuah
Yang Xu Jan. 28, 2022, 1:17 a.m. UTC | #2
on 2022/1/28 2:05, Shuah Khan wrote:
> On 1/27/22 2:11 AM, Yang Xu wrote:
>> 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>
>> ---
>
> Thank you. This and the other 2 patches are in linux-kselftest fixes branch
> for rc3.
Thanks for your review and merge.

Best Regards
Yang Xu
>
> thanks,
> -- Shuah
diff mbox series

Patch

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"