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

From: Stephen Rothwell <[email-masked]>
Date: Thu, 7 Oct 2021 17:27:13 +1100

Hi all,

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

  include/linux/sched/mm.h
  kernel/sched/core.c

between commit:

  8d491de6edc2 ("sched: Move mmdrop to RCU on RT")

from the tip tree and commits:

  5a21ba83ddb2 ("lazy tlb: introduce lazy mm refcount helper functions")
  ade2ef2cb563 ("lazy tlb: allow lazy tlb mm refcounting to be configurable")

from the akpm-current tree.

I don't know if my merging of both these makes sense, but guidance
is welcome.

I fixed it up (see below, and used the latter version of kernel/sched/core.c
) 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/sched/mm.h
index aca874d33fe6,fd6e4d14f477..000000000000
--- a/include/linux/sched/mm.h
+++ b/include/linux/sched/mm.h
@@@ -49,35 -49,27 +49,56 @@@ static inline void mmdrop(struct mm_str
  		__mmdrop(mm);
  }
  
 +#ifdef CONFIG_PREEMPT_RT
 +/*
 + * RCU callback for delayed mm drop. Not strictly RCU, but call_rcu() is
 + * by far the least expensive way to do that.
 + */
 +static inline void __mmdrop_delayed(struct rcu_head *rhp)
 +{
 +	struct mm_struct *mm = container_of(rhp, struct mm_struct, delayed_drop);
 +
 +	__mmdrop(mm);
 +}
 +
 +/*
 + * Invoked from finish_task_switch(). Delegates the heavy lifting on RT
 + * kernels via RCU.
 + */
 +static inline void mmdrop_sched(struct mm_struct *mm)
 +{
 +	/* Provides a full memory barrier. See mmdrop() */
 +	if (atomic_dec_and_test(&mm->mm_count))
 +		call_rcu(&mm->delayed_drop, __mmdrop_delayed);
 +}
 +#else
 +static inline void mmdrop_sched(struct mm_struct *mm)
 +{
 +	mmdrop(mm);
 +}
 +#endif
 +
+ /* Helpers for lazy TLB mm refcounting */
+ static inline void mmgrab_lazy_tlb(struct mm_struct *mm)
+ {
+ 	if (IS_ENABLED(CONFIG_MMU_LAZY_TLB_REFCOUNT))
+ 		mmgrab(mm);
+ }
+ 
+ static inline void mmdrop_lazy_tlb(struct mm_struct *mm)
+ {
+ 	if (IS_ENABLED(CONFIG_MMU_LAZY_TLB_REFCOUNT)) {
 -		mmdrop(mm);
++		mmdrop_sched(mm);
+ 	} else {
+ 		/*
+ 		 * mmdrop_lazy_tlb must provide a full memory barrier, see the
+ 		 * membarrier comment in finish_task_switch which relies on
+ 		 * this.
+ 		 */
+ 		smp_mb();
+ 	}
+ }
+ 
  /**
   * mmget() - Pin the address space associated with a &struct mm_struct.
   * @mm: The address space to pin.