[PATCH] mm/x86: Cleanup unnecessary tsk variable

From: Chih-En Lin
Date: Wed Mar 01 2023 - 22:38:49 EST


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@xxxxxxxxx>
---
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