linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm/mm_init.c: remove obsolete macro HASH_SMALL
@ 2023-06-25  2:13 Miaohe Lin
  2023-06-25  5:06 ` Mike Rapoport
  0 siblings, 1 reply; 2+ messages in thread
From: Miaohe Lin @ 2023-06-25  2:13 UTC (permalink / raw)
  To: akpm, rppt, tglx, mingo
  Cc: peterz, dvhart, dave, andrealmeid, linux-mm, linux-kernel, linmiaohe

HASH_SMALL only works when parameter numentries is 0. But the sole caller
futex_init() never calls alloc_large_system_hash() with numentries set to
0. So HASH_SMALL is obsolete and remove it.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
v2:
  update HASH_ZERO to 0x2 per Mike
---
 include/linux/memblock.h |  4 +---
 kernel/futex/core.c      |  3 +--
 mm/mm_init.c             | 10 +---------
 3 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index f71ff9f0ec81..0d031fbfea25 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -581,9 +581,7 @@ extern void *alloc_large_system_hash(const char *tablename,
 				     unsigned long high_limit);
 
 #define HASH_EARLY	0x00000001	/* Allocating during early boot? */
-#define HASH_SMALL	0x00000002	/* sub-page allocation allowed, min
-					 * shift passed via *_hash_shift */
-#define HASH_ZERO	0x00000004	/* Zero allocated hash table */
+#define HASH_ZERO	0x00000002	/* Zero allocated hash table */
 
 /* Only NUMA needs hash distribution. 64bit NUMA architectures have
  * sufficient vmalloc space.
diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index 514e4582b863..f10587d1d481 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -1132,8 +1132,7 @@ static int __init futex_init(void)
 #endif
 
 	futex_queues = alloc_large_system_hash("futex", sizeof(*futex_queues),
-					       futex_hashsize, 0,
-					       futex_hashsize < 256 ? HASH_SMALL : 0,
+					       futex_hashsize, 0, 0,
 					       &futex_shift, NULL,
 					       futex_hashsize, futex_hashsize);
 	futex_hashsize = 1UL << futex_shift;
diff --git a/mm/mm_init.c b/mm/mm_init.c
index a1963c3322af..999723dee8cc 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -2490,15 +2490,7 @@ void *__init alloc_large_system_hash(const char *tablename,
 		else
 			numentries <<= (PAGE_SHIFT - scale);
 
-		/* Make sure we've got at least a 0-order allocation.. */
-		if (unlikely(flags & HASH_SMALL)) {
-			/* Makes no sense without HASH_EARLY */
-			WARN_ON(!(flags & HASH_EARLY));
-			if (!(numentries >> *_hash_shift)) {
-				numentries = 1UL << *_hash_shift;
-				BUG_ON(!numentries);
-			}
-		} else if (unlikely((numentries * bucketsize) < PAGE_SIZE))
+		if (unlikely((numentries * bucketsize) < PAGE_SIZE))
 			numentries = PAGE_SIZE / bucketsize;
 	}
 	numentries = roundup_pow_of_two(numentries);
-- 
2.27.0



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] mm/mm_init.c: remove obsolete macro HASH_SMALL
  2023-06-25  2:13 [PATCH v2] mm/mm_init.c: remove obsolete macro HASH_SMALL Miaohe Lin
@ 2023-06-25  5:06 ` Mike Rapoport
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Rapoport @ 2023-06-25  5:06 UTC (permalink / raw)
  To: Miaohe Lin
  Cc: akpm, tglx, mingo, peterz, dvhart, dave, andrealmeid, linux-mm,
	linux-kernel

On Sun, Jun 25, 2023 at 10:13:23AM +0800, Miaohe Lin wrote:
> HASH_SMALL only works when parameter numentries is 0. But the sole caller
> futex_init() never calls alloc_large_system_hash() with numentries set to
> 0. So HASH_SMALL is obsolete and remove it.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org>

> ---
> v2:
>   update HASH_ZERO to 0x2 per Mike
> ---
>  include/linux/memblock.h |  4 +---
>  kernel/futex/core.c      |  3 +--
>  mm/mm_init.c             | 10 +---------
>  3 files changed, 3 insertions(+), 14 deletions(-)
> 
> diff --git a/include/linux/memblock.h b/include/linux/memblock.h
> index f71ff9f0ec81..0d031fbfea25 100644
> --- a/include/linux/memblock.h
> +++ b/include/linux/memblock.h
> @@ -581,9 +581,7 @@ extern void *alloc_large_system_hash(const char *tablename,
>  				     unsigned long high_limit);
>  
>  #define HASH_EARLY	0x00000001	/* Allocating during early boot? */
> -#define HASH_SMALL	0x00000002	/* sub-page allocation allowed, min
> -					 * shift passed via *_hash_shift */
> -#define HASH_ZERO	0x00000004	/* Zero allocated hash table */
> +#define HASH_ZERO	0x00000002	/* Zero allocated hash table */
>  
>  /* Only NUMA needs hash distribution. 64bit NUMA architectures have
>   * sufficient vmalloc space.
> diff --git a/kernel/futex/core.c b/kernel/futex/core.c
> index 514e4582b863..f10587d1d481 100644
> --- a/kernel/futex/core.c
> +++ b/kernel/futex/core.c
> @@ -1132,8 +1132,7 @@ static int __init futex_init(void)
>  #endif
>  
>  	futex_queues = alloc_large_system_hash("futex", sizeof(*futex_queues),
> -					       futex_hashsize, 0,
> -					       futex_hashsize < 256 ? HASH_SMALL : 0,
> +					       futex_hashsize, 0, 0,
>  					       &futex_shift, NULL,
>  					       futex_hashsize, futex_hashsize);
>  	futex_hashsize = 1UL << futex_shift;
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index a1963c3322af..999723dee8cc 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -2490,15 +2490,7 @@ void *__init alloc_large_system_hash(const char *tablename,
>  		else
>  			numentries <<= (PAGE_SHIFT - scale);
>  
> -		/* Make sure we've got at least a 0-order allocation.. */
> -		if (unlikely(flags & HASH_SMALL)) {
> -			/* Makes no sense without HASH_EARLY */
> -			WARN_ON(!(flags & HASH_EARLY));
> -			if (!(numentries >> *_hash_shift)) {
> -				numentries = 1UL << *_hash_shift;
> -				BUG_ON(!numentries);
> -			}
> -		} else if (unlikely((numentries * bucketsize) < PAGE_SIZE))
> +		if (unlikely((numentries * bucketsize) < PAGE_SIZE))
>  			numentries = PAGE_SIZE / bucketsize;
>  	}
>  	numentries = roundup_pow_of_two(numentries);
> -- 
> 2.27.0
> 

-- 
Sincerely yours,
Mike.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-25  5:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-25  2:13 [PATCH v2] mm/mm_init.c: remove obsolete macro HASH_SMALL Miaohe Lin
2023-06-25  5:06 ` Mike Rapoport

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox