All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Oleksii Kurochko <oleksii.kurochko@gmail.com>,
	Anthony PERARD <anthony.perard@vates.tech>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH for-4.22 4/5] tests/numa: add unit tests for NUMA setup logic
Date: Wed, 3 Jun 2026 15:45:50 +0200	[thread overview]
Message-ID: <aiAwDo3EWi1oghm2@macbook.local> (raw)
In-Reply-To: <2b1df2c6-ccbb-402c-b65a-7f3beefdeb0d@suse.com>

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.


  reply	other threads:[~2026-06-03 13:46 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01 15:43 [PATCH for-4.22 0/5] numa: add unit testing plus fix regression Roger Pau Monne
2026-06-01 15:43 ` [PATCH for-4.22 1/5] tools/bitops: adjust bitmap_or() interface to match hypervisor Roger Pau Monne
2026-06-03 14:34   ` Anthony PERARD
2026-06-03 19:03     ` Roger Pau Monné
2026-06-01 15:43 ` [PATCH for-4.22 2/5] tools/macros: adjust ROUNDUP() " Roger Pau Monne
2026-06-03 15:15   ` Anthony PERARD
2026-06-01 15:43 ` [PATCH for-4.22 3/5] xen/numa: prepare NUMA setup code for unit testing Roger Pau Monne
2026-06-03  8:27   ` Jan Beulich
2026-06-01 15:43 ` [PATCH for-4.22 4/5] tests/numa: add unit tests for NUMA setup logic Roger Pau Monne
2026-06-03  8:38   ` Jan Beulich
2026-06-03 13:45     ` Roger Pau Monné [this message]
2026-06-03 13:54       ` Jan Beulich
2026-06-03 14:07         ` Roger Pau Monné
2026-06-01 15:43 ` [PATCH for-4.22 5/5] xen/numa: fix setup of non-aligned memory affinity ranges Roger Pau Monne
2026-06-01 17:08   ` Andrew Cooper
2026-06-01 17:20     ` Roger Pau Monné
2026-06-02 10:26       ` Jan Beulich
2026-06-03  8:53   ` Jan Beulich
2026-06-03  8:54     ` Jan Beulich
2026-06-03 13:52       ` Roger Pau Monné
2026-06-02  7:23 ` [PATCH for-4.22 0/5] numa: add unit testing plus fix regression Oleksii Kurochko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aiAwDo3EWi1oghm2@macbook.local \
    --to=roger.pau@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=jbeulich@suse.com \
    --cc=oleksii.kurochko@gmail.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.