Message ID | 20170726180252.GA1129@p100.box (mailing list archive) |
---|---|
State | Accepted, archived |
Headers | show |
On 2017-07-26, at 2:02 PM, Helge Deller wrote: > Instead I'd then suggest the patch below. > The if-clause in switch_mm_irqs_off() will then probably be optimized > away by the compiler. > > diff --git a/arch/parisc/include/asm/mmu_context.h b/arch/parisc/include/asm/mmu_context.h > index a812262..e4a6570 100644 > --- a/arch/parisc/include/asm/mmu_context.h > +++ b/arch/parisc/include/asm/mmu_context.h > @@ -63,6 +63,9 @@ static inline void switch_mm(struct mm_struct *prev, > { > unsigned long flags; > > + if (prev == next) > + return; > + > local_irq_save(flags); > switch_mm_irqs_off(prev, next, tsk); > local_irq_restore(flags); You are correct. I missed the fact that switch_mm_irqs_off() is used by kernel/sched/core.c. Maybe we should replace the "switch_mm_irqs_off(prev, next, tsk);" with the mtctl and load_context lines to ensure that the if-clause is optimized? Dave -- John David Anglin dave.anglin@bell.net -- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 26.07.2017 20:49, John David Anglin wrote: > On 2017-07-26, at 2:02 PM, Helge Deller wrote: > >> Instead I'd then suggest the patch below. >> The if-clause in switch_mm_irqs_off() will then probably be optimized >> away by the compiler. >> >> diff --git a/arch/parisc/include/asm/mmu_context.h b/arch/parisc/include/asm/mmu_context.h >> index a812262..e4a6570 100644 >> --- a/arch/parisc/include/asm/mmu_context.h >> +++ b/arch/parisc/include/asm/mmu_context.h >> @@ -63,6 +63,9 @@ static inline void switch_mm(struct mm_struct *prev, >> { >> unsigned long flags; >> >> + if (prev == next) >> + return; >> + >> local_irq_save(flags); >> switch_mm_irqs_off(prev, next, tsk); >> local_irq_restore(flags); > > You are correct. I missed the fact that switch_mm_irqs_off() is used by kernel/sched/core.c. > > Maybe we should replace the "switch_mm_irqs_off(prev, next, tsk);" with the mtctl and load_context > lines to ensure that the if-clause is optimized? I think we should look at the generated assembly, and if it's not optimized away replace it with mtctl/load_context. Helge -- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/arch/parisc/include/asm/mmu_context.h b/arch/parisc/include/asm/mmu_context.h index a812262..e4a6570 100644 --- a/arch/parisc/include/asm/mmu_context.h +++ b/arch/parisc/include/asm/mmu_context.h @@ -63,6 +63,9 @@ static inline void switch_mm(struct mm_struct *prev, { unsigned long flags; + if (prev == next) + return; + local_irq_save(flags); switch_mm_irqs_off(prev, next, tsk); local_irq_restore(flags);