Skip to content

Commit 8278cc1

Browse files
committed
parisc: Reduce code size by optimizing get_current() function calls
The get_current() code uses the mfctl() macro to get the pointer to the current task struct from %cr30. The problem with the mfctl() macro is, that it is marked volatile which is basically correct, because mfctl() is used to get e.g. the current internal timer or interrupt flags as well. But specifically the task struct pointer (%cr30) doesn't change over time when the kernel executes code for a task. So, by dropping the volatile when retrieving %cr30 the compiler is now able to get this value only once and optimize the generated code a lot. A bloat-o-meter comparism shows that this patch saves ~5kB kernel code on a 32-bit kernel and ~6kB kernel code on a 64-bit kernel. Signed-off-by: Helge Deller <deller@gmx.de>
1 parent 360bd6c commit 8278cc1

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

arch/parisc/include/asm/current.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
#ifndef _ASM_PARISC_CURRENT_H
33
#define _ASM_PARISC_CURRENT_H
44

5-
#include <asm/special_insns.h>
6-
75
#ifndef __ASSEMBLY__
86
struct task_struct;
97

108
static __always_inline struct task_struct *get_current(void)
119
{
12-
return (struct task_struct *) mfctl(30);
10+
struct task_struct *ts;
11+
12+
/* do not use mfctl() macro as it is marked volatile */
13+
asm( "mfctl %%cr30,%0" : "=r" (ts) );
14+
return ts;
1315
}
1416

1517
#define current get_current()

0 commit comments

Comments
 (0)