Message ID | 20231204102027.57185-6-ryan.roberts@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2665907vqy; Mon, 4 Dec 2023 02:21:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFmor/CCYwUFbcCdtOgMtOds0ZlErCCKySfd+jVnVoqkc1nGbvldpiETRp5+4csZjkhshVf X-Received: by 2002:a05:6a20:258b:b0:18c:64e0:447b with SMTP id k11-20020a056a20258b00b0018c64e0447bmr1205282pzd.28.1701685300445; Mon, 04 Dec 2023 02:21:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701685300; cv=none; d=google.com; s=arc-20160816; b=pXT6IBJxfNYhkrahnXzCh4TZIJhtTvq0lvFfi2Na8cuLpKmItymutzohJXsuHkUQE9 Q3a+htpf9GpczmPZ7ytA34j0Jy5G3+oDdfnxzh/D4gu187Fs+9kZ5j+mGzOtdtLG1Jzo IPCnen5U/YxPrACFAw6WAvLFi4rF9GDZu4uNtFGQT0dWrum6Dn+UTM1J3dGmSeQtkh5P Da3aERSFpiENChy/6BSiUm5BQWfkpBQnu8+4chd0XvA2dwQMZZnyjLdTbbHrMUSU46FQ MV3bEKLYduWUdHYjwSoocouRUFU+46YpekhqY1NqRiNvyp84WOFPOjmT8B+dVx4pyYgS fWoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=nujK6Tjb+pxtj0tIwTcRlIIllYyZp5Ttoqe+G0ErqQk=; fh=q/mRw8BjqfXMwBZlJBUekkoSHkVT4tbxFKy9NNgF+Vc=; b=hrfw6G30J3OP9dfKM2nvEw2FQhSElZb7Jw2rvJfufu9AmHN/b1LJak5q+LOnfWyor6 igyrTsS4v5uppMXuHm+j00dRpUNrkNiTYsEz4LCuqXvj3NdrkDNT5dZNHCeKyWSgGmJ+ zsiBK2Q2ShcJq8397KLPvFAyezoORChfTrE81Yyb2PemvfM2KdRrp+MK5qs61VUkfyTy 7IaeCmjigivbsftn1OopmII8/aeKyvycsp4lD1ITyq0ezb+ko7vtiUpc2aj8FTzMYaQx 8b6rEicrIt25im1ARUfclIbnabFkEny3kZYxDTPWs4345HKLQfCMYmWBvti3W9aACfDu E2uA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id il15-20020a17090b164f00b0027cdee52324si2396377pjb.74.2023.12.04.02.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 02:21:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2D947809717A; Mon, 4 Dec 2023 02:21:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232459AbjLDKVO (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Mon, 4 Dec 2023 05:21:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343768AbjLDKVA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 4 Dec 2023 05:21:00 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3C51685 for <linux-kernel@vger.kernel.org>; Mon, 4 Dec 2023 02:21:07 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3FE0416F2; Mon, 4 Dec 2023 02:21:54 -0800 (PST) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 28D103F6C4; Mon, 4 Dec 2023 02:21:04 -0800 (PST) From: Ryan Roberts <ryan.roberts@arm.com> To: Andrew Morton <akpm@linux-foundation.org>, Matthew Wilcox <willy@infradead.org>, Yin Fengwei <fengwei.yin@intel.com>, David Hildenbrand <david@redhat.com>, Yu Zhao <yuzhao@google.com>, Catalin Marinas <catalin.marinas@arm.com>, Anshuman Khandual <anshuman.khandual@arm.com>, Yang Shi <shy828301@gmail.com>, "Huang, Ying" <ying.huang@intel.com>, Zi Yan <ziy@nvidia.com>, Luis Chamberlain <mcgrof@kernel.org>, Itaru Kitayama <itaru.kitayama@gmail.com>, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>, John Hubbard <jhubbard@nvidia.com>, David Rientjes <rientjes@google.com>, Vlastimil Babka <vbabka@suse.cz>, Hugh Dickins <hughd@google.com>, Kefeng Wang <wangkefeng.wang@huawei.com>, Barry Song <21cnbao@gmail.com>, Alistair Popple <apopple@nvidia.com> Cc: Ryan Roberts <ryan.roberts@arm.com>, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 05/10] selftests/mm/kugepaged: Restore thp settings at exit Date: Mon, 4 Dec 2023 10:20:22 +0000 Message-Id: <20231204102027.57185-6-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231204102027.57185-1-ryan.roberts@arm.com> References: <20231204102027.57185-1-ryan.roberts@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 04 Dec 2023 02:21:37 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784346365451774527 X-GMAIL-MSGID: 1784346365451774527 |
Series |
Multi-size THP for anonymous memory
|
|
Commit Message
Ryan Roberts
Dec. 4, 2023, 10:20 a.m. UTC
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@nvidia.com> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com> --- tools/testing/selftests/mm/khugepaged.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
Comments
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@nvidia.com> > Signed-off-by: Ryan Roberts <ryan.roberts@arm.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@redhat.com> Might similarly come in handy for the cow tests. Can be done later.
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);