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=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 D3359C433EF for ; Mon, 13 Sep 2021 18:39:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5BD71610A2 for ; Mon, 13 Sep 2021 18:39:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5BD71610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 8B0216B006C; Mon, 13 Sep 2021 14:39:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 860026B0071; Mon, 13 Sep 2021 14:39:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 727966B0072; Mon, 13 Sep 2021 14:39:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id 650DC6B006C for ; Mon, 13 Sep 2021 14:39:47 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 18BFB267F4 for ; Mon, 13 Sep 2021 18:39:47 +0000 (UTC) X-FDA: 78583414014.09.5C2BA0B Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) by imf08.hostedemail.com (Postfix) with ESMTP id CF7353000098 for ; Mon, 13 Sep 2021 18:39:46 +0000 (UTC) Received: by mail-lj1-f170.google.com with SMTP id r3so19028936ljc.4 for ; Mon, 13 Sep 2021 11:39:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=OlvB7hrdoiO9FX6H+Pv2eU8z16zPILZHXeOZibWtBXs=; b=orgu1YA9EYjvnsjWRykwYRoDEUeSFwpTXocpJiTTmyu/83I8f8DvM18wCoR5yV6M4e 3Xf+VPHF0vtYe2UJYtSGox5y8VMRebqZz5OH/WFFnVanAAEDTtMk6pS4aoDtnRpXeTaS v8Vm+B+kSfwoiL+qfdxZ6yU/sCoh6kIHxvWBnE50pLmw4dr4bQR6n8oSHbukBJx98+5C 2dq3kJPh/CsGdvNZttmLXqNqAVkK79Vrx9hXnbO61SQK/PjtiGfOlgMmlTwtX4mYdOjH bfeLI0W5Gd0cZTS8cPn9Tyf7UKyvzr5/AkPKBVhSWialUtAHwYiHgPxxOm+I6DWS65p6 ouYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=OlvB7hrdoiO9FX6H+Pv2eU8z16zPILZHXeOZibWtBXs=; b=Z17joMoDoT7dzDkvNwF8L2146Wl3O1/HtUFf+5tfAg2rHuQmQiAnJk+MXMcUQWOknY 1DelKxOqdTalQCogxzkMkjo3O9iqc3BVuzwtWrQxZmL8jYLV1HjqU8Xe+CYZk8SnfsVz vJFOiLU/OhVpIVt3q4a9jtmgAHq2YIuZtxdHoVq/8711rKZm/aqbr7ji3bH8P/k46zpb wR4Qkq/vMuIlPlxn4wsiOG/JIKTZFaXhxR+yjtJLVMRXNMP1Te39oAKjnpdnRc5YTs5j ekSsfMQrSarVxuV8NpAqWGByIe8qlUvzSItOAgRTCNHsXqO7sutiVUTKyRh0DMarP7R0 lxIw== X-Gm-Message-State: AOAM532zjMr5KrprRE2Le3oDuJxxR0exdietlf5OSSGp3lA/52LRSt1s 60bBA4Bcjm5daAxDzYXrofY= X-Google-Smtp-Source: ABdhPJwmJIk87zvtwUyMaLsbIsEqE5/n8V85gymgyPTPyf5kR6nIuAPQ62H+NzCSEj4Fj/qD9Lj45g== X-Received: by 2002:a2e:991a:: with SMTP id v26mr12096832lji.111.1631558385554; Mon, 13 Sep 2021 11:39:45 -0700 (PDT) Received: from asus ([147.30.82.254]) by smtp.gmail.com with ESMTPSA id t2sm1071043ljk.125.2021.09.13.11.39.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 11:39:45 -0700 (PDT) Date: Tue, 14 Sep 2021 00:39:42 +0600 From: Zhansaya Bagdauletkyzy To: "Aneesh Kumar K.V" Cc: linux-mm@kvack.org, akpm@linux-foundation.org, Pavel Tatashin , Tyler Hicks , Hugh Dickins , Shuah Khan Subject: Re: [PATCH] selftest/vm: Fix ksm selftest to run with different NUMA topologies Message-ID: <20210913183942.GA159148@asus> 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: ankztgzkm7j1wshtnippa586y8q7qaib Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=orgu1YA9; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of zhansayabagdaulet@gmail.com designates 209.85.208.170 as permitted sender) smtp.mailfrom=zhansayabagdaulet@gmail.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: CF7353000098 X-HE-Tag: 1631558386-157090 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 Mon, Sep 13, 2021 at 06:00:40PM +0530, Aneesh Kumar K.V wrote: > Platforms can have non-contiguous NUMA nodes like below > Hi Aneesh, Thank you for pointing this out. Everything looks good to me: Reviewed-by: Zhansaya Bagdauletkyzy Zhansaya > #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. > > 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 >