lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 15 Sep 2023 21:03:29 +0800
From:   Baoquan He <bhe@...hat.com>
To:     "Uladzislau Rezki (Sony)" <urezki@...il.com>
Cc:     linux-mm@...ck.org, Andrew Morton <akpm@...ux-foundation.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Lorenzo Stoakes <lstoakes@...il.com>,
        Christoph Hellwig <hch@...radead.org>,
        Matthew Wilcox <willy@...radead.org>,
        "Liam R . Howlett" <Liam.Howlett@...cle.com>,
        Dave Chinner <david@...morbit.com>,
        "Paul E . McKenney" <paulmck@...nel.org>,
        Joel Fernandes <joel@...lfernandes.org>,
        Oleksiy Avramchenko <oleksiy.avramchenko@...y.com>
Subject: Re: [PATCH v2 9/9] mm: vmalloc: Set nr_nodes/node_size based on
 CPU-cores

On 08/29/23 at 10:11am, Uladzislau Rezki (Sony) wrote:
......
> real    1m28.382s
> user    0m0.014s
> sys     0m0.026s
> urezki@...38:~$
> 
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@...il.com>
> ---
>  mm/vmalloc.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)

LGTM,

Reviewed-by: Baoquan He <bhe@...hat.com>

> 
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 9cce012aecdb..08990f630c21 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -796,6 +796,9 @@ struct vmap_node {
>  	atomic_t fill_in_progress;
>  };
>  
> +#define MAX_NODES U8_MAX
> +#define MAX_NODE_SIZE SZ_4M
> +
>  static struct vmap_node *nodes, snode;
>  static __read_mostly unsigned int nr_nodes = 1;
>  static __read_mostly unsigned int node_size = 1;
> @@ -4803,11 +4806,24 @@ static void vmap_init_free_space(void)
>  	}
>  }
>  
> +static unsigned int calculate_nr_nodes(void)
> +{
> +	unsigned int nr_cpus;
> +
> +	nr_cpus = num_present_cpus();
> +	if (nr_cpus <= 1)
> +		nr_cpus = num_possible_cpus();
> +
> +	/* Density factor. Two users per a node. */
> +	return clamp_t(unsigned int, nr_cpus >> 1, 1, MAX_NODES);
> +}
> +
>  static void vmap_init_nodes(void)
>  {
>  	struct vmap_node *vn;
>  	int i;
>  
> +	nr_nodes = calculate_nr_nodes();
>  	nodes = &snode;
>  
>  	if (nr_nodes > 1) {
> @@ -4830,6 +4846,16 @@ static void vmap_init_nodes(void)
>  		INIT_LIST_HEAD(&vn->free.head);
>  		spin_lock_init(&vn->free.lock);
>  	}
> +
> +	/*
> +	 * Scale a node size to number of CPUs. Each power of two
> +	 * value doubles a node size. A high-threshold limit is set
> +	 * to 4M.
> +	 */
> +#if BITS_PER_LONG == 64
> +	if (nr_nodes > 1)
> +		node_size = min(SZ_64K << fls(num_possible_cpus()), SZ_4M);
> +#endif
>  }
>  
>  void __init vmalloc_init(void)
> -- 
> 2.30.2
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ