The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Song Hu <husong@kylinos.cn>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org, shuah@kernel.org,
	david@kernel.org, ljs@kernel.org, liam@infradead.org,
	vbabka@kernel.org, surenb@google.com, mhocko@suse.com,
	peterx@redhat.com, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] selftests/mm: restore enable_soft_offline in hugetlb-soft-offline
Date: Wed, 12 Aug 2026 16:42:12 +0300	[thread overview]
Message-ID: <anx4NBqyMKwqvEGb@kernel.org> (raw)
In-Reply-To: <20260812120821.523860-4-husong@kylinos.cn>

Hi,

On Wed, Aug 12, 2026 at 08:08:21PM +0800, Song Hu wrote:
> hugetlb-soft-offline toggles /proc/sys/vm/enable_soft_offline between 1 and
> 0 (test_soft_offline_common(1) then (0)) and leaves it at 0 when it
> finishes, silently disabling soft offlining for the whole system after the
> run.  Read the original value before the test and restore it before
> ksft_finished().
> 
> Signed-off-by: Song Hu <husong@kylinos.cn>
> ---
>  .../selftests/mm/hugetlb-soft-offline.c       | 24 +++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/tools/testing/selftests/mm/hugetlb-soft-offline.c b/tools/testing/selftests/mm/hugetlb-soft-offline.c
> index bc202e4ed2bd..35dcf661b091 100644
> --- a/tools/testing/selftests/mm/hugetlb-soft-offline.c
> +++ b/tools/testing/selftests/mm/hugetlb-soft-offline.c
> @@ -99,6 +99,23 @@ static int set_enable_soft_offline(int value)
>  	return 0;
>  }
>  
> +static int get_enable_soft_offline(void)
> +{
> +	FILE *fp = fopen("/proc/sys/vm/enable_soft_offline", "r");
> +	int value = -1;
> +
> +	if (!fp) {
> +		ksft_perror(EPREFIX "failed to read enable_soft_offline");
> +		return -1;
> +	}
> +	if (fscanf(fp, "%d", &value) != 1) {
> +		ksft_perror(EPREFIX "failed to parse enable_soft_offline");
> +		value = -1;
> +	}
> +	fclose(fp);
> +	return value;
> +}

We have read_num() in vm_util and write_num() that can replace
set_enable_soft_offline().

> +
>  static int create_hugetlbfs_file(struct statfs *file_stat)
>  {
>  	int fd;
> @@ -185,6 +202,8 @@ static void test_soft_offline_common(int enable_soft_offline)
>  
>  int main(int argc, char **argv)
>  {
> +	int orig;

Please spell out what orig is this.

> +
>  	ksft_print_header();
>  
>  	if (!hugetlb_setup_default(8))
> @@ -192,8 +211,13 @@ int main(int argc, char **argv)
>  
>  	ksft_set_plan(2);
>  
> +	orig = get_enable_soft_offline();
> +
>  	test_soft_offline_common(1);
>  	test_soft_offline_common(0);
>  
> +	if (orig >= 0)
> +		set_enable_soft_offline(orig);
> +
>  	ksft_finished();
>  }
> -- 
> 2.43.0
> 

-- 
Sincerely yours,
Mike.

      reply	other threads:[~2026-08-12 13:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12 12:08 [PATCH 0/3] selftests/mm: TAP output and global-state fixes Song Hu
2026-08-12 12:08 ` [PATCH 1/3] selftests/mm: emit TAP header in uffd-wp-mremap Song Hu
2026-08-12 13:42   ` Mike Rapoport
2026-08-12 12:08 ` [PATCH 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test Song Hu
2026-08-12 13:42   ` Mike Rapoport
2026-08-12 12:08 ` [PATCH 3/3] selftests/mm: restore enable_soft_offline in hugetlb-soft-offline Song Hu
2026-08-12 13:42   ` Mike Rapoport [this message]

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=anx4NBqyMKwqvEGb@kernel.org \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=husong@kylinos.cn \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=peterx@redhat.com \
    --cc=shuah@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.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