public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Joerg Vehlow <lkml@jv-coder.de>
Cc: Joerg Vehlow <joerg.vehlow@aox-tech.de>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 3/3] cpuset_regression_test: Allow running, if groups exist
Date: Mon, 15 Nov 2021 09:24:14 +0000	[thread overview]
Message-ID: <87o86ldb5c.fsf@suse.de> (raw)
In-Reply-To: <20210623071543.171021-4-lkml@jv-coder.de>


Joerg Vehlow <lkml@jv-coder.de> writes:

> From: Joerg Vehlow <joerg.vehlow@aox-tech.de>
>
> Even if groups with a set cpuset.cpus exist, the original bug can still be
> in the kernel. It was possible to create a group, set cpuset.cpus and only
> then set cpuset.cpu_exclusive to 1. This did not trigger the bug.
>
> This patche sets cpuset.cpus for all groups to an empty value, before
> running the test and resets them to their original value after the test.
>
> Signed-off-by: Joerg Vehlow <joerg.vehlow@aox-tech.de>

Acked-by: Richard Palethorpe <rpalethorpe@suse.com>

> ---
>  .../cpuset/cpuset_regression_test.sh          | 51 +++++++++++++++++++
>  1 file changed, 51 insertions(+)
>
> diff --git a/testcases/kernel/controllers/cpuset/cpuset_regression_test.sh b/testcases/kernel/controllers/cpuset/cpuset_regression_test.sh
> index 369fbedae..de1d6e649 100755
> --- a/testcases/kernel/controllers/cpuset/cpuset_regression_test.sh
> +++ b/testcases/kernel/controllers/cpuset/cpuset_regression_test.sh
> @@ -19,12 +19,54 @@ TST_MIN_KVER="3.18"
>  . cgroup_lib.sh
>  
>  LOCAL_MOUNTPOINT="cpuset_test"
> +BACKUP_DIRECTORY="cpuset_backup"
>  
>  root_cpuset_dir=
>  cpu_exclusive="cpuset.cpu_exclusive"
>  cpus="cpuset.cpus"
>  old_cpu_exclusive_value=1
>  
> +# cpuset_backup_and_update <backup_dir> <what> <value>
> +# Create backup of the values of a specific file (<what>)
> +# in all cpuset groups and set the value to <value>
> +# The backup is written to <backup_dir> in the same structure
> +# as in the cpuset filesystem
> +cpuset_backup_and_update()
> +{
> +	local backup_dir=$1
> +	local what=$2
> +	local value=$3
> +	local old_dir=$PWD
> +
> +	cd ${root_cpuset_dir}
> +	find . -mindepth 2 -name ${what} -print0 |
> +	while IFS= read -r -d '' file; do
> +		mkdir -p "$(dirname "${backup_dir}/${file}")"
> +		cat "${file}" > "${backup_dir}/${file}"
> +		echo "${value}" > "${file}"
> +	done
> +
> +	cd $old_dir
> +}
> +
> +# cpuset_restore <backup_dir> <what>
> +# Restores the value of a file (<what>) in all cpuset
> +# groups from the backup created by cpuset_backup_and_update
> +cpuset_restore()
> +{
> +	local backup_dir=$1
> +	local what=$2
> +	local old_dir=$PWD
> +
> +	cd ${backup_dir}
> +	find . -mindepth 2 -name ${what} -print0 |
> +	while IFS= read -r -d '' file; do
> +		cat "${file}" > "${root_cpuset_dir}/${file}"
> +	done
> +
> +	cd $old_dir
> +}
> +
>  setup()
>  {
>  	if ! is_cgroup_subsystem_available_and_enabled "cpuset"; then
> @@ -49,6 +91,11 @@ setup()
>  		tst_brk TBROK "Both cpuset.cpu_exclusive and cpu_exclusive do not exist"
>  	fi
>  
> +	# Ensure that no group explicitely uses a cpu,
> +	# otherwise setting cpuset.cpus for the testgroup will fail
> +	mkdir ${BACKUP_DIRECTORY}
> +	cpuset_backup_and_update "${PWD}/${BACKUP_DIRECTORY}" ${cpus} ""
> +
>  	old_cpu_exclusive_value=$(cat ${root_cpuset_dir}/${cpu_exclusive})
>  	if [ "${old_cpu_exclusive_value}" != "1" ];then
>  		echo 1 > ${root_cpuset_dir}/${cpu_exclusive}
> @@ -62,6 +109,10 @@ cleanup()
>  		rmdir ${root_cpuset_dir}/testdir
>  	fi
>  
> +	if [ -d "${BACKUP_DIRECTORY}" ]; then
> +		cpuset_restore "${PWD}/${BACKUP_DIRECTORY}" ${cpus}
> +	fi
> +
>  	if [ "$old_cpu_exclusive_value" != 1 ]; then
>  		# Need to flush, or write may fail with: "Device or resource busy"
>  		sync


-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2021-11-15  9:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-23  7:15 [LTP] [PATCH 0/3] cpuset_regression_test: convert and improve Joerg Vehlow
2021-06-23  7:15 ` [LTP] [PATCH 1/3] cpuset_regression_test: Convert to new api Joerg Vehlow
2021-11-15  9:23   ` Richard Palethorpe
2021-11-15 10:36   ` Richard Palethorpe
2021-06-23  7:15 ` [LTP] [PATCH 2/3] cpuset_regression_test: Drop min cpu requirement Joerg Vehlow
2021-11-15  9:23   ` Richard Palethorpe
2021-06-23  7:15 ` [LTP] [PATCH 3/3] cpuset_regression_test: Allow running, if groups exist Joerg Vehlow
2021-11-15  9:24   ` Richard Palethorpe [this message]
2021-06-23 11:11 ` [LTP] [PATCH 0/3] cpuset_regression_test: convert and improve Richard Palethorpe
2021-06-23 11:20   ` Joerg Vehlow
2021-11-15  9:19     ` Richard Palethorpe

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=87o86ldb5c.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=joerg.vehlow@aox-tech.de \
    --cc=lkml@jv-coder.de \
    --cc=ltp@lists.linux.it \
    /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