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

Re: [PATCH v2 3/9] xen/x86: move generically usable NUMA code from x86 to common


  • To: Wei Chen <wei.chen@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 12 Jul 2022 15:13:04 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=ylGWmcAhIhFVUisaiNsJWg9JoeiMyxWeNyKTWs6XXZI=; b=PyHeaBuWERj/NvqxmRLhbPeQlSHGRBaHy5R/TrdHC3E3lQI6n0CLpIBcQimesgzwZWX5E/d1FuVK8ObKZH5FO7zkxDYweQMizCrbjpBnN35yW1uAsnCpT9zDKSfM9T0Szyd/L9uXI2ybGerkHyojqqTUrG+otDfglCzvTU9iQsFCY+s7cV87GKGQO4TMQwuSiLQmWOAfDlToOBgJzv7sHe1YiAj5dvK/SfhJWDchPlVLuvIHbycVAe1IHdFbaIVDqF/rsGGCw9sWk385RosRIk176hgfbdRHL9lSNSZrZPLd6L1VvH/e/39UmBMFNreYVJ4pBICQsmyv3P3PxxC9uA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ychrbz4pRLxrp/F1ZpQLghX4tARWe1GgqsH44HE5uRAUnUOZta+a3VoQh4FVKwYLjg/YkU36THOG/PlMMPTVEre5k15d3cxi7sDZxI0z3N9SMx+1ibABCvBqZ23irLqeMun19bXOR7pyJ+idDjN1ABReLAKK9YywVfNbn72z9LRCnXjtRcuKrfc2bZ52g6BOlNkscmLiYnfUgHtCgKWFUGKYgPTYuItucHF4vde6mQVdsvNmBArkS7CncePL4CeMu1HYnwoMrzNFQYRfn2C5JWaarV5mpGR++m/GHmU9nPvm1vYoh6qb69TuIPg55z/R7OC4bXit85J8jO0hSso4bg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: nd@xxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 12 Jul 2022 13:13:14 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 08.07.2022 16:54, Wei Chen wrote:
> --- /dev/null
> +++ b/xen/common/numa.c
> @@ -0,0 +1,439 @@
> +/*
> + * Generic VM initialization for NUMA setups.
> + * Copyright 2002,2003 Andi Kleen, SuSE Labs.
> + * Adapted for Xen: Ryan Harper <ryanh@xxxxxxxxxx>
> + */
> +
> +#include <xen/init.h>
> +#include <xen/keyhandler.h>
> +#include <xen/mm.h>
> +#include <xen/nodemask.h>
> +#include <xen/numa.h>
> +#include <xen/param.h>
> +#include <xen/sched.h>
> +#include <xen/softirq.h>
> +#include <asm/acpi.h>

Isn't the goal for the now common code to not be dependent upon ACPI?

> +struct node_data node_data[MAX_NUMNODES];
> +
> +/* Mapping from pdx to node id */
> +int memnode_shift;
> +static typeof(*memnodemap) _memnodemap[64];
> +unsigned long memnodemapsize;
> +u8 *memnodemap;

For code moved, please switch to (in this case) uint8_t. I'm on the
edge of asking to go further and
- also use __read_mostly for some / all of these,
- make memnode_shift unsigned int (sadly this looks to require more
  adjustments, even if negative shift counts are meaningless),
- convert from plain int to unsigned int elsewhere as appropriate,
- add const where appropriate / possible.

> +nodeid_t cpu_to_node[NR_CPUS] __read_mostly = {
> +    [0 ... NR_CPUS-1] = NUMA_NO_NODE
> +};
> +
> +cpumask_t node_to_cpumask[MAX_NUMNODES] __read_mostly;

For these two please put __read_mostly into its more conventional
place (right after the type).

> +nodemask_t __read_mostly node_online_map = { { [0] = 1UL } };
> +
> +enum numa_mode numa_status;

This should probably have been __read_mostly already in the earlier
patch introducing it.

> +#ifdef CONFIG_NUMA_EMU
> +static int numa_fake __initdata = 0;

The __initdata again wants to move, and the initializer can be omitted.

> +/* [numa=off] */
> +static int __init cf_check numa_setup(const char *opt)
> +{
> +    if ( !strncmp(opt,"off",3) )

As you're correcting style violations elsewhere, please also insert the
missing spaces here and below.

> --- a/xen/include/xen/numa.h
> +++ b/xen/include/xen/numa.h
> @@ -18,4 +18,78 @@
>    (((d)->vcpu != NULL && (d)->vcpu[0] != NULL) \
>     ? vcpu_to_node((d)->vcpu[0]) : NUMA_NO_NODE)
>  
> +/* The following content can be used when NUMA feature is enabled */
> +#ifdef CONFIG_NUMA
> +
> +extern nodeid_t      cpu_to_node[NR_CPUS];
> +extern cpumask_t     node_to_cpumask[];
> +
> +#define cpu_to_node(cpu)        (cpu_to_node[cpu])
> +#define parent_node(node)       (node)
> +#define node_to_first_cpu(node) (__ffs(node_to_cpumask[node]))
> +#define node_to_cpumask(node)   (node_to_cpumask[node])
> +
> +struct node {
> +    paddr_t start, end;
> +};
> +
> +extern int compute_hash_shift(struct node *nodes, int numnodes,
> +                              nodeid_t *nodeids);
> +
> +#define VIRTUAL_BUG_ON(x)
> +
> +/* Enumerations for NUMA status. */
> +enum numa_mode {
> +    numa_on = 0,
> +    numa_off,
> +    /* NUMA turns on, but ACPI table is bad or disabled. */
> +    numa_no_acpi,
> +    /* NUMA turns on, and ACPI table works well. */
> +    numa_acpi,
> +};
> +
> +extern void numa_add_cpu(int cpu);
> +extern void numa_init_array(void);
> +extern void numa_initmem_init(unsigned long start_pfn, unsigned long 
> end_pfn);
> +extern bool numa_enabled_with_firmware(void);
> +extern enum numa_mode numa_status;
> +
> +extern void numa_set_node(int cpu, nodeid_t node);
> +extern void setup_node_bootmem(nodeid_t nodeid, paddr_t start, paddr_t end);
> +
> +static inline void clear_node_cpumask(int cpu)
> +{
> +    cpumask_clear_cpu(cpu, &node_to_cpumask[cpu_to_node(cpu)]);
> +}
> +
> +/* Simple perfect hash to map pdx to node numbers */
> +extern int memnode_shift;
> +extern unsigned long memnodemapsize;
> +extern u8 *memnodemap;
> +
> +struct node_data {
> +    unsigned long node_start_pfn;
> +    unsigned long node_spanned_pages;
> +};
> +
> +extern struct node_data node_data[];
> +
> +static inline __attribute__((pure)) nodeid_t phys_to_nid(paddr_t addr)

Please use __attribute_pure__.

Jan



 


Rackspace

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