Subject: Re: linux-next: manual merge of the net-next tree with the mm tree

From: Stephen Rothwell <[email-masked]>
Date: Mon, 29 Apr 2024 12:33:51 +1000

Hi all,

On Mon, 29 Apr 2024 11:43:02 +1000 Stephen Rothwell <[email-masked]> wrote:
>
> Today's linux-next merge of the net-next tree got a conflict in:
> 
>   include/linux/slab.h
> 
> between commit:
> 
>   7bd230a26648 ("mm/slab: enable slab allocation tagging for kmalloc and friends")
> 
> from the mm_unstable branch of the mm tree and commit:
> 
>   a1d6063d9f2f ("slab: introduce kvmalloc_array_node() and kvcalloc_node()")
> 
> from the net-next tree.
> 
> I fixed it up (maybe? see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging.  You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.

I tried again, see below.
-- 
Cheers,
Stephen Rothwell

diff --cc include/linux/slab.h
index 4cc37ef22aae,d1d1fa5e7983..88426b015faa
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@@ -773,40 -744,66 +773,54 @@@ static inline __alloc_size(1, 2) void *
   * @size: how many bytes of memory are required.
   * @flags: the type of memory to allocate (see kmalloc).
   */
 -static inline __alloc_size(1) void *kzalloc(size_t size, gfp_t flags)
 +static inline __alloc_size(1) void *kzalloc_noprof(size_t size, gfp_t flags)
  {
 -	return kmalloc(size, flags | __GFP_ZERO);
 +	return kmalloc_noprof(size, flags | __GFP_ZERO);
  }
 +#define kzalloc(...)				alloc_hooks(kzalloc_noprof(__VA_ARGS__))
 +#define kzalloc_node(_size, _flags, _node)	kmalloc_node(_size, (_flags)|__GFP_ZERO, _node)
  
 -/**
 - * kzalloc_node - allocate zeroed memory from a particular memory node.
 - * @size: how many bytes of memory are required.
 - * @flags: the type of memory to allocate (see kmalloc).
 - * @node: memory node from which to allocate
 - */
 -static inline __alloc_size(1) void *kzalloc_node(size_t size, gfp_t flags, int node)
 -{
 -	return kmalloc_node(size, flags | __GFP_ZERO, node);
 -}
 +extern void *kvmalloc_node_noprof(size_t size, gfp_t flags, int node) __alloc_size(1);
 +#define kvmalloc_node(...)			alloc_hooks(kvmalloc_node_noprof(__VA_ARGS__))
  
 -extern void *kvmalloc_node(size_t size, gfp_t flags, int node) __alloc_size(1);
 -static inline __alloc_size(1) void *kvmalloc(size_t size, gfp_t flags)
 -{
 -	return kvmalloc_node(size, flags, NUMA_NO_NODE);
 -}
 -static inline __alloc_size(1) void *kvzalloc_node(size_t size, gfp_t flags, int node)
 -{
 -	return kvmalloc_node(size, flags | __GFP_ZERO, node);
 -}
 -static inline __alloc_size(1) void *kvzalloc(size_t size, gfp_t flags)
 -{
 -	return kvmalloc(size, flags | __GFP_ZERO);
 -}
 +#define kvmalloc(_size, _flags)			kvmalloc_node(_size, _flags, NUMA_NO_NODE)
 +#define kvmalloc_noprof(_size, _flags)		kvmalloc_node_noprof(_size, _flags, NUMA_NO_NODE)
 +#define kvzalloc(_size, _flags)			kvmalloc(_size, _flags|__GFP_ZERO)
  
 -static inline __alloc_size(1, 2) void *
 -kvmalloc_array_node(size_t n, size_t size, gfp_t flags, int node)
 +#define kvzalloc_node(_size, _flags, _node)	kvmalloc_node(_size, _flags|__GFP_ZERO, _node)
 +
- static inline __alloc_size(1, 2) void *kvmalloc_array_noprof(size_t n, size_t size, gfp_t flags)
++static inline __alloc_size(1, 2) void *kvmalloc_array_node_noprof(size_t n, size_t size, gfp_t flags, int node)
  {
  	size_t bytes;
  
  	if (unlikely(check_mul_overflow(n, size, &bytes)))
  		return NULL;
  
- 	return kvmalloc_node_noprof(bytes, flags, NUMA_NO_NODE);
 -	return kvmalloc_node(bytes, flags, node);
++	return kvmalloc_node_noprof(bytes, flags, node);
+ }
+ 
++#define kvmalloc_array_node(...)	alloc_hooks(kvmalloc_array_node_noprof(__VA_ARGS__))
++
+ static inline __alloc_size(1, 2) void *
+ kvmalloc_array(size_t n, size_t size, gfp_t flags)
+ {
+ 	return kvmalloc_array_node(n, size, flags, NUMA_NO_NODE);
+ }
++#define kvmalloc_array_noprof(_n, _size, _flags)	kvmalloc_array(_n, _size, _flags)
+ 
+ static inline __alloc_size(1, 2) void *
+ kvcalloc_node(size_t n, size_t size, gfp_t flags, int node)
+ {
 -	return kvmalloc_array_node(n, size, flags | __GFP_ZERO, node);
++	return kvmalloc_array_node_noprof(n, size, flags | __GFP_ZERO, node);
  }
  
- #define kvmalloc_array(...)			alloc_hooks(kvmalloc_array_noprof(__VA_ARGS__))
 -static inline __alloc_size(1, 2) void *kvcalloc(size_t n, size_t size, gfp_t flags)
 -{
 -	return kvmalloc_array(n, size, flags | __GFP_ZERO);
 -}
 +#define kvcalloc(_n, _size, _flags)		kvmalloc_array(_n, _size, _flags|__GFP_ZERO)
- #define kvcalloc_noprof(_n, _size, _flags)	kvmalloc_array_noprof(_n, _size, _flags|__GFP_ZERO)
++#define kvcalloc_noprof(_n, _size, _flags)	kvmalloc_array_node_noprof(_n, _size, _flags|__GFP_ZERO)
  
 -extern void *kvrealloc(const void *p, size_t oldsize, size_t newsize, gfp_t flags)
 +extern void *kvrealloc_noprof(const void *p, size_t oldsize, size_t newsize, gfp_t flags)
  		      __realloc_size(3);
 +#define kvrealloc(...)				alloc_hooks(kvrealloc_noprof(__VA_ARGS__))
 +
  extern void kvfree(const void *addr);
  DEFINE_FREE(kvfree, void *, if (_T) kvfree(_T))