Skip to contentSkip to conversation

mm/x86: Cleanup unnecessary tsk variable

PATCH New Chih-En Lin 1 participant 1 message Mar 2, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/x86: Cleanup unnecessary tsk variable

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.

---
 arch/x86/mm/fault.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
arch/x86/mm/fault.c +3 -11
index 7b0d4ab894c8..841ccf340ce8 100644
@@ -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
Signature · 1 line
2.39.1