From patchwork Sat May 21 08:38:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: patrick wang X-Patchwork-Id: 12857745 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2EC4C433EF for ; Sat, 21 May 2022 08:38:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 088366B0073; Sat, 21 May 2022 04:38:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 036946B0074; Sat, 21 May 2022 04:38:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E413D6B0075; Sat, 21 May 2022 04:38:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D537F6B0073 for ; Sat, 21 May 2022 04:38:50 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B3575696 for ; Sat, 21 May 2022 08:38:50 +0000 (UTC) X-FDA: 79489099620.11.72BF130 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf16.hostedemail.com (Postfix) with ESMTP id AF8C218001C for ; Sat, 21 May 2022 08:38:37 +0000 (UTC) Received: by mail-pj1-f50.google.com with SMTP id ev18so9853512pjb.4 for ; Sat, 21 May 2022 01:38:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JifwYnD6JO0kOV61Ln5I93dJxrKHSoYK3bTtvWqPo9s=; b=IfwIadc/gfqz1l+D/XvQVz8sUI7LNyNig02LUX7Nx3A5oAwQEGtseWjwXl8Lz1UMom DTSx8BK/FYzL8VGeFiFiJp/YiaZNGzpBy6lReK2S1DachCgSJzGAw1hwdGWWUGpzK8gX gs2FaVMwoY2TjWX2YHomgmB4VSXIQ2b4SzbtumQcnPciIz6JA0pFaMpmC86Fefus8faX hJz0NTz7bIKCh4J6W78D2WGm4v4udFFEcuvGer39liOUHFAzIbmA2gWPiEOCiiAxVZ/Z wW9RrNse4ZjNDu91f9YmBg5Fb3uyXhFTDCD7kAdV85aaN2a2R+ektUEQbV91ekKCkYUy +8Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JifwYnD6JO0kOV61Ln5I93dJxrKHSoYK3bTtvWqPo9s=; b=3COWF2pfeEFWzlnDzybGT1NKv0CzjVtcuDH81qd7lipUSZKozZrAQDDiRBxI4M67pF s0AXu5KVc2WW1TEDuR2TwVKex/OeVeDvshLqxu/fzuKS1kAj14gWbdR7ptv7hmC25eC1 KtNAwhQt5LR3UIqX05X9VPY57y/fk8ApEJsbbb3UX7E9j7OqCdjeAPwij1n7r5d+ckt8 uGQwpqS13T8MwO2XC4vfpwwtve9pLH4dts7JVWd5DoU6BLpEn7CjfjM0iFi7gh55m6Oz 9TZ6YTDOiksKfdi9C37vO4oMXCsiUJwN27tPDUhiEu1RUEcSvP3CwYL5eu+txTFvwQwv d71w== X-Gm-Message-State: AOAM530eA2peUDB7XJ//Ev0jLr3mbZjGO/0OIaKrvbR5ukwPNkckzu1j GQzruSF5JJ65OnoixWJ2QsU= X-Google-Smtp-Source: ABdhPJyHSwmxq/BUcPtiGeaOIa9ApUD2tKNORjgg1PkOAZaXH5D5ZoCezl2qk2NGuxpmDgjR8LruuQ== X-Received: by 2002:a17:90a:4615:b0:1df:40e6:6474 with SMTP id w21-20020a17090a461500b001df40e66474mr15500678pjg.194.1653122329370; Sat, 21 May 2022 01:38:49 -0700 (PDT) Received: from localhost ([101.86.206.159]) by smtp.gmail.com with ESMTPSA id f7-20020a6547c7000000b003db8691008esm1022381pgs.12.2022.05.21.01.38.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 May 2022 01:38:49 -0700 (PDT) From: Patrick Wang To: akpm@linux-foundation.org, shuah@kernel.org Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patrick.wang.shcn@gmail.com Subject: [PATCH 1/3] selftests: vm: check numa_available() before operating "merge_across_nodes" in ksm_tests Date: Sat, 21 May 2022 16:38:23 +0800 Message-Id: <20220521083825.319654-2-patrick.wang.shcn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220521083825.319654-1-patrick.wang.shcn@gmail.com> References: <20220521083825.319654-1-patrick.wang.shcn@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: AF8C218001C X-Stat-Signature: 1kg1gtim6ebbn569w7u9wp5epsqhdapc Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="IfwIadc/"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of patrick.wang.shcn@gmail.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=patrick.wang.shcn@gmail.com X-Rspam-User: X-HE-Tag: 1653122317-474907 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Currently, ksm_tests operates "merge_across_nodes" with NUMA either enabled or disabled. In a system with NUMA disabled, these operations will fail and output a misleading report given "merge_across_nodes" does not exist in sysfs: ---------------------------- running ./ksm_tests -M -p 10 ---------------------------- f /sys/kernel/mm/ksm/merge_across_nodes fopen: No such file or directory Cannot save default tunables [FAIL] ---------------------- So check numa_available() before those operations to skip them if NUMA is disabled. Signed-off-by: Patrick Wang --- tools/testing/selftests/vm/ksm_tests.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/vm/ksm_tests.c b/tools/testing/selftests/vm/ksm_tests.c index fd85f15869d1..2fcf24312da8 100644 --- a/tools/testing/selftests/vm/ksm_tests.c +++ b/tools/testing/selftests/vm/ksm_tests.c @@ -221,7 +221,8 @@ static bool assert_ksm_pages_count(long dupl_page_count) static int ksm_save_def(struct ksm_sysfs *ksm_sysfs) { if (ksm_read_sysfs(KSM_FP("max_page_sharing"), &ksm_sysfs->max_page_sharing) || - ksm_read_sysfs(KSM_FP("merge_across_nodes"), &ksm_sysfs->merge_across_nodes) || + numa_available() ? 0 : + ksm_read_sysfs(KSM_FP("merge_across_nodes"), &ksm_sysfs->merge_across_nodes) || ksm_read_sysfs(KSM_FP("sleep_millisecs"), &ksm_sysfs->sleep_millisecs) || ksm_read_sysfs(KSM_FP("pages_to_scan"), &ksm_sysfs->pages_to_scan) || ksm_read_sysfs(KSM_FP("run"), &ksm_sysfs->run) || @@ -236,7 +237,8 @@ static int ksm_save_def(struct ksm_sysfs *ksm_sysfs) static int ksm_restore(struct ksm_sysfs *ksm_sysfs) { if (ksm_write_sysfs(KSM_FP("max_page_sharing"), ksm_sysfs->max_page_sharing) || - ksm_write_sysfs(KSM_FP("merge_across_nodes"), ksm_sysfs->merge_across_nodes) || + numa_available() ? 0 : + ksm_write_sysfs(KSM_FP("merge_across_nodes"), ksm_sysfs->merge_across_nodes) || ksm_write_sysfs(KSM_FP("pages_to_scan"), ksm_sysfs->pages_to_scan) || ksm_write_sysfs(KSM_FP("run"), ksm_sysfs->run) || ksm_write_sysfs(KSM_FP("sleep_millisecs"), ksm_sysfs->sleep_millisecs) || @@ -720,7 +722,8 @@ int main(int argc, char *argv[]) if (ksm_write_sysfs(KSM_FP("run"), 2) || ksm_write_sysfs(KSM_FP("sleep_millisecs"), 0) || - ksm_write_sysfs(KSM_FP("merge_across_nodes"), 1) || + numa_available() ? 0 : + ksm_write_sysfs(KSM_FP("merge_across_nodes"), 1) || ksm_write_sysfs(KSM_FP("pages_to_scan"), page_count)) return KSFT_FAIL;