On Wed, Feb 21, 2024 at 4:01 PM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote: > > > The quilt patch titled > Subject: x86/mm: clarify "prev" usage in switch_mm_irqs_off() > has been removed from the -mm tree. Its filename was > x86-mm-clarify-prev-usage-in-switch_mm_irqs_off.patch > > This patch was dropped because it was merged into the mm-stable branch > of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm > > ------------------------------------------------------ > From: Yosry Ahmed <yosryahmed@xxxxxxxxxx> > Subject: x86/mm: clarify "prev" usage in switch_mm_irqs_off() > Date: Fri, 26 Jan 2024 08:06:44 +0000 > > In the x86 implementation of switch_mm_irqs_off(), we do not use the > "prev" argument passed in by the caller, we use exclusively use > "real_prev", which is cpu_tlbstate.loaded_mm. This is not obvious at the > first sight. > > Furthermore, a comment describes a condition that happens when called with > prev == next, but this should not affect the function in any way since > prev is unused. Apparently, the comment is intended to clarify why we > don't rely on prev == next to decide whether we need to update CR3, but > again, it is not obvious. The comment also references the fact that > leave_mm() calls with prev == NULL and tsk == NULL, but this also > shouldn't matter because prev is unused and tsk is only used in one > function which has a NULL check. > > Clarify things by renaming (prev -> unused) and (real_prev -> prev), also > move and rewrite the comment as an explanation for why we don't rely on > "prev" supplied by the caller in x86 code and use our own. Hopefully this > makes reading the code easier. I really wished that someone would double check my understanding and make sure I didn't make things worse here in my attempt to clarify them :)