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

From: Stephen Rothwell <[email-masked]>
Date: Fri, 24 Dec 2021 18:45:20 +1100

Hi all,

On Tue, 21 Dec 2021 22:07:34 +1100 Stephen Rothwell <[email-masked]> 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);
  }