lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <22992b35-c6b6-4fcd-bfba-01a5f99198cd@redhat.com>
Date:   Tue, 5 Dec 2023 18:00:11 +0100
From:   David Hildenbrand <david@...hat.com>
To:     Ryan Roberts <ryan.roberts@....com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Matthew Wilcox <willy@...radead.org>,
        Yin Fengwei <fengwei.yin@...el.com>,
        Yu Zhao <yuzhao@...gle.com>,
        Catalin Marinas <catalin.marinas@....com>,
        Anshuman Khandual <anshuman.khandual@....com>,
        Yang Shi <shy828301@...il.com>,
        "Huang, Ying" <ying.huang@...el.com>, Zi Yan <ziy@...dia.com>,
        Luis Chamberlain <mcgrof@...nel.org>,
        Itaru Kitayama <itaru.kitayama@...il.com>,
        "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
        John Hubbard <jhubbard@...dia.com>,
        David Rientjes <rientjes@...gle.com>,
        Vlastimil Babka <vbabka@...e.cz>,
        Hugh Dickins <hughd@...gle.com>,
        Kefeng Wang <wangkefeng.wang@...wei.com>,
        Barry Song <21cnbao@...il.com>,
        Alistair Popple <apopple@...dia.com>
Cc:     linux-mm@...ck.org, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v8 05/10] selftests/mm/kugepaged: Restore thp settings at
 exit

On 04.12.23 11:20, Ryan Roberts wrote:
> Previously, the saved thp settings would be restored upon a signal or at
> the natural end of the test suite. But there are some tests that
> directly call exit() upon failure. In this case, the thp settings were
> not being restored, which could then influence other tests.
> 
> Fix this by installing an atexit() handler to do the actual restore. The
> signal handler can now just call exit() and the atexit handler is
> invoked.
> 
> Reviewed-by: Alistair Popple <apopple@...dia.com>
> Signed-off-by: Ryan Roberts <ryan.roberts@....com>
> ---
>   tools/testing/selftests/mm/khugepaged.c | 17 +++++++++++------
>   1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/khugepaged.c b/tools/testing/selftests/mm/khugepaged.c
> index 030667cb5533..fc47a1c4944c 100644
> --- a/tools/testing/selftests/mm/khugepaged.c
> +++ b/tools/testing/selftests/mm/khugepaged.c
> @@ -374,18 +374,22 @@ static void pop_settings(void)
>   	write_settings(current_settings());
>   }
>   
> -static void restore_settings(int sig)
> +static void restore_settings_atexit(void)
>   {
>   	if (skip_settings_restore)
> -		goto out;
> +		return;
>   
>   	printf("Restore THP and khugepaged settings...");
>   	write_settings(&saved_settings);
>   	success("OK");
> -	if (sig)
> -		exit(EXIT_FAILURE);
> -out:
> -	exit(exit_status);
> +
> +	skip_settings_restore = true;
> +}
> +
> +static void restore_settings(int sig)
> +{
> +	/* exit() will invoke the restore_settings_atexit handler. */
> +	exit(sig ? EXIT_FAILURE : exit_status);
>   }
>   
>   static void save_settings(void)
> @@ -415,6 +419,7 @@ static void save_settings(void)
>   
>   	success("OK");
>   
> +	atexit(restore_settings_atexit);
>   	signal(SIGTERM, restore_settings);
>   	signal(SIGINT, restore_settings);
>   	signal(SIGHUP, restore_settings);

Reviewed-by: David Hildenbrand <david@...hat.com>

Might similarly come in handy for the cow tests. Can be done later.

-- 
Cheers,

David / dhildenb

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ