From patchwork Tue Sep 27 03:28:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Gongyi X-Patchwork-Id: 12989831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE827C07E9D for ; Tue, 27 Sep 2022 03:32:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229751AbiI0Dcx (ORCPT ); Mon, 26 Sep 2022 23:32:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229587AbiI0Dcw (ORCPT ); Mon, 26 Sep 2022 23:32:52 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2862A7AB6; Mon, 26 Sep 2022 20:32:48 -0700 (PDT) Received: from canpemm500005.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Mc4pS1L6ZzlXMF; Tue, 27 Sep 2022 11:28:32 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.63) by canpemm500005.china.huawei.com (7.192.104.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 27 Sep 2022 11:32:46 +0800 From: Zhao Gongyi To: , , , CC: , , , , , Subject: [PATCH -next v4 2/3] selftests/memory-hotplug: Restore memory before exit Date: Tue, 27 Sep 2022 11:28:50 +0800 Message-ID: <20220927032851.128174-3-zhaogongyi@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220927032851.128174-1-zhaogongyi@huawei.com> References: <20220927032851.128174-1-zhaogongyi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.63] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500005.china.huawei.com (7.192.104.229) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Some momory will be left in offline state when calling offline_memory_expect_fail() failed. Restore it before exit. Signed-off-by: Zhao Gongyi Reviewed-by: David Hildenbrand --- .../memory-hotplug/mem-on-off-test.sh | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh index 1d87611a7d52..91a7457616bb 100755 --- a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh +++ b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh @@ -134,6 +134,16 @@ offline_memory_expect_fail() return 0 } +online_all_offline_memory() +{ + for memory in `hotpluggable_offline_memory`; do + if ! online_memory_expect_success $memory; then + echo "$FUNCNAME $memory: unexpected fail" >&2 + retval=1 + fi + done +} + error=-12 priority=0 # Run with default of ratio=2 for Kselftest run @@ -275,11 +285,7 @@ done # Online all hot-pluggable memory # echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/error -for memory in `hotpluggable_offline_memory`; do - if ! online_memory_expect_success $memory; then - retval=1 - fi -done +online_all_offline_memory # # Test memory hot-remove error handling (online => offline) @@ -296,4 +302,9 @@ done echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error /sbin/modprobe -q -r memory-notifier-error-inject +# +# Restore memory before exit +# +online_all_offline_memory + exit $retval