This patchset makes the macro get_personality function alike
and teaches code to use get_personality() instead of explicit
reference.
[I am sorry if you've received multiple copied of this, since
my git-send-email doesn't work well. ]
Signed-off-by: WANG Cong <[email protected]>
This patch makes the macro get_personality function-like.
Signed-off-by: WANG Cong <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Bryan Wu <[email protected]>
Cc: David Howells <[email protected]>
---
arch/blackfin/kernel/signal.c | 2 +-
arch/frv/kernel/signal.c | 4 ++--
include/linux/personality.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/blackfin/kernel/signal.c b/arch/blackfin/kernel/signal.c
index 5564c95..f3ef4ee 100644
--- a/arch/blackfin/kernel/signal.c
+++ b/arch/blackfin/kernel/signal.c
@@ -224,7 +224,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t * info,
/* Set up registers for signal handler */
wrusp((unsigned long)frame);
- if (get_personality & FDPIC_FUNCPTRS) {
+ if (get_personality() & FDPIC_FUNCPTRS) {
struct fdpic_func_descriptor __user *funcptr =
(struct fdpic_func_descriptor *) ka->sa.sa_handler;
__get_user(regs->pc, &funcptr->text);
diff --git a/arch/frv/kernel/signal.c b/arch/frv/kernel/signal.c
index d64bcaf..7e4405d 100644
--- a/arch/frv/kernel/signal.c
+++ b/arch/frv/kernel/signal.c
@@ -297,7 +297,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set)
__frame->lr = (unsigned long) &frame->retcode;
__frame->gr8 = sig;
- if (get_personality & FDPIC_FUNCPTRS) {
+ if (get_personality() & FDPIC_FUNCPTRS) {
struct fdpic_func_descriptor __user *funcptr =
(struct fdpic_func_descriptor __user *) ka->sa.sa_handler;
__get_user(__frame->pc, &funcptr->text);
@@ -396,7 +396,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
__frame->gr8 = sig;
__frame->gr9 = (unsigned long) &frame->info;
- if (get_personality & FDPIC_FUNCPTRS) {
+ if (get_personality() & FDPIC_FUNCPTRS) {
struct fdpic_func_descriptor __user *funcptr =
(struct fdpic_func_descriptor __user *) ka->sa.sa_handler;
__get_user(__frame->pc, &funcptr->text);
diff --git a/include/linux/personality.h b/include/linux/personality.h
index 012cd55..1891b31 100644
--- a/include/linux/personality.h
+++ b/include/linux/personality.h
@@ -108,7 +108,7 @@ struct exec_domain {
/*
* Personality of the currently running process.
*/
-#define get_personality (current->personality)
+#define get_personality() (current->personality)
/*
* Change personality of the currently running process.
--
1.5.3.8
Use get_personality() macro instead of explicit reference
for mm/ code.
Signed-off-by: WANG Cong <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Christoph Lameter <[email protected]>
---
mm/mmap.c | 2 +-
mm/mprotect.c | 2 +-
mm/nommu.c | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index a32d28c..42d647f 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -910,7 +910,7 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
* (the exception is when the underlying filesystem is noexec
* mounted, in which case we dont add PROT_EXEC.)
*/
- if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
+ if ((prot & PROT_READ) && (get_personality() & READ_IMPLIES_EXEC))
if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
prot |= PROT_EXEC;
diff --git a/mm/mprotect.c b/mm/mprotect.c
index 4de5468..620b8db 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -237,7 +237,7 @@ sys_mprotect(unsigned long start, size_t len, unsigned long prot)
/*
* Does the application expect PROT_READ to imply PROT_EXEC:
*/
- if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
+ if ((prot & PROT_READ) && (get_personality() & READ_IMPLIES_EXEC))
prot |= PROT_EXEC;
vm_flags = calc_vm_prot_bits(prot);
diff --git a/mm/nommu.c b/mm/nommu.c
index 5d8ae08..a1c6162 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -665,7 +665,7 @@ static int validate_mmap_request(struct file *file,
}
else if ((prot & PROT_READ) && !(prot & PROT_EXEC)) {
/* handle implication of PROT_EXEC by PROT_READ */
- if (current->personality & READ_IMPLIES_EXEC) {
+ if (get_personality() & READ_IMPLIES_EXEC) {
if (capabilities & BDI_CAP_EXEC_MAP)
prot |= PROT_EXEC;
}
@@ -686,7 +686,7 @@ static int validate_mmap_request(struct file *file,
/* handle PROT_EXEC implication by PROT_READ */
if ((prot & PROT_READ) &&
- (current->personality & READ_IMPLIES_EXEC))
+ (get_personality() & READ_IMPLIES_EXEC))
prot |= PROT_EXEC;
}
--
1.5.3.8
Use get_personality() macro instead of explicit reference.
Signed-off-by: WANG Cong <[email protected]>
Cc: Alexander Viro <[email protected]>
---
fs/binfmt_elf.c | 6 +++---
fs/compat.c | 6 +++---
fs/select.c | 6 +++---
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 41a958a..1b5803f 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -516,7 +516,7 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
unsigned int random_variable = 0;
if ((current->flags & PF_RANDOMIZE) &&
- !(current->personality & ADDR_NO_RANDOMIZE)) {
+ !(get_personality() & ADDR_NO_RANDOMIZE)) {
random_variable = get_random_int() & STACK_RND_MASK;
random_variable <<= PAGE_SHIFT;
}
@@ -744,7 +744,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
if (elf_read_implies_exec(loc->elf_ex, executable_stack))
current->personality |= READ_IMPLIES_EXEC;
- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
+ if (!(get_personality() & ADDR_NO_RANDOMIZE) && randomize_va_space)
current->flags |= PF_RANDOMIZE;
arch_pick_mmap_layout(current->mm);
@@ -969,7 +969,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
arch_randomize_brk(current->mm);
#endif
- if (current->personality & MMAP_PAGE_ZERO) {
+ if (get_personality() & MMAP_PAGE_ZERO) {
/* Why this, you ask??? Well SVr4 maps page 0 as read-only,
and some applications "depend" upon this behavior.
Since we do not have the power to recompile these, we
diff --git a/fs/compat.c b/fs/compat.c
index 2ce4456..eefe23b 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1610,7 +1610,7 @@ asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
if (tvp) {
struct compat_timeval rtv;
- if (current->personality & STICKY_TIMEOUTS)
+ if (get_personality() & STICKY_TIMEOUTS)
goto sticky;
rtv.tv_usec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ));
rtv.tv_sec = timeout;
@@ -1685,7 +1685,7 @@ asmlinkage long compat_sys_pselect7(int n, compat_ulong_t __user *inp,
if (tsp) {
struct compat_timespec rts;
- if (current->personality & STICKY_TIMEOUTS)
+ if (get_personality() & STICKY_TIMEOUTS)
goto sticky;
rts.tv_sec = timeout / HZ;
@@ -1800,7 +1800,7 @@ asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
if (tsp && timeout >= 0) {
struct compat_timespec rts;
- if (current->personality & STICKY_TIMEOUTS)
+ if (get_personality() & STICKY_TIMEOUTS)
goto sticky;
/* Yes, we know it's actually an s64, but it's also positive. */
rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) *
diff --git a/fs/select.c b/fs/select.c
index 5633fe9..6041e24 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -401,7 +401,7 @@ asmlinkage long sys_select(int n, fd_set __user *inp, fd_set __user *outp,
if (tvp) {
struct timeval rtv;
- if (current->personality & STICKY_TIMEOUTS)
+ if (get_personality() & STICKY_TIMEOUTS)
goto sticky;
rtv.tv_usec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ));
rtv.tv_sec = timeout;
@@ -467,7 +467,7 @@ asmlinkage long sys_pselect7(int n, fd_set __user *inp, fd_set __user *outp,
if (tsp) {
struct timespec rts;
- if (current->personality & STICKY_TIMEOUTS)
+ if (get_personality() & STICKY_TIMEOUTS)
goto sticky;
rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) *
1000;
@@ -814,7 +814,7 @@ asmlinkage long sys_ppoll(struct pollfd __user *ufds, unsigned int nfds,
if (tsp && timeout >= 0) {
struct timespec rts;
- if (current->personality & STICKY_TIMEOUTS)
+ if (get_personality() & STICKY_TIMEOUTS)
goto sticky;
/* Yes, we know it's actually an s64, but it's also positive. */
rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) *
--
1.5.3.8
Use get_personality() macro instead of explicit reference
for powerpc code.
Signed-off-by: WANG Cong <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Paul Mackerras <[email protected]>
---
arch/powerpc/kernel/syscalls.c | 4 ++--
arch/powerpc/mm/mmap.c | 2 +-
include/asm-powerpc/elf.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
index 3b1d5dd..4b910b8 100644
--- a/arch/powerpc/kernel/syscalls.c
+++ b/arch/powerpc/kernel/syscalls.c
@@ -228,7 +228,7 @@ long ppc64_personality(unsigned long personality)
{
long ret;
- if (personality(current->personality) == PER_LINUX32
+ if (personality(get_personality()) == PER_LINUX32
&& personality == PER_LINUX)
personality = PER_LINUX32;
ret = sys_personality(personality);
@@ -239,7 +239,7 @@ long ppc64_personality(unsigned long personality)
#endif
#ifdef CONFIG_PPC64
-#define OVERRIDE_MACHINE (personality(current->personality) == PER_LINUX32)
+#define OVERRIDE_MACHINE (personality(get_personality()) == PER_LINUX32)
#else
#define OVERRIDE_MACHINE 0
#endif
diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
index 86010fc..92a9e45 100644
--- a/arch/powerpc/mm/mmap.c
+++ b/arch/powerpc/mm/mmap.c
@@ -54,7 +54,7 @@ static inline int mmap_is_legacy(void)
if (!test_thread_flag(TIF_32BIT))
return 1;
- if (current->personality & ADDR_COMPAT_LAYOUT)
+ if (get_personality() & ADDR_COMPAT_LAYOUT)
return 1;
if (current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY)
diff --git a/include/asm-powerpc/elf.h b/include/asm-powerpc/elf.h
index 9080d85..d9e7bff 100644
--- a/include/asm-powerpc/elf.h
+++ b/include/asm-powerpc/elf.h
@@ -256,7 +256,7 @@ do { \
set_thread_flag(TIF_ABI_PENDING); \
else \
clear_thread_flag(TIF_ABI_PENDING); \
- if (personality(current->personality) != PER_LINUX32) \
+ if (personality(get_personality()) != PER_LINUX32) \
set_personality(PER_LINUX); \
} while (0)
/*
--
1.5.3.8
Use get_personality() macro instead of explicit reference
for parisc code.
Signed-off-by: WANG Cong <[email protected]>
Cc: Kyle McMartin <[email protected]>
Cc: Matthew Wilcox <[email protected]>
---
arch/parisc/kernel/sys_parisc.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index 4f58921..1515ced 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -259,7 +259,7 @@ long parisc_personality(unsigned long personality)
{
long err;
- if (personality(current->personality) == PER_LINUX32
+ if (personality(get_personality()) == PER_LINUX32
&& personality == PER_LINUX)
personality = PER_LINUX32;
@@ -275,7 +275,7 @@ long parisc_newuname(struct new_utsname __user *name)
int err = sys_newuname(name);
#ifdef CONFIG_COMPAT
- if (!err && personality(current->personality) == PER_LINUX32) {
+ if (!err && personality(get_personality()) == PER_LINUX32) {
if (__put_user(0, name->machine + 6) ||
__put_user(0, name->machine + 7))
err = -EFAULT;
--
1.5.3.8
Use get_personality() macro and other two tiny improvements.
Signed-off-by: WANG Cong <[email protected]>
Cc: David Miller <[email protected]>
Cc: William L. Irwin <[email protected]>
Cc: [email protected]
---
arch/sparc/kernel/signal.c | 2 +-
arch/sparc64/kernel/signal32.c | 2 +-
arch/sparc64/kernel/sys_sparc.c | 6 +++---
include/asm-sparc/namei.h | 2 +-
include/asm-sparc64/elf.h | 2 +-
include/asm-sparc64/namei.h | 2 +-
6 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/sparc/kernel/signal.c b/arch/sparc/kernel/signal.c
index 9994cac..0464874 100644
--- a/arch/sparc/kernel/signal.c
+++ b/arch/sparc/kernel/signal.c
@@ -1010,7 +1010,7 @@ asmlinkage void do_signal(struct pt_regs * regs, unsigned long orig_i0, int rest
#ifdef SVR4_SIGNAL_BROKEN
int svr4_signal = 0;
#else
- int svr4_signal = current->personality == PER_SVR4;
+ int svr4_signal = (get_personality() == PER_SVR4);
#endif
cookie.restart_syscall = restart_syscall;
diff --git a/arch/sparc64/kernel/signal32.c b/arch/sparc64/kernel/signal32.c
index 8c1c121..e3bc993 100644
--- a/arch/sparc64/kernel/signal32.c
+++ b/arch/sparc64/kernel/signal32.c
@@ -1270,7 +1270,7 @@ void do_signal32(sigset_t *oldset, struct pt_regs * regs,
struct signal_deliver_cookie cookie;
struct k_sigaction ka;
int signr;
- int svr4_signal = current->personality == PER_SVR4;
+ int svr4_signal = (get_personality() == PER_SVR4);
cookie.restart_syscall = restart_syscall;
cookie.orig_i0 = orig_i0;
diff --git a/arch/sparc64/kernel/sys_sparc.c b/arch/sparc64/kernel/sys_sparc.c
index 134d801..3813ec7 100644
--- a/arch/sparc64/kernel/sys_sparc.c
+++ b/arch/sparc64/kernel/sys_sparc.c
@@ -372,7 +372,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
* bit is set, or if the expected stack growth is unlimited:
*/
if (!test_thread_flag(TIF_32BIT) ||
- (current->personality & ADDR_COMPAT_LAYOUT) ||
+ (get_personality() & ADDR_COMPAT_LAYOUT) ||
current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY ||
sysctl_legacy_va_layout) {
mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
@@ -518,7 +518,7 @@ asmlinkage long sparc64_newuname(struct new_utsname __user *name)
{
int ret = sys_newuname(name);
- if (current->personality == PER_LINUX32 && !ret) {
+ if (get_personality() == PER_LINUX32 && !ret) {
ret = (copy_to_user(name->machine, "sparc\0\0", 8)
? -EFAULT : 0);
}
@@ -529,7 +529,7 @@ asmlinkage long sparc64_personality(unsigned long personality)
{
int ret;
- if (current->personality == PER_LINUX32 &&
+ if (get_personality() == PER_LINUX32 &&
personality == PER_LINUX)
personality = PER_LINUX32;
ret = sys_personality(personality);
diff --git a/include/asm-sparc/namei.h b/include/asm-sparc/namei.h
index f2461e8..b87f621 100644
--- a/include/asm-sparc/namei.h
+++ b/include/asm-sparc/namei.h
@@ -13,7 +13,7 @@
static inline char * __emul_prefix(void)
{
- switch (current->personality) {
+ switch (get_personality()) {
case PER_SUNOS:
return SPARC_BSD_EMUL;
case PER_SVR4:
diff --git a/include/asm-sparc64/elf.h b/include/asm-sparc64/elf.h
index 11c8e68..2140dbe 100644
--- a/include/asm-sparc64/elf.h
+++ b/include/asm-sparc64/elf.h
@@ -211,7 +211,7 @@ do { unsigned long new_flags = current_thread_info()->flags; \
/* flush_thread will update pgd cache */ \
if (ibcs2) \
set_personality(PER_SVR4); \
- else if (current->personality != PER_LINUX32) \
+ else if (get_personality() != PER_LINUX32) \
set_personality(PER_LINUX); \
} while (0)
diff --git a/include/asm-sparc64/namei.h b/include/asm-sparc64/namei.h
index ccda19e..e6a1dd9 100644
--- a/include/asm-sparc64/namei.h
+++ b/include/asm-sparc64/namei.h
@@ -13,7 +13,7 @@
static inline char * __emul_prefix(void)
{
- switch (current->personality) {
+ switch (get_personality()) {
case PER_SUNOS:
return SPARC_BSD_EMUL;
case PER_SVR4:
--
1.5.3.8
Use get_personality() macro instead of explicit reference
for arm code.
Signed-off-by: WANG Cong <[email protected]>
Cc: Russell King <[email protected]>
---
arch/arm/kernel/traps.c | 4 ++--
include/asm-arm/namei.h | 2 +-
include/asm-arm/processor.h | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 5595fdd..975faaf 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -381,8 +381,8 @@ static int bad_syscall(int n, struct pt_regs *regs)
struct thread_info *thread = current_thread_info();
siginfo_t info;
- if (current->personality != PER_LINUX &&
- current->personality != PER_LINUX_32BIT &&
+ if (get_personality() != PER_LINUX &&
+ get_personality() != PER_LINUX_32BIT &&
thread->exec_domain->handler) {
thread->exec_domain->handler(n, regs);
return regs->ARM_r0;
diff --git a/include/asm-arm/namei.h b/include/asm-arm/namei.h
index a402d3b..c55dc87 100644
--- a/include/asm-arm/namei.h
+++ b/include/asm-arm/namei.h
@@ -14,7 +14,7 @@
static inline char *__emul_prefix(void)
{
- switch (current->personality) {
+ switch (get_personality()) {
case PER_BSD:
return ARM_BSD_EMUL;
default:
diff --git a/include/asm-arm/processor.h b/include/asm-arm/processor.h
index bd8029e..7f040b4 100644
--- a/include/asm-arm/processor.h
+++ b/include/asm-arm/processor.h
@@ -23,7 +23,7 @@
#include <asm/types.h>
#ifdef __KERNEL__
-#define STACK_TOP ((current->personality == PER_LINUX_32BIT) ? \
+#define STACK_TOP ((get_personality() == PER_LINUX_32BIT) ? \
TASK_SIZE : TASK_SIZE_26)
#define STACK_TOP_MAX TASK_SIZE
#endif
@@ -65,7 +65,7 @@ struct thread_struct {
unsigned long *stack = (unsigned long *)sp; \
set_fs(USER_DS); \
memzero(regs->uregs, sizeof(regs->uregs)); \
- if (current->personality & ADDR_LIMIT_32BIT) \
+ if (get_personality() & ADDR_LIMIT_32BIT) \
regs->ARM_cpsr = USR_MODE; \
else \
regs->ARM_cpsr = USR26_MODE; \
--
1.5.3.8
Use get_personality() macro instead of explicit reference
for x86 code.
Signed-off-by: WANG Cong <[email protected]>
Cc: Ingo Molnar <[email protected]>
---
arch/x86/ia32/sys_ia32.c | 6 +++---
arch/x86/kernel/process_32.c | 2 +-
arch/x86/kernel/process_64.c | 2 +-
arch/x86/kernel/sys_x86_64.c | 2 +-
arch/x86/mm/mmap.c | 2 +-
include/asm-x86/page.h | 2 +-
include/asm-x86/processor.h | 2 +-
7 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
index abf71d2..80e7431 100644
--- a/arch/x86/ia32/sys_ia32.c
+++ b/arch/x86/ia32/sys_ia32.c
@@ -666,7 +666,7 @@ asmlinkage long sys32_personality(unsigned long personality)
{
int ret;
- if (personality(current->personality) == PER_LINUX32 &&
+ if (personality(get_personality()) == PER_LINUX32 &&
personality == PER_LINUX)
personality = PER_LINUX32;
ret = sys_personality(personality);
@@ -744,7 +744,7 @@ asmlinkage long sys32_olduname(struct oldold_utsname __user *name)
__OLD_UTS_LEN);
err |= __put_user(0, name->version+__OLD_UTS_LEN);
- if (personality(current->personality) == PER_LINUX32)
+ if (personality(get_personality()) == PER_LINUX32)
arch = "i686";
err |= __copy_to_user(&name->machine, arch, strlen(arch) + 1);
@@ -765,7 +765,7 @@ long sys32_uname(struct old_utsname __user *name)
down_read(&uts_sem);
err = copy_to_user(name, utsname(), sizeof(*name));
up_read(&uts_sem);
- if (personality(current->personality) == PER_LINUX32)
+ if (personality(get_personality()) == PER_LINUX32)
err |= copy_to_user(&name->machine, "i686", 5);
return err ? -EFAULT : 0;
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index a7d50a5..c4992fc 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -837,7 +837,7 @@ unsigned long get_wchan(struct task_struct *p)
unsigned long arch_align_stack(unsigned long sp)
{
- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
+ if (!(get_personality() & ADDR_NO_RANDOMIZE) && randomize_va_space)
sp -= get_random_int() % 8192;
return sp & ~0xf;
}
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index b0cc8f0..8223f3f 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -915,7 +915,7 @@ long sys_arch_prctl(int code, unsigned long addr)
unsigned long arch_align_stack(unsigned long sp)
{
- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
+ if (!(get_personality() & ADDR_NO_RANDOMIZE) && randomize_va_space)
sp -= get_random_int() % 8192;
return sp & ~0xf;
}
diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
index bd802a5..0b7548b 100644
--- a/arch/x86/kernel/sys_x86_64.c
+++ b/arch/x86/kernel/sys_x86_64.c
@@ -247,7 +247,7 @@ asmlinkage long sys_uname(struct new_utsname __user * name)
down_read(&uts_sem);
err = copy_to_user(name, utsname(), sizeof (*name));
up_read(&uts_sem);
- if (personality(current->personality) == PER_LINUX32)
+ if (personality(get_personality()) == PER_LINUX32)
err |= copy_to_user(&name->machine, "i686", 5);
return err ? -EFAULT : 0;
}
diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
index 56fe712..f299d64 100644
--- a/arch/x86/mm/mmap.c
+++ b/arch/x86/mm/mmap.c
@@ -55,7 +55,7 @@ static int mmap_is_ia32(void)
static int mmap_is_legacy(void)
{
- if (current->personality & ADDR_COMPAT_LAYOUT)
+ if (get_personality() & ADDR_COMPAT_LAYOUT)
return 1;
if (current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY)
diff --git a/include/asm-x86/page.h b/include/asm-x86/page.h
index 1cb7c51..fd90c7a 100644
--- a/include/asm-x86/page.h
+++ b/include/asm-x86/page.h
@@ -42,7 +42,7 @@
#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
#define VM_DATA_DEFAULT_FLAGS \
- (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
+ (((get_personality() & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
diff --git a/include/asm-x86/processor.h b/include/asm-x86/processor.h
index 45a2f0a..c426dc1 100644
--- a/include/asm-x86/processor.h
+++ b/include/asm-x86/processor.h
@@ -791,7 +791,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
/* This decides where the kernel will search for a free chunk of vm
* space during mmap's.
*/
-#define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
+#define IA32_PAGE_OFFSET ((get_personality() & ADDR_LIMIT_3GB) ? \
0xc0000000 : 0xFFFFe000)
#define TASK_SIZE (test_thread_flag(TIF_IA32) ? \
--
1.5.3.8
Use get_personality() macro instead of explicit reference for
uml code.
Signed-off-by: WANG Cong <[email protected]>
Cc: Jeff Dike <[email protected]>
---
arch/um/kernel/process.c | 2 +-
arch/um/sys-x86_64/syscalls.c | 2 +-
include/asm-um/vm-flags-i386.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index fc50d2f..91e0a84 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -405,7 +405,7 @@ int singlestepping(void * t)
#ifndef arch_align_stack
unsigned long arch_align_stack(unsigned long sp)
{
- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
+ if (!(get_personality() & ADDR_NO_RANDOMIZE) && randomize_va_space)
sp -= get_random_int() % 8192;
return sp & ~0xf;
}
diff --git a/arch/um/sys-x86_64/syscalls.c b/arch/um/sys-x86_64/syscalls.c
index f1199fd..cf7b61e 100644
--- a/arch/um/sys-x86_64/syscalls.c
+++ b/arch/um/sys-x86_64/syscalls.c
@@ -20,7 +20,7 @@ asmlinkage long sys_uname64(struct new_utsname __user * name)
err = copy_to_user(name, utsname(), sizeof (*name));
up_read(&uts_sem);
- if (personality(current->personality) == PER_LINUX32)
+ if (personality(get_personality()) == PER_LINUX32)
err |= copy_to_user(&name->machine, "i686", 5);
return err ? -EFAULT : 0;
diff --git a/include/asm-um/vm-flags-i386.h b/include/asm-um/vm-flags-i386.h
index e0d24c5..c30e0f6 100644
--- a/include/asm-um/vm-flags-i386.h
+++ b/include/asm-um/vm-flags-i386.h
@@ -8,7 +8,7 @@
#define VM_DATA_DEFAULT_FLAGS \
(VM_READ | VM_WRITE | \
- ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
+ ((get_personality() & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
#endif
--
1.5.3.8
Use get_personality() macro instead of explicit reference
for s390 code.
Signed-off-by: WANG Cong <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/s390/kernel/binfmt_elf32.c | 2 +-
arch/s390/kernel/sys_s390.c | 4 ++--
arch/s390/mm/mmap.c | 2 +-
include/asm-s390/elf.h | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/s390/kernel/binfmt_elf32.c b/arch/s390/kernel/binfmt_elf32.c
index 3e1c315..6a55911 100644
--- a/arch/s390/kernel/binfmt_elf32.c
+++ b/arch/s390/kernel/binfmt_elf32.c
@@ -78,7 +78,7 @@
do { \
if (ibcs2) \
set_personality(PER_SVR4); \
- else if (current->personality != PER_LINUX32) \
+ else if (get_personality() != PER_LINUX32) \
set_personality(PER_LINUX); \
set_thread_flag(TIF_31BIT); \
} while (0)
diff --git a/arch/s390/kernel/sys_s390.c b/arch/s390/kernel/sys_s390.c
index fefee99..f8371fe 100644
--- a/arch/s390/kernel/sys_s390.c
+++ b/arch/s390/kernel/sys_s390.c
@@ -215,7 +215,7 @@ asmlinkage long s390x_newuname(struct new_utsname __user *name)
{
int ret = sys_newuname(name);
- if (current->personality == PER_LINUX32 && !ret) {
+ if (get_personality() == PER_LINUX32 && !ret) {
ret = copy_to_user(name->machine, "s390\0\0\0\0", 8);
if (ret) ret = -EFAULT;
}
@@ -226,7 +226,7 @@ asmlinkage long s390x_personality(unsigned long personality)
{
int ret;
- if (current->personality == PER_LINUX32 && personality == PER_LINUX)
+ if (get_personality() == PER_LINUX32 && personality == PER_LINUX)
personality = PER_LINUX32;
ret = sys_personality(personality);
if (ret == PER_LINUX32)
diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
index 5932a82..f5bf304 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -59,7 +59,7 @@ static inline int mmap_is_legacy(void)
return 1;
#endif
return sysctl_legacy_va_layout ||
- (current->personality & ADDR_COMPAT_LAYOUT) ||
+ (get_personality() & ADDR_COMPAT_LAYOUT) ||
current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY;
}
diff --git a/include/asm-s390/elf.h b/include/asm-s390/elf.h
index b3ac262..18482d3 100644
--- a/include/asm-s390/elf.h
+++ b/include/asm-s390/elf.h
@@ -202,7 +202,7 @@ extern char elf_platform[];
do { \
if (ibcs2) \
set_personality(PER_SVR4); \
- else if (current->personality != PER_LINUX32) \
+ else if (get_personality() != PER_LINUX32) \
set_personality(PER_LINUX); \
clear_thread_flag(TIF_31BIT); \
} while (0)
--
1.5.3.8
Use get_personality() macro instead of explicit reference
for mips code.
Signed-off-by: WANG Cong <[email protected]>
Cc: Ralf Baechle <[email protected]>
---
arch/mips/kernel/linux32.c | 4 ++--
arch/mips/kernel/process.c | 4 ++--
include/asm-mips/elf.h | 2 +-
include/asm-mips/namei.h | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index 65af3cc..e5b7671 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -446,7 +446,7 @@ asmlinkage long sys32_newuname(struct new_utsname __user * name)
ret = -EFAULT;
up_read(&uts_sem);
- if (current->personality == PER_LINUX32 && !ret)
+ if (get_personality() == PER_LINUX32 && !ret)
if (copy_to_user(name->machine, "mips\0\0\0", 8))
ret = -EFAULT;
@@ -457,7 +457,7 @@ asmlinkage int sys32_personality(unsigned long personality)
{
int ret;
personality &= 0xffffffff;
- if (personality(current->personality) == PER_LINUX32 &&
+ if (personality(get_personality()) == PER_LINUX32 &&
personality == PER_LINUX)
personality = PER_LINUX32;
ret = sys_personality(personality);
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 2c09a44..dc7486c 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -126,7 +126,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
childregs->regs[7] = 0; /* Clear error flag */
#if defined(CONFIG_BINFMT_IRIX)
- if (current->personality != PER_LINUX) {
+ if (get_personality() != PER_LINUX) {
/* Under IRIX things are a little different. */
childregs->regs[3] = 1;
regs->regs[3] = 0;
@@ -471,7 +471,7 @@ out:
*/
unsigned long arch_align_stack(unsigned long sp)
{
- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
+ if (!(get_personality() & ADDR_NO_RANDOMIZE) && randomize_va_space)
sp -= get_random_int() & ~PAGE_MASK;
return sp & ALMASK;
diff --git a/include/asm-mips/elf.h b/include/asm-mips/elf.h
index f69f7ac..c07f464 100644
--- a/include/asm-mips/elf.h
+++ b/include/asm-mips/elf.h
@@ -308,7 +308,7 @@ do { \
\
if (ibcs2) \
set_personality(PER_SVR4); \
- else if (current->personality != PER_LINUX32) \
+ else if (get_personality() != PER_LINUX32) \
set_personality(PER_LINUX); \
} while (0)
diff --git a/include/asm-mips/namei.h b/include/asm-mips/namei.h
index c94d12d..18ab9eb 100644
--- a/include/asm-mips/namei.h
+++ b/include/asm-mips/namei.h
@@ -9,7 +9,7 @@
static inline char *__emul_prefix(void)
{
- switch (current->personality) {
+ switch (get_personality()) {
case PER_IRIX32:
case PER_IRIXN32:
case PER_IRIX64:
--
1.5.3.8
Use get_personality() macro instead of explicit reference
for ia64 code.
Signed-off-by: WANG Cong <[email protected]>
Cc: Tony Luck <[email protected]>
---
arch/ia64/ia32/sys_ia32.c | 2 +-
arch/ia64/mm/init.c | 2 +-
include/asm-ia64/fcntl.h | 2 +-
include/asm-ia64/namei.h | 2 +-
include/asm-ia64/page.h | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
index d025a22..a91273f 100644
--- a/arch/ia64/ia32/sys_ia32.c
+++ b/arch/ia64/ia32/sys_ia32.c
@@ -2265,7 +2265,7 @@ sys32_personality (unsigned int personality)
{
long ret;
- if (current->personality == PER_LINUX32 && personality == PER_LINUX)
+ if (get_personality() == PER_LINUX32 && personality == PER_LINUX)
personality = PER_LINUX32;
ret = sys_personality(personality);
if (ret == PER_LINUX32)
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 25aef62..f5641bb 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -139,7 +139,7 @@ ia64_init_addr_space (void)
}
/* map NaT-page at address zero to speed up speculative dereferencing of NULL: */
- if (!(current->personality & MMAP_PAGE_ZERO)) {
+ if (!(get_personality() & MMAP_PAGE_ZERO)) {
vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
if (vma) {
vma->vm_mm = current->mm;
diff --git a/include/asm-ia64/fcntl.h b/include/asm-ia64/fcntl.h
index 1dd275d..e8acf85 100644
--- a/include/asm-ia64/fcntl.h
+++ b/include/asm-ia64/fcntl.h
@@ -6,7 +6,7 @@
*/
#define force_o_largefile() \
- (personality(current->personality) != PER_LINUX32)
+ (personality(get_personality()) != PER_LINUX32)
#include <asm-generic/fcntl.h>
diff --git a/include/asm-ia64/namei.h b/include/asm-ia64/namei.h
index 78e7680..da38e5c 100644
--- a/include/asm-ia64/namei.h
+++ b/include/asm-ia64/namei.h
@@ -14,7 +14,7 @@
static inline char *
__emul_prefix (void)
{
- switch (current->personality) {
+ switch (get_personality()) {
case PER_LINUX32:
return EMUL_PREFIX_LINUX_IA32;
default:
diff --git a/include/asm-ia64/page.h b/include/asm-ia64/page.h
index 4999a6c..287e53b 100644
--- a/include/asm-ia64/page.h
+++ b/include/asm-ia64/page.h
@@ -224,7 +224,7 @@ get_order (unsigned long size)
#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \
VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC | \
- (((current->personality & READ_IMPLIES_EXEC) != 0) \
+ (((get_personality() & READ_IMPLIES_EXEC) != 0) \
? VM_EXEC : 0))
#endif /* _ASM_IA64_PAGE_H */
--
1.5.3.8
Use get_personality() macro instead of explicit reference
for alpha code.
Signed-off-by: WANG Cong <[email protected]>
Cc: Richard Henderson <[email protected]>
---
arch/alpha/kernel/osf_sys.c | 6 +++---
include/asm-alpha/processor.h | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 8c71daf..df825a4 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -1266,7 +1266,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long limit;
/* "32 bit" actually means 31 bit, since pointers sign extend. */
- if (current->personality & ADDR_LIMIT_32BIT)
+ if (get_personality() & ADDR_LIMIT_32BIT)
limit = 0x80000000;
else
limit = TASK_SIZE;
@@ -1327,7 +1327,7 @@ osf_fix_iov_len(const struct iovec __user *iov, unsigned long count)
asmlinkage ssize_t
osf_readv(unsigned long fd, const struct iovec __user * vector, unsigned long count)
{
- if (unlikely(personality(current->personality) == PER_OSF4))
+ if (unlikely(personality(get_personality()) == PER_OSF4))
if (osf_fix_iov_len(vector, count))
return -EFAULT;
return sys_readv(fd, vector, count);
@@ -1336,7 +1336,7 @@ osf_readv(unsigned long fd, const struct iovec __user * vector, unsigned long co
asmlinkage ssize_t
osf_writev(unsigned long fd, const struct iovec __user * vector, unsigned long count)
{
- if (unlikely(personality(current->personality) == PER_OSF4))
+ if (unlikely(personality(get_personality()) == PER_OSF4))
if (osf_fix_iov_len(vector, count))
return -EFAULT;
return sys_writev(fd, vector, count);
diff --git a/include/asm-alpha/processor.h b/include/asm-alpha/processor.h
index 94afe58..6c164b9 100644
--- a/include/asm-alpha/processor.h
+++ b/include/asm-alpha/processor.h
@@ -21,7 +21,7 @@
#define TASK_SIZE (0x40000000000UL)
#define STACK_TOP \
- (current->personality & ADDR_LIMIT_32BIT ? 0x80000000 : 0x00120000000UL)
+ (get_personality() & ADDR_LIMIT_32BIT ? 0x80000000 : 0x00120000000UL)
#define STACK_TOP_MAX 0x00120000000UL
@@ -29,7 +29,7 @@
* space during mmap's.
*/
#define TASK_UNMAPPED_BASE \
- ((current->personality & ADDR_LIMIT_32BIT) ? 0x40000000 : TASK_SIZE / 2)
+ ((get_personality() & ADDR_LIMIT_32BIT) ? 0x40000000 : TASK_SIZE / 2)
typedef struct {
unsigned long seg;
--
1.5.3.8
Use get_personality() macro instead of explicit reference
for frv code.
Signed-off-by: WANG Cong <[email protected]>
Cc: David Howells <[email protected]>
---
include/asm-frv/page.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/asm-frv/page.h b/include/asm-frv/page.h
index c2c1e89..6c5c4db 100644
--- a/include/asm-frv/page.h
+++ b/include/asm-frv/page.h
@@ -69,7 +69,7 @@ extern unsigned long max_pfn;
#ifdef CONFIG_MMU
#define VM_DATA_DEFAULT_FLAGS \
(VM_READ | VM_WRITE | \
- ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
+ ((get_personality() & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
#endif
--
1.5.3.8
Use get_personality() macro instead of explicit reference
for mn10300 code.
Signed-off-by: WANG Cong <[email protected]>
Cc: David Howells <[email protected]>
Cc: [email protected]
---
include/asm-mn10300/page.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/asm-mn10300/page.h b/include/asm-mn10300/page.h
index 124971b..fc6e9fb 100644
--- a/include/asm-mn10300/page.h
+++ b/include/asm-mn10300/page.h
@@ -123,7 +123,7 @@ static inline int get_order(unsigned long size)
#define VM_DATA_DEFAULT_FLAGS \
(VM_READ | VM_WRITE | \
- ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
+ ((get_personality() & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
#endif /* __KERNEL__ */
--
1.5.3.8
Use get_personality() macro instead of explicit reference.
Signed-off-by: WANG Cong <[email protected]>
Cc: Christoph Hellwig <[email protected]>
---
kernel/exec_domain.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c
index a9e6bad..056ba23 100644
--- a/kernel/exec_domain.c
+++ b/kernel/exec_domain.c
@@ -192,11 +192,11 @@ get_exec_domain_list(char *page)
asmlinkage long
sys_personality(u_long personality)
{
- u_long old = current->personality;
+ u_long old = get_personality();
if (personality != 0xffffffff) {
set_personality(personality);
- if (current->personality != personality)
+ if (get_personality() != personality)
return -EINVAL;
}
--
1.5.3.8
On Sat, Feb 23, 2008 at 04:14:03PM +0800, WANG Cong wrote:
> This patchset makes the macro get_personality function alike
> and teaches code to use get_personality() instead of explicit
> reference.
>
> [I am sorry if you've received multiple copied of this, since
> my git-send-email doesn't work well. ]
Yes, but why? "current->personality" is way more understandable than
your macro because task subject to dereference is very visible.
On Sat, Feb 23, 2008 at 4:14 PM, WANG Cong <[email protected]> wrote:
> This patch makes the macro get_personality function-like.
>
> Signed-off-by: WANG Cong <[email protected]>
> Cc: Christoph Hellwig <[email protected]>
> Cc: Bryan Wu <[email protected]>
> Cc: David Howells <[email protected]>
>
> ---
> arch/blackfin/kernel/signal.c | 2 +-
> arch/frv/kernel/signal.c | 4 ++--
> include/linux/personality.h | 2 +-
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/blackfin/kernel/signal.c b/arch/blackfin/kernel/signal.c
> index 5564c95..f3ef4ee 100644
> --- a/arch/blackfin/kernel/signal.c
> +++ b/arch/blackfin/kernel/signal.c
> @@ -224,7 +224,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t * info,
>
> /* Set up registers for signal handler */
> wrusp((unsigned long)frame);
> - if (get_personality & FDPIC_FUNCPTRS) {
> + if (get_personality() & FDPIC_FUNCPTRS) {
> struct fdpic_func_descriptor __user *funcptr =
> (struct fdpic_func_descriptor *) ka->sa.sa_handler;
> __get_user(regs->pc, &funcptr->text);
It looks ok for Blackfin
Acked-by: Bryan Wu <[email protected]>
Thanks a lot.
From: Alexey Dobriyan <[email protected]>
Subject: Re: [PATCH 00/16] (Resend) Use get_personality()
Date: Sat, 23 Feb 2008 11:51:01 +0300
Message-ID: <[email protected]>
> On Sat, Feb 23, 2008 at 04:14:03PM +0800, WANG Cong wrote:
> > This patchset makes the macro get_personality function alike
> > and teaches code to use get_personality() instead of explicit
> > reference.
> >
> > [I am sorry if you've received multiple copied of this, since
> > my git-send-email doesn't work well. ]
>
> Yes, but why? "current->personality" is way more understandable than
> your macro because task subject to dereference is very visible.
Use get_personality() can hide the task_struct internals a bit.
And I don't think using the macro to access it is less understandable.
Since 'current' won't be NULL, whether the dereference is visible is
not important.
Regards.
On Sat, Feb 23, 2008 at 04:14:08PM +0800, WANG Cong wrote:
> Use get_personality() macro instead of explicit reference
> for parisc code.
> - if (personality(current->personality) == PER_LINUX32
> + if (personality(get_personality()) == PER_LINUX32
Hm. We have an interesting clash of conventions here.
On the one hand, we have the java-style accessor convention.
get_personality()/set_personality().
On the other hand, we have reference counting. get_cpu()/put_cpu().
When I first saw this patch, I assumed the latter (and went looking for
the missing put_), but _personality is of the former style. I have one
suggestion (that nobody is going to like), which is that we suffix
reference-counting functions with _ref, ie:
get_cpu_ref()
put_cpu_ref()
pci_get_device_ref()
pci_put_device_ref()
pci_dev_get_ref()
pci_dev_put_ref()
(PCI is actually a good example here; it has "get" referring both to
refcounting and to accessors)
--
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
On Sat, Feb 23, 2008 at 04:59:44PM +0800, WANG Cong wrote:
> From: Alexey Dobriyan <[email protected]>
> Subject: Re: [PATCH 00/16] (Resend) Use get_personality()
> > On Sat, Feb 23, 2008 at 04:14:03PM +0800, WANG Cong wrote:
> > > This patchset makes the macro get_personality function alike
> > > and teaches code to use get_personality() instead of explicit
> > > reference.
> > >
> > > [I am sorry if you've received multiple copied of this, since
> > > my git-send-email doesn't work well. ]
> >
> > Yes, but why? "current->personality" is way more understandable than
> > your macro because task subject to dereference is very visible.
>
> Use get_personality() can hide the task_struct internals a bit.
->personality is going to become something less trivial?
Sorry, but you sound like C++ people writing tons of pointless get/set
wrappers. And your get_personality() is worse -- C++ would write it as
current->personality()
and again, even here, it's immediately visible that current task is
involved, not some other task.
> And I don't think using the macro to access it is less understandable.
> Since 'current' won't be NULL, whether the dereference is visible is
> not important.
It's not about NULL vs non-NULL at all.
From: Alexey Dobriyan <[email protected]>
Subject: Re: [PATCH 00/16] (Resend) Use get_personality()
Date: Sat, 23 Feb 2008 12:27:10 +0300
Message-ID: <[email protected]>
> On Sat, Feb 23, 2008 at 04:59:44PM +0800, WANG Cong wrote:
> > From: Alexey Dobriyan <[email protected]>
> > Subject: Re: [PATCH 00/16] (Resend) Use get_personality()
>
> > > On Sat, Feb 23, 2008 at 04:14:03PM +0800, WANG Cong wrote:
> > > > This patchset makes the macro get_personality function alike
> > > > and teaches code to use get_personality() instead of explicit
> > > > reference.
> > > >
> > > > [I am sorry if you've received multiple copied of this, since
> > > > my git-send-email doesn't work well. ]
> > >
> > > Yes, but why? "current->personality" is way more understandable than
> > > your macro because task subject to dereference is very visible.
> >
> > Use get_personality() can hide the task_struct internals a bit.
>
> ->personality is going to become something less trivial?
> Sorry, but you sound like C++ people writing tons of pointless get/set
> wrappers. And your get_personality() is worse -- C++ would write it as
>
> current->personality()
>
> and again, even here, it's immediately visible that current task is
> involved, not some other task.
>
Can't get_personality() mean getting the personality of current task?
Or you want a more generic macro like this?
#define get_task_personality(tsk) ((tsk)->personality)
No, that is _too_ generic. Look at the code, (nearly) all references to
'personality' are via 'current'. So get_personality() is enough.
I am not a fan of C++, I know that sometimes the get/set method in C++
is really a bit pointless, but, of course, *not* all the times.
Regards.
* WANG Cong <[email protected]> wrote:
> Use get_personality() macro instead of explicit reference for x86
> code.
thanks, applied.
Ingo
* Ingo Molnar <[email protected]> wrote:
> * WANG Cong <[email protected]> wrote:
>
> > Use get_personality() macro instead of explicit reference for x86
> > code.
>
> thanks, applied.
randconfig testing found the following build failures:
arch/x86/kernel/process_64.c: In function 'do_arch_prctl':
arch/x86/kernel/process_64.c:836: error: called object 'get_current()->personality' is not a function
arch/x86/kernel/process_64.c:862: error: called object 'get_current()->personality' is not a function
so i dropped the patch again. Config attached.
Ingo
From: Ingo Molnar <[email protected]>
Subject: Re: [PATCH 08/16] x86: use get_personality()
Date: Sat, 23 Feb 2008 11:19:54 +0100
Message-ID: <[email protected]>
>
> * Ingo Molnar <[email protected]> wrote:
>
> > * WANG Cong <[email protected]> wrote:
> >
> > > Use get_personality() macro instead of explicit reference for x86
> > > code.
> >
> > thanks, applied.
>
> randconfig testing found the following build failures:
>
> arch/x86/kernel/process_64.c: In function 'do_arch_prctl':
> arch/x86/kernel/process_64.c:836: error: called object 'get_current()->personality' is not a function
> arch/x86/kernel/process_64.c:862: error: called object 'get_current()->personality' is not a function
>
> so i dropped the patch again. Config attached.
>
> Ingo
Sorry that I didn't mention that this patch should be applied
_after_ [patch 01/16], since in [patch 01/16] I made the macro
get_personality like a function.
Sorry for this. Just wait after [patch 01/16] is applied.
Thanks.
WANG Cong <[email protected]> wrote:
> This patch makes the macro get_personality function-like.
>
> Signed-off-by: WANG Cong <[email protected]>
Acked-By: David Howells <[email protected]>
WANG Cong <[email protected]> wrote:
> Use get_personality() macro instead of explicit reference
> for frv code.
>
> Signed-off-by: WANG Cong <[email protected]>
Acked-By: David Howells <[email protected]>
WANG Cong <[email protected]> wrote:
> Use get_personality() macro instead of explicit reference
> for mn10300 code.
>
> Signed-off-by: WANG Cong <[email protected]>
Acked-By: David Howells <[email protected]>
Matthew Wilcox wrote:
> On Sat, Feb 23, 2008 at 04:14:08PM +0800, WANG Cong wrote:
>
>> Use get_personality() macro instead of explicit reference
>> for parisc code.
>> - if (personality(current->personality) == PER_LINUX32
>> + if (personality(get_personality()) == PER_LINUX32
>>
>
> Hm. We have an interesting clash of conventions here.
>
> On the one hand, we have the java-style accessor convention.
> get_personality()/set_personality().
>
Is get_personality() thought to be better than current->personality? To
me, the latter seems more meaningful, and I'd rather see it than the former.
On Sat, Feb 23, 2008 at 11:16:22PM +1030, David Newall wrote:
> Is get_personality() thought to be better than current->personality? To
> me, the latter seems more meaningful, and I'd rather see it than the former.
I suppose it's possible we might want to move 'personality' out of
'current' one day, and having an accessor macro makes it easier to do
that. I agree it doesn't seem like a big win though.
--
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
On Sat, Feb 23, 2008 at 12:27:10PM +0300, Alexey Dobriyan wrote:
> > Use get_personality() can hide the task_struct internals a bit.
>
> ->personality is going to become something less trivial?
> Sorry, but you sound like C++ people writing tons of pointless get/set
> wrappers. And your get_personality() is worse -- C++ would write it as
>
> current->personality()
>
> and again, even here, it's immediately visible that current task is
> involved, not some other task.
Yes, completely agreement. While I might have introduced this gem
back then it is entirely stupid if you think about it. Please send
patches to kill get_personality and just use current->personality
instead.
Thanks.
On Sat, 23 Feb 2008 13:37:31 -0500 Christoph Hellwig <[email protected]> wrote:
> On Sat, Feb 23, 2008 at 12:27:10PM +0300, Alexey Dobriyan wrote:
> > > Use get_personality() can hide the task_struct internals a bit.
> >
> > ->personality is going to become something less trivial?
> > Sorry, but you sound like C++ people writing tons of pointless get/set
> > wrappers. And your get_personality() is worse -- C++ would write it as
> >
> > current->personality()
> >
> > and again, even here, it's immediately visible that current task is
> > involved, not some other task.
>
> Yes, completely agreement. While I might have introduced this gem
> back then it is entirely stupid if you think about it. Please send
> patches to kill get_personality and just use current->personality
> instead.
>
yup.
We'll generally only add wrappers of this form if we need to provide
alternative implementations, or if we expect that we shall do so in the
future.
From: Andrew Morton <[email protected]>
Subject: Re: [PATCH 00/16] (Resend) Use get_personality()
Date: Sat, 23 Feb 2008 11:16:29 -0800
Message-ID: <[email protected]>
> On Sat, 23 Feb 2008 13:37:31 -0500 Christoph Hellwig <[email protected]> wrote:
>
> > On Sat, Feb 23, 2008 at 12:27:10PM +0300, Alexey Dobriyan wrote:
> > > > Use get_personality() can hide the task_struct internals a bit.
> > >
> > > ->personality is going to become something less trivial?
> > > Sorry, but you sound like C++ people writing tons of pointless get/set
> > > wrappers. And your get_personality() is worse -- C++ would write it as
> > >
> > > current->personality()
> > >
> > > and again, even here, it's immediately visible that current task is
> > > involved, not some other task.
> >
> > Yes, completely agreement. While I might have introduced this gem
> > back then it is entirely stupid if you think about it. Please send
> > patches to kill get_personality and just use current->personality
> > instead.
> >
>
> yup.
>
> We'll generally only add wrappers of this form if we need to provide
> alternative implementations, or if we expect that we shall do so in the
> future.
>
Ok. I will send a patch to remove it.
From: WANG Cong <[email protected]>
Date: Sun, 24 Feb 2008 12:09:03 +0800
Subject: [PATCH] Remove the macro get_personality
Remove the macro get_personality, use ->personality instead.
Cc: Ingo Molnar <[email protected]>
Cc: Christoph Hellwig <[email protected]
Cc: Alexey Dobriyan <[email protected]>
Cc: David Howells <[email protected]>
Cc: Bryan Wu <[email protected]>
Signed-off-by: WANG Cong <[email protected]>
---
arch/blackfin/kernel/signal.c | 2 +-
arch/frv/kernel/signal.c | 4 ++--
include/linux/personality.h | 4 ----
3 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/arch/blackfin/kernel/signal.c b/arch/blackfin/kernel/signal.c
index 5564c95..e8d3869 100644
--- a/arch/blackfin/kernel/signal.c
+++ b/arch/blackfin/kernel/signal.c
@@ -224,7 +224,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t * info,
/* Set up registers for signal handler */
wrusp((unsigned long)frame);
- if (get_personality & FDPIC_FUNCPTRS) {
+ if (current->personality & FDPIC_FUNCPTRS) {
struct fdpic_func_descriptor __user *funcptr =
(struct fdpic_func_descriptor *) ka->sa.sa_handler;
__get_user(regs->pc, &funcptr->text);
diff --git a/arch/frv/kernel/signal.c b/arch/frv/kernel/signal.c
index d64bcaf..3bdb368 100644
--- a/arch/frv/kernel/signal.c
+++ b/arch/frv/kernel/signal.c
@@ -297,7 +297,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set)
__frame->lr = (unsigned long) &frame->retcode;
__frame->gr8 = sig;
- if (get_personality & FDPIC_FUNCPTRS) {
+ if (current->personality & FDPIC_FUNCPTRS) {
struct fdpic_func_descriptor __user *funcptr =
(struct fdpic_func_descriptor __user *) ka->sa.sa_handler;
__get_user(__frame->pc, &funcptr->text);
@@ -396,7 +396,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
__frame->gr8 = sig;
__frame->gr9 = (unsigned long) &frame->info;
- if (get_personality & FDPIC_FUNCPTRS) {
+ if (current->personality & FDPIC_FUNCPTRS) {
struct fdpic_func_descriptor __user *funcptr =
(struct fdpic_func_descriptor __user *) ka->sa.sa_handler;
__get_user(__frame->pc, &funcptr->text);
diff --git a/include/linux/personality.h b/include/linux/personality.h
index 012cd55..a84e9ff 100644
--- a/include/linux/personality.h
+++ b/include/linux/personality.h
@@ -105,10 +105,6 @@ struct exec_domain {
*/
#define personality(pers) (pers & PER_MASK)
-/*
- * Personality of the currently running process.
- */
-#define get_personality (current->personality)
/*
* Change personality of the currently running process.
--
1.5.3.8