mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mm/x86: Cleanup unnecessary tsk variable
@ 2023-03-02  3:42 Chih-En Lin
  0 siblings, 0 replies; only message in thread
From: Chih-En Lin @ 2023-03-02  3:42 UTC (permalink / raw)
  To: x86, linux-kernel
  Cc: Dave Hansen, Andy Lutomirski, Peter Zijlstra, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, H. Peter Anvin, Chih-En Lin

It's unnecessary to use tsk to access current if tsk is used by one
time only. In such a case, drop variable tsk by using current.

Signed-off-by: Chih-En Lin <shiyn.lin@gmail.com>
---
 arch/x86/mm/fault.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 7b0d4ab894c8..841ccf340ce8 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -605,16 +605,14 @@ static noinline void
 pgtable_bad(struct pt_regs *regs, unsigned long error_code,
 	    unsigned long address)
 {
-	struct task_struct *tsk;
 	unsigned long flags;
 	int sig;
 
 	flags = oops_begin();
-	tsk = current;
 	sig = SIGKILL;
 
 	printk(KERN_ALERT "%s: Corrupted page table at address %lx\n",
-	       tsk->comm, address);
+	       current->comm, address);
 	dump_pagetable(address);
 
 	if (__die("Bad pagetable", regs, error_code))
@@ -831,8 +829,6 @@ static void
 __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
 		       unsigned long address, u32 pkey, int si_code)
 {
-	struct task_struct *tsk = current;
-
 	if (!user_mode(regs)) {
 		kernelmode_fixup_or_oops(regs, error_code, address,
 					 SIGSEGV, si_code, pkey);
@@ -867,7 +863,7 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
 		return;
 
 	if (likely(show_unhandled_signals))
-		show_signal_msg(regs, error_code, address, tsk);
+		show_signal_msg(regs, error_code, address, current);
 
 	set_signal_archinfo(address, error_code);
 
@@ -1253,14 +1249,10 @@ void do_user_addr_fault(struct pt_regs *regs,
 			unsigned long address)
 {
 	struct vm_area_struct *vma;
-	struct task_struct *tsk;
-	struct mm_struct *mm;
+	struct mm_struct *mm = current->mm;
 	vm_fault_t fault;
 	unsigned int flags = FAULT_FLAG_DEFAULT;
 
-	tsk = current;
-	mm = tsk->mm;
-
 	if (unlikely((error_code & (X86_PF_USER | X86_PF_INSTR)) == X86_PF_INSTR)) {
 		/*
 		 * Whoops, this is kernel mode code trying to execute from
-- 
2.39.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-02  3:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-02  3:42 [PATCH] mm/x86: Cleanup unnecessary tsk variable Chih-En Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®