From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB060C433EF for ; Mon, 13 Sep 2021 14:24:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 596F360F44 for ; Mon, 13 Sep 2021 14:24:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 596F360F44 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id A68F0900002; Mon, 13 Sep 2021 10:24:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A18226B0071; Mon, 13 Sep 2021 10:24:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92DEC900002; Mon, 13 Sep 2021 10:24:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0174.hostedemail.com [216.40.44.174]) by kanga.kvack.org (Postfix) with ESMTP id 858E36B006C for ; Mon, 13 Sep 2021 10:24:36 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 4626B180AD804 for ; Mon, 13 Sep 2021 14:24:36 +0000 (UTC) X-FDA: 78582770952.26.2F207DB Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by imf24.hostedemail.com (Postfix) with ESMTP id D8356B00009F for ; Mon, 13 Sep 2021 14:24:35 +0000 (UTC) Received: from sequoia (162-237-133-238.lightspeed.rcsntx.sbcglobal.net [162.237.133.238]) by linux.microsoft.com (Postfix) with ESMTPSA id 626BF20B6C51; Mon, 13 Sep 2021 07:24:34 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 626BF20B6C51 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1631543074; bh=+Kdq4BELq7JNaKZo6IDDlfmuXuQ69gV8dJn6LeD9N2o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=g0T2tLh5u8LSEem8vgsbdyyjPA077BWIL0/4BNapqDywM5nosXMSDWfd7mortgJUO T0/RcXJbLvTLnwMql6W4bCo90zUMQAM/vOfOBzgCscj20+jDcUTJ7UzqGjEUkXMqBK cCPjGdgiVoOD9DqCpK9aCPTHIORjZHi3ztVr566s= Date: Mon, 13 Sep 2021 09:24:32 -0500 From: Tyler Hicks To: "Aneesh Kumar K.V" Cc: linux-mm@kvack.org, akpm@linux-foundation.org, Zhansaya Bagdauletkyzy , Pavel Tatashin , Hugh Dickins , Shuah Khan Subject: Re: [PATCH] selftest/vm: Fix ksm selftest to run with different NUMA topologies Message-ID: <20210913142432.GB3600@sequoia> References: <20210913123040.278031-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210913123040.278031-1-aneesh.kumar@linux.ibm.com> X-Stat-Signature: sjc7sgtyyq1im5s494yh7encqfzh8kjk Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux.microsoft.com header.s=default header.b=g0T2tLh5; dmarc=pass (policy=none) header.from=linux.microsoft.com; spf=pass (imf24.hostedemail.com: domain of tyhicks@linux.microsoft.com designates 13.77.154.182 as permitted sender) smtp.mailfrom=tyhicks@linux.microsoft.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: D8356B00009F X-HE-Tag: 1631543075-509046 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: On 2021-09-13 18:00:40, Aneesh Kumar K.V wrote: > Platforms can have non-contiguous NUMA nodes like below > > #numactl -H > available: 2 nodes (0,8) > ..... > node distances: > node 0 8 > 0: 10 40 > 8: 40 10 > > #numactl -H > available: 1 nodes (1) > .... > node distances: > node 1 > 1: 10 > > Hence update the test to not assume the presence of Node 0 and 1 > and also use numa_num_configured_nodes() instead of numa_max_node > for finding whether to skip the test. > I think this should be added: Fixes: 82e717ad3501 ("selftests: vm: add KSM merging across nodes test") The rest looks good to me: Reviewed-by: Tyler Hicks Tyler > Cc: Zhansaya Bagdauletkyzy > Cc: Pavel Tatashin > Cc: Tyler Hicks > Cc: Hugh Dickins > Cc: Shuah Khan > Signed-off-by: Aneesh Kumar K.V > --- > tools/testing/selftests/vm/ksm_tests.c | 32 +++++++++++++++++++++++--- > 1 file changed, 29 insertions(+), 3 deletions(-) > > diff --git a/tools/testing/selftests/vm/ksm_tests.c b/tools/testing/selftests/vm/ksm_tests.c > index b61dcdb44c5b..5bdfc5fe4d57 100644 > --- a/tools/testing/selftests/vm/ksm_tests.c > +++ b/tools/testing/selftests/vm/ksm_tests.c > @@ -354,12 +354,37 @@ static int check_ksm_zero_page_merge(int mapping, int prot, long page_count, int > return KSFT_FAIL; > } > > +static unsigned long get_next_mem_node(unsigned long node) > +{ > + > + long node_size; > + unsigned long i; > + unsigned long max_node = numa_max_node(); > + /* > + * start from node and find the next memory node > + */ > +restart: > + for (i = node + 1; i <= max_node; i++) { > + node_size = numa_node_size(i, NULL); > + if (node_size > 0) > + return i; > + } > + node = -1; > + goto restart; > +} > + > +static unsigned long get_first_mem_node(void) > +{ > + return get_next_mem_node(-1); > +} > + > static int check_ksm_numa_merge(int mapping, int prot, int timeout, bool merge_across_nodes, > size_t page_size) > { > void *numa1_map_ptr, *numa2_map_ptr; > struct timespec start_time; > int page_count = 2; > + unsigned long first_node; > > if (clock_gettime(CLOCK_MONOTONIC_RAW, &start_time)) { > perror("clock_gettime"); > @@ -370,7 +395,7 @@ static int check_ksm_numa_merge(int mapping, int prot, int timeout, bool merge_a > perror("NUMA support not enabled"); > return KSFT_SKIP; > } > - if (numa_max_node() < 1) { > + if (numa_num_configured_nodes() <= 1) { > printf("At least 2 NUMA nodes must be available\n"); > return KSFT_SKIP; > } > @@ -378,8 +403,9 @@ static int check_ksm_numa_merge(int mapping, int prot, int timeout, bool merge_a > return KSFT_FAIL; > > /* allocate 2 pages in 2 different NUMA nodes and fill them with the same data */ > - numa1_map_ptr = numa_alloc_onnode(page_size, 0); > - numa2_map_ptr = numa_alloc_onnode(page_size, 1); > + first_node = get_first_mem_node(); > + numa1_map_ptr = numa_alloc_onnode(page_size, first_node); > + numa2_map_ptr = numa_alloc_onnode(page_size, get_next_mem_node(first_node)); > if (!numa1_map_ptr || !numa2_map_ptr) { > perror("numa_alloc_onnode"); > return KSFT_FAIL; > -- > 2.31.1 >