[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-4.22 4/5] tests/numa: add unit tests for NUMA setup logic


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 3 Jun 2026 15:45:50 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=J7yhNv497TOx+GLykH9rC2Yigxk/02FKic+gK7C3HjE=; b=AUifN/9emtYdoTHIEc2iBDE4lPd0YwZ8sjVXhS82L6bF4Ghuk72FHpnT31KsejvPVJgbSXC7dV41fE2EX3KtlaNwFmb4+XuXqTPXo9zMhAbNWLB1HfFK8uY4zRpZ8s3RcrtyHOM9tAkvbWA8HIqoMT00Wb9Z5pBpBRwMPxB1S8TwzWQJLY/JpKiB1s8GOjtGja/tiaoYrnKC5Ma1A6raEXZ57NAl987TO4inL1UwDSNu1WVcWE0igiUowWZCdFW57hGerFdKpZPS/kQQ1fIWJ77JAVn/hH4ykcB3JtHYRTqZRJRNneydsRZ+f1IBez7ysevzDt4G/jp0E17kMAc4qQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pbTfgfGtPYgWGzxZ2AkLoWDir0D5ReE4N60CL3+LeOgK73fBs/Tlv6aSWzHSe0UBNb9nbAx9Ln58X/RrzML8MVDn1VIZfGh5Fdyy3dWL5QbkbH1zPJM0+Cx09MOUJn7gAHQ+6aLot1Q6h2NYhnEmEJP06WTUaV5uR+EWquFSBeV5pYJC/g1YWOhKZGNSjjq5RqSxc/GWsYwvkST+krKg92oQwbOplIA83TxTJ0XvyyVRZF461W0z8B8DANhKyBjrqxtlINE7Z5vvBv5is243QZDa7C2PhJZcaQI94OvgDseb91CKp6zLEIMYWfswWClG4tMPTQptg4epQJ8EQmvFLw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 03 Jun 2026 13:46:06 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Jun 03, 2026 at 10:38:52AM +0200, Jan Beulich wrote:
> On 01.06.2026 17:43, Roger Pau Monne wrote:
> > --- /dev/null
> > +++ b/tools/tests/numa/.gitignore
> > @@ -0,0 +1,2 @@
> > +/numa.h
> > +/test-numa
> 
> Why the leading slashes?

This is the format of the .gitignore that we use in the pdx, numa and
rengeset testing.  The slashes denote that the pattern is relative to
the particular .gitignore itself, but won't match any level below the
.gitignore.

> > --- /dev/null
> > +++ b/tools/tests/numa/Makefile
> > @@ -0,0 +1,47 @@
> > +XEN_ROOT=$(CURDIR)/../../..
> > +include $(XEN_ROOT)/tools/Rules.mk
> > +
> > +TARGETS := test-numa
> > +
> > +.PHONY: all
> > +all: $(TARGETS)
> > +
> > +.PHONY: run
> > +run: $(TARGETS)
> > +ifeq ($(CC),$(HOSTCC))
> > +   set -e;             \
> > +   for test in $? ; do \
> > +           ./$$test ;  \
> > +   done
> > +else
> > +   $(warning HOSTCC != CC, will not run test)
> > +endif
> > +
> > +.PHONY: clean
> > +clean:
> > +   $(RM) -- *.o $(TARGETS) $(DEPS_RM) numa.h
> > +
> > +.PHONY: distclean
> > +distclean: clean
> > +   $(RM) -- *~
> 
> I see we remove *~ elsewhere, but not everywhere. I don't, however, know
> why we have that, and hence I wonder whether it really wants replicating.

Seems like *~ is a backup file created by some editors (Emacs or Vim
for example.  Again this is a verbatim copy of the Makefile that we
use for other unit testing (I think I copied this from the PDX
testing).

> > --- /dev/null
> > +++ b/tools/tests/numa/harness.h
> > @@ -0,0 +1,184 @@
> > +/* SPDX-License-Identifier: GPL-2.0-only */
> > +/*
> > + * Unit tests for NUMA setup.
> > + *
> > + * Copyright (C) 2026 Cloud Software Group
> > + */
> > +
> > +#ifndef _TEST_HARNESS_
> > +#define _TEST_HARNESS_
> > +
> > +#include <assert.h>
> > +#include <errno.h>
> > +#include <inttypes.h>
> > +#include <stdbool.h>
> > +#include <stdint.h>
> > +#include <stdio.h>
> > +#include <stdlib.h>
> > +#include <string.h>
> > +
> > +#include <xen-tools/bitops.h>
> > +#include <xen-tools/common-macros.h>
> > +
> > +#define CONFIG_DEBUG
> > +#define CONFIG_NUMA
> > +#define CONFIG_NR_NUMA_NODES 64
> > +#define NR_CPUS 256
> > +#define MAX_RANGES 128
> > +#define PADDR_BITS 52
> > +
> > +#define __init
> > +#define __initdata
> > +#define __ro_after_init
> > +#define __read_mostly
> > +
> > +#define printk printf
> > +#define XENLOG_INFO ""
> > +#define XENLOG_DEBUG ""
> > +#define XENLOG_WARNING ""
> > +#define KERN_INFO ""
> > +#define KERN_ERR ""
> > +#define KERN_WARNING ""
> > +#define KERN_DEBUG ""
> > +
> > +#define PAGE_SHIFT    12
> > +/* Some libcs define PAGE_SIZE in limits.h. */
> > +#undef  PAGE_SIZE
> > +#define PAGE_SIZE     (1L << PAGE_SHIFT)
> > +#define MAX_ORDER     18 /* 2 * PAGETABLE_ORDER (9) */
> > +
> > +#define PFN_DOWN(x)   ((x) >> PAGE_SHIFT)
> > +#define PFN_UP(x)     (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
> > +
> > +#define paddr_to_pfn(pa)  ((unsigned long)((pa) >> PAGE_SHIFT))
> > +#define mfn_to_pdx(mfn)   (mfn)
> > +#define paddr_to_pdx(pa)  ((pa) >> PAGE_SHIFT)
> > +#define mfn_to_maddr(mfn) ((mfn) << PAGE_SHIFT)
> > +
> > +#define ASSERT assert
> > +#define ASSERT_UNREACHABLE() assert(0)
> > +
> > +/* For the purposes of the testing assume arch NID == Xen NID. */
> > +#define numa_node_to_arch_nid(n) (n)
> > +
> > +typedef uint64_t paddr_t;
> > +#define PRIpaddr "016" PRIx64
> > +
> > +typedef unsigned long mfn_t;
> > +typedef uint8_t nodeid_t;
> > +
> > +#define __set_bit set_bit
> > +#define __clear_bit clear_bit
> > +
> > +static inline unsigned int find_next_bit(
> > +    const unsigned long *addr, unsigned int size, unsigned int off)
> > +{
> > +    unsigned int i;
> > +
> > +    ASSERT(size <= BITS_PER_LONG);
> > +
> > +    for ( i = off; i < size; i++ )
> > +        if ( !!(*addr & (1UL << i)) )
> 
> Why the !! ?

I copied this from the PDX header and simplified the function because
now it only cares about set values, and forgot to drop it.  I can
indeed drop the !!.

> 
> > +            return i;
> > +
> > +    return size;
> > +}
> > +
> > +#define find_first_bit(b, s) find_next_bit(b, s, 0)
> > +
> > +/* Minimal cpumask support. */
> > +typedef struct cpumask{ DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
> > +
> > +#define cpumask_clear_cpu(c, m) clear_bit((c), (m)->bits)
> > +
> > +/* Define the nodemask helpers used. */
> > +typedef struct nodemask{ DECLARE_BITMAP(bits, CONFIG_NR_NUMA_NODES); } 
> > nodemask_t;
> > +
> > +#define node_set(node, dst) set_bit((node), (dst).bits)
> 
> To aid readability, omit the parentheses around "node"? (More similar cases
> further down.)

Sure, this is all copied from the nodemask.h header.  I should have
adjusted.

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.