* [PATCH mm-stable 1/2] x86/mm: further clarify switch_mm_irqs_off() documentation
@ 2024-02-22 19:09 Yosry Ahmed
2024-02-22 19:09 ` [PATCH mm-stable 2/2] x86/mm: always pass NULL as the first argument of switch_mm_irqs_off() Yosry Ahmed
2024-02-22 19:11 ` [PATCH mm-stable 1/2] x86/mm: further clarify switch_mm_irqs_off() documentation Dave Hansen
0 siblings, 2 replies; 4+ messages in thread
From: Yosry Ahmed @ 2024-02-22 19:09 UTC (permalink / raw)
To: Andrew Morton
Cc: Dave Hansen, Ingo Molnar, Thomas Gleixner, Borislav Petkov,
Dave Hansen, Andy Lutomirski, Peter Zijlstra, x86, linux-mm,
linux-kernel, Yosry Ahmed
Commit accf6b23d1e5a ("x86/mm: clarify "prev" usage in
switch_mm_irqs_off()") attempted to clarify x86's usage of the arguments
passed by generic code, specifically the "prev" argument the is unused
by x86. However, it could have done a better job with the comment above
switch_mm_irqs_off(). Rewrite this comment according to Dave Hansen's
suggestion.
Fixes: accf6b23d1e5 ("x86/mm: clarify "prev" usage in switch_mm_irqs_off()")
Suggested-by: Dave Hansen <dave.hansen@intel.com>
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
---
arch/x86/mm/tlb.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index bf9605caf24f7..b67545baf6973 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -493,10 +493,10 @@ static inline void cr4_update_pce_mm(struct mm_struct *mm) { }
#endif
/*
- * The "prev" argument passed by the caller does not always match CR3. For
- * example, the scheduler passes in active_mm when switching from lazy TLB mode
- * to normal mode, but switch_mm_irqs_off() can be called from x86 code without
- * updating active_mm. Use cpu_tlbstate.loaded_mm instead.
+ * This optimizes when not actually switching mm's. Some architectures use the
+ * 'unused' argument for this optimization, but x86 must use
+ * 'cpu_tlbstate.loaded_mm' instead because it does not always keep
+ * 'current->active_mm' up to date.
*/
void switch_mm_irqs_off(struct mm_struct *unused, struct mm_struct *next,
struct task_struct *tsk)
--
2.44.0.rc1.240.g4c46232300-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH mm-stable 2/2] x86/mm: always pass NULL as the first argument of switch_mm_irqs_off()
2024-02-22 19:09 [PATCH mm-stable 1/2] x86/mm: further clarify switch_mm_irqs_off() documentation Yosry Ahmed
@ 2024-02-22 19:09 ` Yosry Ahmed
2024-02-22 19:12 ` Dave Hansen
2024-02-22 19:11 ` [PATCH mm-stable 1/2] x86/mm: further clarify switch_mm_irqs_off() documentation Dave Hansen
1 sibling, 1 reply; 4+ messages in thread
From: Yosry Ahmed @ 2024-02-22 19:09 UTC (permalink / raw)
To: Andrew Morton
Cc: Dave Hansen, Ingo Molnar, Thomas Gleixner, Borislav Petkov,
Dave Hansen, Andy Lutomirski, Peter Zijlstra, x86, linux-mm,
linux-kernel, Yosry Ahmed
The first argument of switch_mm_irqs_off() is unused by the x86
implementation. Make sure that x86 code never passes a non-NULL value to
make this clear. Update the only non violating caller, switch_mm().
Suggested-by: Dave Hansen <dave.hansen@intel.com>
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
---
arch/x86/mm/tlb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index b67545baf6973..51f9f56941058 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -327,7 +327,7 @@ void switch_mm(struct mm_struct *prev, struct mm_struct *next,
unsigned long flags;
local_irq_save(flags);
- switch_mm_irqs_off(prev, next, tsk);
+ switch_mm_irqs_off(NULL, next, tsk);
local_irq_restore(flags);
}
--
2.44.0.rc1.240.g4c46232300-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH mm-stable 1/2] x86/mm: further clarify switch_mm_irqs_off() documentation
2024-02-22 19:09 [PATCH mm-stable 1/2] x86/mm: further clarify switch_mm_irqs_off() documentation Yosry Ahmed
2024-02-22 19:09 ` [PATCH mm-stable 2/2] x86/mm: always pass NULL as the first argument of switch_mm_irqs_off() Yosry Ahmed
@ 2024-02-22 19:11 ` Dave Hansen
1 sibling, 0 replies; 4+ messages in thread
From: Dave Hansen @ 2024-02-22 19:11 UTC (permalink / raw)
To: Yosry Ahmed, Andrew Morton
Cc: Ingo Molnar, Thomas Gleixner, Borislav Petkov, Dave Hansen,
Andy Lutomirski, Peter Zijlstra, x86, linux-mm, linux-kernel
On 2/22/24 11:09, Yosry Ahmed wrote:
> Commit accf6b23d1e5a ("x86/mm: clarify "prev" usage in
> switch_mm_irqs_off()") attempted to clarify x86's usage of the arguments
> passed by generic code, specifically the "prev" argument the is unused
> by x86. However, it could have done a better job with the comment above
> switch_mm_irqs_off(). Rewrite this comment according to Dave Hansen's
> suggestion.
Looks good, thanks for sending this!
Acked-by: Dave Hansen <dave.hansen@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH mm-stable 2/2] x86/mm: always pass NULL as the first argument of switch_mm_irqs_off()
2024-02-22 19:09 ` [PATCH mm-stable 2/2] x86/mm: always pass NULL as the first argument of switch_mm_irqs_off() Yosry Ahmed
@ 2024-02-22 19:12 ` Dave Hansen
0 siblings, 0 replies; 4+ messages in thread
From: Dave Hansen @ 2024-02-22 19:12 UTC (permalink / raw)
To: Yosry Ahmed, Andrew Morton
Cc: Ingo Molnar, Thomas Gleixner, Borislav Petkov, Dave Hansen,
Andy Lutomirski, Peter Zijlstra, x86, linux-mm, linux-kernel
On 2/22/24 11:09, Yosry Ahmed wrote:
> The first argument of switch_mm_irqs_off() is unused by the x86
> implementation. Make sure that x86 code never passes a non-NULL value to
> make this clear. Update the only non violating caller, switch_mm().
Acked-by: Dave Hansen <dave.hansen@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-02-22 19:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-22 19:09 [PATCH mm-stable 1/2] x86/mm: further clarify switch_mm_irqs_off() documentation Yosry Ahmed
2024-02-22 19:09 ` [PATCH mm-stable 2/2] x86/mm: always pass NULL as the first argument of switch_mm_irqs_off() Yosry Ahmed
2024-02-22 19:12 ` Dave Hansen
2024-02-22 19:11 ` [PATCH mm-stable 1/2] x86/mm: further clarify switch_mm_irqs_off() documentation Dave Hansen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.