linux-next: manual merge of the akpm-current tree with the userns tree

Stephen Rothwell posted 1 patch 4 years, 6 months ago
linux-next: manual merge of the akpm-current tree with the userns tree
Posted by Stephen Rothwell 4 years, 6 months ago
Hi all,

Today's linux-next merge of the akpm-current tree got conflicts in:

  include/linux/kthread.h
  kernel/kthread.c

between commit:

  40966e316f86 ("kthread: Ensure struct kthread is present for all kthreads")

from the userns tree and commit:

  1ac41b3d9ad8 ("kthread: dynamically allocate memory to store kthread's full name")

from the akpm-current tree.

I fixed it up (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.

-- 
Cheers,
Stephen Rothwell

diff --cc include/linux/kthread.h
index 4f3433afb54b,a1810374eaa9..000000000000
--- a/include/linux/kthread.h
+++ b/include/linux/kthread.h
@@@ -33,7 -33,8 +33,8 @@@ struct task_struct *kthread_create_on_c
  					  unsigned int cpu,
  					  const char *namefmt);
  
+ void get_kthread_comm(char *buf, size_t buf_size, struct task_struct *tsk);
 -void set_kthread_struct(struct task_struct *p);
 +bool set_kthread_struct(struct task_struct *p);
  
  void kthread_set_per_cpu(struct task_struct *k, int cpu);
  bool kthread_is_per_cpu(struct task_struct *k);
diff --cc kernel/kthread.c
index c14707d15341,8be710f2d83d..000000000000
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@@ -94,7 -95,19 +96,19 @@@ static inline struct kthread *__to_kthr
  	return kthread;
  }
  
+ void get_kthread_comm(char *buf, size_t buf_size, struct task_struct *tsk)
+ {
+ 	struct kthread *kthread = to_kthread(tsk);
+ 
+ 	if (!kthread || !kthread->full_name) {
+ 		__get_task_comm(buf, buf_size, tsk);
+ 		return;
+ 	}
+ 
+ 	strscpy_pad(buf, kthread->full_name, buf_size);
+ }
+ 
 -void set_kthread_struct(struct task_struct *p)
 +bool set_kthread_struct(struct task_struct *p)
  {
  	struct kthread *kthread;
  
@@@ -122,13 -128,17 +136,17 @@@ void free_kthread_struct(struct task_st
  	struct kthread *kthread;
  
  	/*
 -	 * Can be NULL if this kthread was created by kernel_thread()
 -	 * or if kmalloc() in kthread() failed.
 +	 * Can be NULL if kmalloc() in set_kthread_struct() failed.
  	 */
  	kthread = to_kthread(k);
+ 	if (!kthread)
+ 		return;
+ 
  #ifdef CONFIG_BLK_CGROUP
- 	WARN_ON_ONCE(kthread && kthread->blkcg_css);
+ 	WARN_ON_ONCE(kthread->blkcg_css);
  #endif
 +	k->set_child_tid = (__force void __user *)NULL;
+ 	kfree(kthread->full_name);
  	kfree(kthread);
  }
  
Re: linux-next: manual merge of the akpm-current tree with the userns tree
Posted by Stephen Rothwell 4 years, 6 months ago
Hi all,

On Tue, 21 Dec 2021 22:07:34 +1100 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Today's linux-next merge of the akpm-current tree got conflicts in:
> 
>   include/linux/kthread.h
>   kernel/kthread.c
> 
> between commit:
> 
>   40966e316f86 ("kthread: Ensure struct kthread is present for all kthreads")
> 
> from the userns tree and commit:
> 
>   1ac41b3d9ad8 ("kthread: dynamically allocate memory to store kthread's full name")
> 
> from the akpm-current tree.

With the addition of commit

  329b30af470a ("kthread: Generalize pf_io_worker so it can point to struct kthread")

to the userns tree, the resolution is now as below.

-- 
Cheers,
Stephen Rothwell

diff --cc kernel/kthread.c
index 261a3c3b9c6c,8be710f2d83d..000000000000
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@@ -94,7 -95,19 +96,19 @@@ static inline struct kthread *__to_kthr
  	return kthread;
  }
  
+ void get_kthread_comm(char *buf, size_t buf_size, struct task_struct *tsk)
+ {
+ 	struct kthread *kthread = to_kthread(tsk);
+ 
+ 	if (!kthread || !kthread->full_name) {
+ 		__get_task_comm(buf, buf_size, tsk);
+ 		return;
+ 	}
+ 
+ 	strscpy_pad(buf, kthread->full_name, buf_size);
+ }
+ 
 -void set_kthread_struct(struct task_struct *p)
 +bool set_kthread_struct(struct task_struct *p)
  {
  	struct kthread *kthread;
  
@@@ -118,13 -128,17 +132,17 @@@ void free_kthread_struct(struct task_st
  	struct kthread *kthread;
  
  	/*
 -	 * Can be NULL if this kthread was created by kernel_thread()
 -	 * or if kmalloc() in kthread() failed.
 +	 * Can be NULL if kmalloc() in set_kthread_struct() failed.
  	 */
  	kthread = to_kthread(k);
+ 	if (!kthread)
+ 		return;
+ 
  #ifdef CONFIG_BLK_CGROUP
- 	WARN_ON_ONCE(kthread && kthread->blkcg_css);
+ 	WARN_ON_ONCE(kthread->blkcg_css);
  #endif
 +	k->worker_private = NULL;
+ 	kfree(kthread->full_name);
  	kfree(kthread);
  }