x86: Unneeded assignment to tsk in recent x86 change
PATCH 1/1 x86: Unneeded assignment to tsk in recent x86 change
Hello!
Impact: Cleanup.
Remove unneeded assignment to tsk in recent x86 change [1].
Patch vs. tip/master.
Uros.
arch/x86/mm/fault.c +1 -3
@@ -421,7 +421,6 @@ static noinline void pgtable_bad(struct pt_regs *regs,printk (KERN_ALERT "%s: Corrupted page table at address %lx\n" , tsk->comm, address);dump_pagetable (address); - tsk = current; tsk->thread.cr2 = address; tsk->thread.trap_no =14 ; tsk->thread.error_code = error_code;
@@ -795,13 +794,12 @@ asmlinkagevoid __kprobes do_page_fault (struct pt_regs *regs,unsigned long error_code) {unsigned long address; -struct task_struct *tsk; +struct task_struct *tsk = current;struct mm_struct *mm;struct vm_area_struct *vma;int write;int fault; - tsk = current; mm = tsk->mm;prefetchw (&mm->mmap_sem);
Quoted 18 lines · Uros Bizjak
Hello!
Impact: Cleanup.
Remove unneeded assignment to tsk in recent x86 change [1].
Signed-off-by Uros Bizjak <[email protected]>Patch vs. tip/master.
Uros.
arch/x86/mm/fault.c +0
-0
arch/x86/mm/fault.c static noinline void pgtable_bad(struct pt_regs *regs, · line 426
Quoted 7 lines
arch/x86/mm/fault.c +0
-1@@ -421,7 +421,6 @@ static noinline void pgtable_bad(struct pt_regs *regs,printk (KERN_ALERT "%s: Corrupted page table at address %lx\n" , tsk->comm, address);dump_pagetable (address); - tsk = current; tsk->thread.cr2 = address; tsk->thread.trap_no =14 ; tsk->thread.error_code = error_code;
this bit is ok, clearly *tsk is valid and == current before the assignment
Quoted 4 lines
arch/x86/mm/fault.c +0
-0@@ -795,13 +794,12 @@ asmlinkagevoid __kprobes do_page_fault (struct pt_regs *regs,unsigned long error_code) {unsigned long address;
arch/x86/mm/fault.c asmlinkage · line 804
Quoted 10 lines
arch/x86/mm/fault.c +1
-2-struct task_struct *tsk; +struct task_struct *tsk = current;struct mm_struct *mm;struct vm_area_struct *vma;int write;int fault; - tsk = current; mm = tsk->mm;prefetchw (&mm->mmap_sem);
but this is neither a fix nor IMO a cleanup (it's inconsistent with the other variables in that function)
Quoted 16 lines · Mikael Pettersson
Quoted 16 lines
Impact: Cleanup.
Remove unneeded assignment to tsk in recent x86 change [1].
arch/x86/mm/fault.c +1
-1@@ -795,13 +794,12 @@ asmlinkagevoid __kprobes do_page_fault (struct pt_regs *regs,unsigned long error_code) {unsigned long address; -struct task_struct *tsk; +struct task_struct *tsk = current;struct mm_struct *mm;struct vm_area_struct *vma;int write;int fault;
Quoted 7 lines
arch/x86/mm/fault.c asmlinkage · line 804
Quoted 3 lines
arch/x86/mm/fault.c +0
-1- tsk = current; mm = tsk->mm;prefetchw (&mm->mmap_sem);but this is neither a fix nor IMO a cleanup (it's inconsistent with the other variables in that function)
Hm, I'm not sure I see the inconsistency here. Care to explain this inconsistency in a couple of words?
Thanks,
Uros.
Quoted 22 lines · Uros Bizjak
Quoted 20 lines · Mikael Pettersson
Quoted 19 lines
Impact: Cleanup.
Remove unneeded assignment to tsk in recent x86 change [1].
arch/x86/mm/fault.c +1
-2@@ -795,13 +794,12 @@ asmlinkagevoid __kprobes do_page_fault (struct pt_regs *regs,unsigned long error_code) {unsigned long address; -struct task_struct *tsk; +struct task_struct *tsk = current;struct mm_struct *mm;struct vm_area_struct *vma;int write;int fault; - tsk = current; mm = tsk->mm;prefetchw (&mm->mmap_sem);
Quoted 6 lines
Quoted 3 lines
but this is neither a fix nor IMO a cleanup (it's inconsistent with the other variables in that function)
Hm, I'm not sure I see the inconsistency here. Care to explain this inconsistency in a couple of words?
You're initialising some variables in their declarations, and some using assignments at the start of the procedure body. In particular, for some reason you don't initialise 'mm' in its declaration even though you could do so for consistency with 'tsk'.
However, I'm strongly in favour of separating declarations and initialisations (esp. ones that need actual computations), so rather than subjecting 'mm' to the treatment you gave 'tsk', just leave the code alone.