* [PATCH] alpha, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
@ 2011-06-10 13:08 ` Mathias Krause
2011-06-10 13:08 ` [PATCH] arm, " Mathias Krause
` (19 subsequent siblings)
20 siblings, 0 replies; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:08 UTC (permalink / raw)
To: linux-alpha
Cc: Andrew Morton, Linus Torvalds, linux-kernel, Mathias Krause,
Richard Henderson, Ivan Kokshaysky, Matt Turner
The address limit is already set in flush_old_exec() so this
set_fs(USER_DS) is redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
---
arch/alpha/kernel/process.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index 838eac1..89bbe5b 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -200,7 +200,6 @@ show_regs(struct pt_regs *regs)
void
start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
{
- set_fs(USER_DS);
regs->pc = pc;
regs->ps = 8;
wrusp(sp);
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* [PATCH] arm, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
2011-06-10 13:08 ` [PATCH] alpha, exec: remove redundant set_fs(USER_DS) Mathias Krause
@ 2011-06-10 13:08 ` Mathias Krause
2011-06-10 13:48 ` Russell King - ARM Linux
2011-06-10 13:09 ` [PATCH] avr32, " Mathias Krause
` (18 subsequent siblings)
20 siblings, 1 reply; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:08 UTC (permalink / raw)
To: Russell King
Cc: Andrew Morton, Linus Torvalds, linux-arm-kernel, linux-kernel,
Mathias Krause
The address limit is already set in flush_old_exec() so this
set_fs(USER_DS) is redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
arch/arm/include/asm/processor.h | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
index b2d9df5..3962caf 100644
--- a/arch/arm/include/asm/processor.h
+++ b/arch/arm/include/asm/processor.h
@@ -55,7 +55,6 @@ struct thread_struct {
#define start_thread(regs,pc,sp) \
({ \
unsigned long *stack = (unsigned long *)sp; \
- set_fs(USER_DS); \
memset(regs->uregs, 0, sizeof(regs->uregs)); \
if (current->personality & ADDR_LIMIT_32BIT) \
regs->ARM_cpsr = USR_MODE; \
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* Re: [PATCH] arm, exec: remove redundant set_fs(USER_DS)
2011-06-10 13:08 ` [PATCH] arm, " Mathias Krause
@ 2011-06-10 13:48 ` Russell King - ARM Linux
2011-06-10 13:53 ` Mathias Krause
0 siblings, 1 reply; 59+ messages in thread
From: Russell King - ARM Linux @ 2011-06-10 13:48 UTC (permalink / raw)
To: Mathias Krause
Cc: Andrew Morton, Linus Torvalds, linux-arm-kernel, linux-kernel
On Fri, Jun 10, 2011 at 03:08:57PM +0200, Mathias Krause wrote:
> The address limit is already set in flush_old_exec() so this
> set_fs(USER_DS) is redundant.
Please show where and how this is done. I've looked and can't see
any equivalent call to set_fs() in flush_old_exec().
^ permalink raw reply [flat|nested] 59+ messages in thread
* Re: [PATCH] arm, exec: remove redundant set_fs(USER_DS)
2011-06-10 13:48 ` Russell King - ARM Linux
@ 2011-06-10 13:53 ` Mathias Krause
2011-06-27 4:29 ` Mathias Krause
0 siblings, 1 reply; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:53 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Andrew Morton, Linus Torvalds, linux-arm-kernel, linux-kernel
On Fri, Jun 10, 2011 at 3:48 PM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Fri, Jun 10, 2011 at 03:08:57PM +0200, Mathias Krause wrote:
>> The address limit is already set in flush_old_exec() so this
>> set_fs(USER_DS) is redundant.
>
> Please show where and how this is done. I've looked and can't see
> any equivalent call to set_fs() in flush_old_exec().
Before dac853a (exec: delay address limit change until point of no
return) it was done in search_binary_handler(), now it is done in
flush_old_exec(). Either way set_fs(USER_DS) was/gets called before
start_thread() so the call there is redundant.
Mathias
^ permalink raw reply [flat|nested] 59+ messages in thread
* Re: [PATCH] arm, exec: remove redundant set_fs(USER_DS)
2011-06-10 13:53 ` Mathias Krause
@ 2011-06-27 4:29 ` Mathias Krause
0 siblings, 0 replies; 59+ messages in thread
From: Mathias Krause @ 2011-06-27 4:29 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Andrew Morton, Linus Torvalds, linux-arm-kernel, linux-kernel
On Fri, Jun 10, 2011 at 3:53 PM, Mathias Krause <minipli@googlemail.com> wrote:
> On Fri, Jun 10, 2011 at 3:48 PM, Russell King - ARM Linux
> <linux@arm.linux.org.uk> wrote:
>> On Fri, Jun 10, 2011 at 03:08:57PM +0200, Mathias Krause wrote:
>>> The address limit is already set in flush_old_exec() so this
>>> set_fs(USER_DS) is redundant.
>>
>> Please show where and how this is done. I've looked and can't see
>> any equivalent call to set_fs() in flush_old_exec().
>
> Before dac853a (exec: delay address limit change until point of no
> return) it was done in search_binary_handler(), now it is done in
> flush_old_exec(). Either way set_fs(USER_DS) was/gets called before
> start_thread() so the call there is redundant.
Russell, any new opinion on this?
Mathias
^ permalink raw reply [flat|nested] 59+ messages in thread
* [PATCH] avr32, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
2011-06-10 13:08 ` [PATCH] alpha, exec: remove redundant set_fs(USER_DS) Mathias Krause
2011-06-10 13:08 ` [PATCH] arm, " Mathias Krause
@ 2011-06-10 13:09 ` Mathias Krause
2011-06-14 11:28 ` Hans-Christian Egtvedt
2011-06-10 13:09 ` [PATCH] blackfin, " Mathias Krause
` (17 subsequent siblings)
20 siblings, 1 reply; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:09 UTC (permalink / raw)
To: Hans-Christian Egtvedt
Cc: Andrew Morton, Linus Torvalds, linux-kernel, Mathias Krause
The address limit is already set in flush_old_exec() so this
set_fs(USER_DS) is redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
arch/avr32/include/asm/processor.h | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/arch/avr32/include/asm/processor.h b/arch/avr32/include/asm/processor.h
index 49a88f5..108502b 100644
--- a/arch/avr32/include/asm/processor.h
+++ b/arch/avr32/include/asm/processor.h
@@ -131,7 +131,6 @@ struct thread_struct {
*/
#define start_thread(regs, new_pc, new_sp) \
do { \
- set_fs(USER_DS); \
memset(regs, 0, sizeof(*regs)); \
regs->sr = MODE_USER; \
regs->pc = new_pc & ~1; \
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* Re: [PATCH] avr32, exec: remove redundant set_fs(USER_DS)
2011-06-10 13:09 ` [PATCH] avr32, " Mathias Krause
@ 2011-06-14 11:28 ` Hans-Christian Egtvedt
0 siblings, 0 replies; 59+ messages in thread
From: Hans-Christian Egtvedt @ 2011-06-14 11:28 UTC (permalink / raw)
To: Mathias Krause; +Cc: Andrew Morton, Linus Torvalds, linux-kernel
On Fri, 2011-06-10 at 15:09 +0200, Mathias Krause wrote:
> The address limit is already set in flush_old_exec() so this
> set_fs(USER_DS) is redundant.
>
> Signed-off-by: Mathias Krause <minipli@googlemail.com>
Thanks, after searching up the history before this patch I see the whole
point as well. Please drop a line/link to parent patches that explains
the whole picture in the future.
I'll apply this to the AVR32 tree.
--
Hans-Christian Egtvedt
^ permalink raw reply [flat|nested] 59+ messages in thread
* [PATCH] blackfin, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
` (2 preceding siblings ...)
2011-06-10 13:09 ` [PATCH] avr32, " Mathias Krause
@ 2011-06-10 13:09 ` Mathias Krause
2011-06-10 14:17 ` Mike Frysinger
2011-06-10 13:09 ` [PATCH] cris, " Mathias Krause
` (16 subsequent siblings)
20 siblings, 1 reply; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:09 UTC (permalink / raw)
To: Mike Frysinger
Cc: Andrew Morton, Linus Torvalds, linux-kernel, Mathias Krause
The address limit is already set in flush_old_exec() so this
set_fs(USER_DS) is redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
arch/blackfin/kernel/process.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/arch/blackfin/kernel/process.c b/arch/blackfin/kernel/process.c
index 6a660fa..6a80a9e 100644
--- a/arch/blackfin/kernel/process.c
+++ b/arch/blackfin/kernel/process.c
@@ -140,7 +140,6 @@ EXPORT_SYMBOL(kernel_thread);
*/
void start_thread(struct pt_regs *regs, unsigned long new_ip, unsigned long new_sp)
{
- set_fs(USER_DS);
regs->pc = new_ip;
if (current->mm)
regs->p5 = current->mm->start_data;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* [PATCH] cris, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
` (3 preceding siblings ...)
2011-06-10 13:09 ` [PATCH] blackfin, " Mathias Krause
@ 2011-06-10 13:09 ` Mathias Krause
2011-06-10 13:09 ` [PATCH] frv, " Mathias Krause
` (15 subsequent siblings)
20 siblings, 0 replies; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:09 UTC (permalink / raw)
To: Mikael Starvik
Cc: Andrew Morton, Linus Torvalds, linux-cris-kernel, linux-kernel,
Mathias Krause, Jesper Nilsson
The address limit is already set in flush_old_exec() so those calls to
set_fs(USER_DS) are redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
---
arch/cris/include/arch-v10/arch/processor.h | 1 -
arch/cris/include/arch-v32/arch/processor.h | 1 -
2 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/arch/cris/include/arch-v10/arch/processor.h b/arch/cris/include/arch-v10/arch/processor.h
index cc692c7..93feb2a 100644
--- a/arch/cris/include/arch-v10/arch/processor.h
+++ b/arch/cris/include/arch-v10/arch/processor.h
@@ -53,7 +53,6 @@ struct thread_struct {
*/
#define start_thread(regs, ip, usp) do { \
- set_fs(USER_DS); \
regs->irp = ip; \
regs->dccr |= 1 << U_DCCR_BITNR; \
wrusp(usp); \
diff --git a/arch/cris/include/arch-v32/arch/processor.h b/arch/cris/include/arch-v32/arch/processor.h
index f80b477..9603c90 100644
--- a/arch/cris/include/arch-v32/arch/processor.h
+++ b/arch/cris/include/arch-v32/arch/processor.h
@@ -47,7 +47,6 @@ struct thread_struct {
*/
#define start_thread(regs, ip, usp) \
do { \
- set_fs(USER_DS); \
regs->erp = ip; \
regs->ccs |= 1 << (U_CCS_BITNR + CCS_SHIFT); \
wrusp(usp); \
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* [PATCH] frv, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
` (4 preceding siblings ...)
2011-06-10 13:09 ` [PATCH] cris, " Mathias Krause
@ 2011-06-10 13:09 ` Mathias Krause
2011-06-10 13:09 ` [PATCH] h8300, " Mathias Krause
` (14 subsequent siblings)
20 siblings, 0 replies; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:09 UTC (permalink / raw)
To: David Howells; +Cc: Andrew Morton, Linus Torvalds, linux-kernel, Mathias Krause
The address limit is already set in flush_old_exec() so those calls to
set_fs(USER_DS) are redundant.
Also removed the dead code in flush_thread().
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
arch/frv/include/asm/processor.h | 1 -
arch/frv/kernel/process.c | 5 +----
2 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/arch/frv/include/asm/processor.h b/arch/frv/include/asm/processor.h
index 4b789ab..81c2e27 100644
--- a/arch/frv/include/asm/processor.h
+++ b/arch/frv/include/asm/processor.h
@@ -97,7 +97,6 @@ extern struct task_struct *__kernel_current_task;
*/
#define start_thread(_regs, _pc, _usp) \
do { \
- set_fs(USER_DS); /* reads from user space */ \
__frame = __kernel_frame0_ptr; \
__frame->pc = (_pc); \
__frame->psr &= ~PSR_S; \
diff --git a/arch/frv/kernel/process.c b/arch/frv/kernel/process.c
index 9d35975..3901df1 100644
--- a/arch/frv/kernel/process.c
+++ b/arch/frv/kernel/process.c
@@ -143,10 +143,7 @@ void machine_power_off(void)
void flush_thread(void)
{
-#if 0 //ndef NO_FPU
- unsigned long zero = 0;
-#endif
- set_fs(USER_DS);
+ /* nothing */
}
inline unsigned long user_stack(const struct pt_regs *regs)
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* [PATCH] h8300, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
` (5 preceding siblings ...)
2011-06-10 13:09 ` [PATCH] frv, " Mathias Krause
@ 2011-06-10 13:09 ` Mathias Krause
2011-06-10 13:09 ` [PATCH] ia64, " Mathias Krause
` (13 subsequent siblings)
20 siblings, 0 replies; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:09 UTC (permalink / raw)
To: Yoshinori Sato
Cc: Andrew Morton, Linus Torvalds, linux-kernel, Mathias Krause
The address limit is already set in flush_old_exec() so those calls to
set_fs(USER_DS) are redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
arch/h8300/include/asm/processor.h | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/arch/h8300/include/asm/processor.h b/arch/h8300/include/asm/processor.h
index 69e8a34..e834b60 100644
--- a/arch/h8300/include/asm/processor.h
+++ b/arch/h8300/include/asm/processor.h
@@ -81,7 +81,6 @@ struct thread_struct {
#if defined(__H8300H__)
#define start_thread(_regs, _pc, _usp) \
do { \
- set_fs(USER_DS); /* reads from user space */ \
(_regs)->pc = (_pc); \
(_regs)->ccr = 0x00; /* clear all flags */ \
(_regs)->er5 = current->mm->start_data; /* GOT base */ \
@@ -91,7 +90,6 @@ do { \
#if defined(__H8300S__)
#define start_thread(_regs, _pc, _usp) \
do { \
- set_fs(USER_DS); /* reads from user space */ \
(_regs)->pc = (_pc); \
(_regs)->ccr = 0x00; /* clear kernel flag */ \
(_regs)->exr = 0x78; /* enable all interrupts */ \
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* [PATCH] ia64, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
` (6 preceding siblings ...)
2011-06-10 13:09 ` [PATCH] h8300, " Mathias Krause
@ 2011-06-10 13:09 ` Mathias Krause
2011-06-10 13:09 ` [PATCH] m32r, " Mathias Krause
` (12 subsequent siblings)
20 siblings, 0 replies; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:09 UTC (permalink / raw)
To: Tony Luck
Cc: Andrew Morton, Linus Torvalds, linux-ia64, linux-kernel,
Mathias Krause, Fenghua Yu
The address limit is already set in flush_old_exec() so this
set_fs(USER_DS) is redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
---
arch/ia64/include/asm/processor.h | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
index 03afe79..b2d6051 100644
--- a/arch/ia64/include/asm/processor.h
+++ b/arch/ia64/include/asm/processor.h
@@ -309,7 +309,6 @@ struct thread_struct {
}
#define start_thread(regs,new_ip,new_sp) do { \
- set_fs(USER_DS); \
regs->cr_ipsr = ((regs->cr_ipsr | (IA64_PSR_BITS_TO_SET | IA64_PSR_CPL)) \
& ~(IA64_PSR_BITS_TO_CLEAR | IA64_PSR_RI | IA64_PSR_IS)); \
regs->cr_iip = new_ip; \
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* [PATCH] m32r, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
` (7 preceding siblings ...)
2011-06-10 13:09 ` [PATCH] ia64, " Mathias Krause
@ 2011-06-10 13:09 ` Mathias Krause
2011-06-10 13:09 ` [PATCH] m68k, " Mathias Krause
` (11 subsequent siblings)
20 siblings, 0 replies; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:09 UTC (permalink / raw)
To: Hirokazu Takata
Cc: Andrew Morton, Linus Torvalds, linux-m32r, linux-kernel,
Mathias Krause
The address limit is already set in flush_old_exec() so this
set_fs(USER_DS) is redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
arch/m32r/include/asm/processor.h | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/arch/m32r/include/asm/processor.h b/arch/m32r/include/asm/processor.h
index 8397c24..e1f46d7 100644
--- a/arch/m32r/include/asm/processor.h
+++ b/arch/m32r/include/asm/processor.h
@@ -106,7 +106,6 @@ struct thread_struct {
#define start_thread(regs, new_pc, new_spu) \
do { \
- set_fs(USER_DS); \
regs->psw = (regs->psw | USERPS_BPSW) & 0x0000FFFFUL; \
regs->bpc = new_pc; \
regs->spu = new_spu; \
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* [PATCH] m68k, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
` (8 preceding siblings ...)
2011-06-10 13:09 ` [PATCH] m32r, " Mathias Krause
@ 2011-06-10 13:09 ` Mathias Krause
2011-06-15 14:40 ` Geert Uytterhoeven
2011-06-10 13:09 ` [PATCH] microblaze, " Mathias Krause
` (10 subsequent siblings)
20 siblings, 1 reply; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:09 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Andrew Morton, Linus Torvalds, linux-m68k, linux-kernel,
Mathias Krause, Greg Ungerer
The address limit is already set in flush_old_exec() so those calls to
set_fs(USER_DS) are redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: Greg Ungerer <gerg@uclinux.org>
---
Note: I'm not sure about the assignment to current->thread.fs in
flush_thread() -- shouldn't this be done in set_fs() itself?
arch/m68k/include/asm/processor.h | 4 ----
arch/m68k/kernel/process_mm.c | 2 +-
arch/m68k/kernel/process_no.c | 2 +-
3 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/arch/m68k/include/asm/processor.h b/arch/m68k/include/asm/processor.h
index f111b02..d8ef53a 100644
--- a/arch/m68k/include/asm/processor.h
+++ b/arch/m68k/include/asm/processor.h
@@ -105,9 +105,6 @@ struct thread_struct {
static inline void start_thread(struct pt_regs * regs, unsigned long pc,
unsigned long usp)
{
- /* reads from user space */
- set_fs(USER_DS);
-
regs->pc = pc;
regs->sr &= ~0x2000;
wrusp(usp);
@@ -129,7 +126,6 @@ extern int handle_kernel_fault(struct pt_regs *regs);
#define start_thread(_regs, _pc, _usp) \
do { \
- set_fs(USER_DS); /* reads from user space */ \
(_regs)->pc = (_pc); \
((struct switch_stack *)(_regs))[-1].a6 = 0; \
reformat(_regs); \
diff --git a/arch/m68k/kernel/process_mm.c b/arch/m68k/kernel/process_mm.c
index c2a1fc2..1bc223a 100644
--- a/arch/m68k/kernel/process_mm.c
+++ b/arch/m68k/kernel/process_mm.c
@@ -185,7 +185,7 @@ EXPORT_SYMBOL(kernel_thread);
void flush_thread(void)
{
unsigned long zero = 0;
- set_fs(USER_DS);
+
current->thread.fs = __USER_DS;
if (!FPU_IS_EMU)
asm volatile (".chip 68k/68881\n\t"
diff --git a/arch/m68k/kernel/process_no.c b/arch/m68k/kernel/process_no.c
index 9b86ad1..69c1803 100644
--- a/arch/m68k/kernel/process_no.c
+++ b/arch/m68k/kernel/process_no.c
@@ -158,7 +158,7 @@ void flush_thread(void)
#ifdef CONFIG_FPU
unsigned long zero = 0;
#endif
- set_fs(USER_DS);
+
current->thread.fs = __USER_DS;
#ifdef CONFIG_FPU
if (!FPU_IS_EMU)
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* Re: [PATCH] m68k, exec: remove redundant set_fs(USER_DS)
2011-06-10 13:09 ` [PATCH] m68k, " Mathias Krause
@ 2011-06-15 14:40 ` Geert Uytterhoeven
2011-06-15 15:49 ` Mathias Krause
0 siblings, 1 reply; 59+ messages in thread
From: Geert Uytterhoeven @ 2011-06-15 14:40 UTC (permalink / raw)
To: Mathias Krause
Cc: Andrew Morton, Linus Torvalds, linux-m68k, linux-kernel,
Greg Ungerer
On Fri, Jun 10, 2011 at 15:09, Mathias Krause <minipli@googlemail.com> wrote:
> The address limit is already set in flush_old_exec() so those calls to
> set_fs(USER_DS) are redundant.
>
> Signed-off-by: Mathias Krause <minipli@googlemail.com>
> Cc: Greg Ungerer <gerg@uclinux.org>
> ---
>
> Note: I'm not sure about the assignment to current->thread.fs in
> flush_thread() -- shouldn't this be done in set_fs() itself?
set_fs() is used to temporary set the address space to be used from the
kernel.
current->thread.fs is the address space that will be used when the
thread returns
to userspace.
So I think it's correct.
For nommu, thread.fs is set, but not really used.
> arch/m68k/include/asm/processor.h | 4 ----
> arch/m68k/kernel/process_mm.c | 2 +-
> arch/m68k/kernel/process_no.c | 2 +-
> 3 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/arch/m68k/include/asm/processor.h b/arch/m68k/include/asm/processor.h
> index f111b02..d8ef53a 100644
> --- a/arch/m68k/include/asm/processor.h
> +++ b/arch/m68k/include/asm/processor.h
> @@ -105,9 +105,6 @@ struct thread_struct {
> static inline void start_thread(struct pt_regs * regs, unsigned long pc,
> unsigned long usp)
> {
> - /* reads from user space */
> - set_fs(USER_DS);
> -
> regs->pc = pc;
> regs->sr &= ~0x2000;
> wrusp(usp);
> @@ -129,7 +126,6 @@ extern int handle_kernel_fault(struct pt_regs *regs);
>
> #define start_thread(_regs, _pc, _usp) \
> do { \
> - set_fs(USER_DS); /* reads from user space */ \
> (_regs)->pc = (_pc); \
> ((struct switch_stack *)(_regs))[-1].a6 = 0; \
> reformat(_regs); \
> diff --git a/arch/m68k/kernel/process_mm.c b/arch/m68k/kernel/process_mm.c
> index c2a1fc2..1bc223a 100644
> --- a/arch/m68k/kernel/process_mm.c
> +++ b/arch/m68k/kernel/process_mm.c
> @@ -185,7 +185,7 @@ EXPORT_SYMBOL(kernel_thread);
> void flush_thread(void)
> {
> unsigned long zero = 0;
> - set_fs(USER_DS);
> +
> current->thread.fs = __USER_DS;
> if (!FPU_IS_EMU)
> asm volatile (".chip 68k/68881\n\t"
> diff --git a/arch/m68k/kernel/process_no.c b/arch/m68k/kernel/process_no.c
> index 9b86ad1..69c1803 100644
> --- a/arch/m68k/kernel/process_no.c
> +++ b/arch/m68k/kernel/process_no.c
> @@ -158,7 +158,7 @@ void flush_thread(void)
> #ifdef CONFIG_FPU
> unsigned long zero = 0;
> #endif
> - set_fs(USER_DS);
> +
> current->thread.fs = __USER_DS;
> #ifdef CONFIG_FPU
> if (!FPU_IS_EMU)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 59+ messages in thread* Re: [PATCH] m68k, exec: remove redundant set_fs(USER_DS)
2011-06-15 14:40 ` Geert Uytterhoeven
@ 2011-06-15 15:49 ` Mathias Krause
0 siblings, 0 replies; 59+ messages in thread
From: Mathias Krause @ 2011-06-15 15:49 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Andrew Morton, Linus Torvalds, linux-m68k, linux-kernel,
Greg Ungerer
On Wed, Jun 15, 2011 at 4:40 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> On Fri, Jun 10, 2011 at 15:09, Mathias Krause <minipli@googlemail.com> wrote:
>> The address limit is already set in flush_old_exec() so those calls to
>> set_fs(USER_DS) are redundant.
>>
>> Signed-off-by: Mathias Krause <minipli@googlemail.com>
>> Cc: Greg Ungerer <gerg@uclinux.org>
>> ---
>>
>> Note: I'm not sure about the assignment to current->thread.fs in
>> flush_thread() -- shouldn't this be done in set_fs() itself?
>
> set_fs() is used to temporary set the address space to be used from the
> kernel.
> current->thread.fs is the address space that will be used when the
> thread returns
> to userspace.
> So I think it's correct.
>
> For nommu, thread.fs is set, but not really used.
Thanks for the explanation. So only the set_fs() is redundant.
Mathias
^ permalink raw reply [flat|nested] 59+ messages in thread
* [PATCH] microblaze, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
` (9 preceding siblings ...)
2011-06-10 13:09 ` [PATCH] m68k, " Mathias Krause
@ 2011-06-10 13:09 ` Mathias Krause
2011-07-05 11:45 ` Michal Simek
2011-06-10 13:10 ` [PATCH] mips, exec: remove redundant addr_limit assignment Mathias Krause
` (9 subsequent siblings)
20 siblings, 1 reply; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:09 UTC (permalink / raw)
To: Michal Simek
Cc: Andrew Morton, Linus Torvalds, microblaze-uclinux, linux-kernel,
Mathias Krause
The address limit is already set in flush_old_exec() so this
set_fs(USER_DS) is redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
arch/microblaze/kernel/process.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c
index 968648a..dbb8124 100644
--- a/arch/microblaze/kernel/process.c
+++ b/arch/microblaze/kernel/process.c
@@ -237,7 +237,6 @@ unsigned long get_wchan(struct task_struct *p)
/* Set up a thread for executing a new program */
void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp)
{
- set_fs(USER_DS);
regs->pc = pc;
regs->r1 = usp;
regs->pt_mode = 0;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* Re: [PATCH] microblaze, exec: remove redundant set_fs(USER_DS)
2011-06-10 13:09 ` [PATCH] microblaze, " Mathias Krause
@ 2011-07-05 11:45 ` Michal Simek
0 siblings, 0 replies; 59+ messages in thread
From: Michal Simek @ 2011-07-05 11:45 UTC (permalink / raw)
To: Mathias Krause
Cc: Andrew Morton, Linus Torvalds, microblaze-uclinux, linux-kernel
Mathias Krause wrote:
> The address limit is already set in flush_old_exec() so this
> set_fs(USER_DS) is redundant.
>
> Signed-off-by: Mathias Krause <minipli@googlemail.com>
> ---
> arch/microblaze/kernel/process.c | 1 -
> 1 files changed, 0 insertions(+), 1 deletions(-)
>
> diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c
> index 968648a..dbb8124 100644
> --- a/arch/microblaze/kernel/process.c
> +++ b/arch/microblaze/kernel/process.c
> @@ -237,7 +237,6 @@ unsigned long get_wchan(struct task_struct *p)
> /* Set up a thread for executing a new program */
> void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp)
> {
> - set_fs(USER_DS);
> regs->pc = pc;
> regs->r1 = usp;
> regs->pt_mode = 0;
Andrew has added it to his queue. I have tested and applied too.
Thanks,
Michal
--
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian
^ permalink raw reply [flat|nested] 59+ messages in thread
* [PATCH] mips, exec: remove redundant addr_limit assignment
2011-06-10 8:11 ` Mathias Krause
` (10 preceding siblings ...)
2011-06-10 13:09 ` [PATCH] microblaze, " Mathias Krause
@ 2011-06-10 13:10 ` Mathias Krause
2011-06-10 13:10 ` [PATCH] mn10300, exec: remove redundant set_fs(USER_DS) Mathias Krause
` (8 subsequent siblings)
20 siblings, 0 replies; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:10 UTC (permalink / raw)
To: Ralf Baechle
Cc: Andrew Morton, Linus Torvalds, linux-mips, linux-kernel,
Mathias Krause
The address limit is already set in flush_old_exec() via set_fs(USER_DS)
so this assignment is redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
arch/mips/kernel/process.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index d2112d3..a8d53e5 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -103,7 +103,6 @@ void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
__init_dsp();
regs->cp0_epc = pc;
regs->regs[29] = sp;
- current_thread_info()->addr_limit = USER_DS;
}
void exit_thread(void)
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* [PATCH] mn10300, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
` (11 preceding siblings ...)
2011-06-10 13:10 ` [PATCH] mips, exec: remove redundant addr_limit assignment Mathias Krause
@ 2011-06-10 13:10 ` Mathias Krause
2011-06-10 13:10 ` [PATCH] parisc, " Mathias Krause
` (7 subsequent siblings)
20 siblings, 0 replies; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:10 UTC (permalink / raw)
To: David Howells
Cc: Andrew Morton, Linus Torvalds, linux-am33-list, linux-kernel,
Mathias Krause, Koichi Yasutake
The address limit is already set in flush_old_exec() so this
set_fs(USER_DS) is redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
---
arch/mn10300/include/asm/processor.h | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/arch/mn10300/include/asm/processor.h b/arch/mn10300/include/asm/processor.h
index 4c1b5cc..f7b3c9a 100644
--- a/arch/mn10300/include/asm/processor.h
+++ b/arch/mn10300/include/asm/processor.h
@@ -127,7 +127,6 @@ static inline void start_thread(struct pt_regs *regs,
{
struct thread_info *ti = current_thread_info();
struct pt_regs *frame0;
- set_fs(USER_DS);
frame0 = thread_info_to_uregs(ti);
frame0->epsw = EPSW_nSL | EPSW_IE | EPSW_IM;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* [PATCH] parisc, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
` (12 preceding siblings ...)
2011-06-10 13:10 ` [PATCH] mn10300, exec: remove redundant set_fs(USER_DS) Mathias Krause
@ 2011-06-10 13:10 ` Mathias Krause
2011-06-10 13:10 ` [PATCH] ppc, " Mathias Krause
` (6 subsequent siblings)
20 siblings, 0 replies; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:10 UTC (permalink / raw)
To: James E.J. Bottomley
Cc: Andrew Morton, Linus Torvalds, linux-parisc, linux-kernel,
Mathias Krause, Kyle McMartin, Helge Deller
The address limit is already set in flush_old_exec() so those calls to
set_fs(USER_DS) are redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Helge Deller <deller@gmx.de>
---
arch/parisc/include/asm/processor.h | 2 --
arch/parisc/kernel/process.c | 1 -
2 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/arch/parisc/include/asm/processor.h b/arch/parisc/include/asm/processor.h
index 9ce66e9..7213ec9 100644
--- a/arch/parisc/include/asm/processor.h
+++ b/arch/parisc/include/asm/processor.h
@@ -196,7 +196,6 @@ typedef unsigned int elf_caddr_t;
/* offset pc for priv. level */ \
pc |= 3; \
\
- set_fs(USER_DS); \
regs->iasq[0] = spaceid; \
regs->iasq[1] = spaceid; \
regs->iaoq[0] = pc; \
@@ -299,7 +298,6 @@ on downward growing arches, it looks like this:
elf_addr_t pc = (elf_addr_t)new_pc | 3; \
elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1; \
\
- set_fs(USER_DS); \
regs->iasq[0] = spaceid; \
regs->iasq[1] = spaceid; \
regs->iaoq[0] = pc; \
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index 4b4b918..62c60b8 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -192,7 +192,6 @@ void flush_thread(void)
/* Only needs to handle fpu stuff or perf monitors.
** REVISIT: several arches implement a "lazy fpu state".
*/
- set_fs(USER_DS);
}
void release_thread(struct task_struct *dead_task)
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* [PATCH] ppc, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
` (13 preceding siblings ...)
2011-06-10 13:10 ` [PATCH] parisc, " Mathias Krause
@ 2011-06-10 13:10 ` Mathias Krause
2011-06-10 13:10 ` [PATCH] s390, " Mathias Krause
` (5 subsequent siblings)
20 siblings, 0 replies; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:10 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Andrew Morton, Linus Torvalds, linuxppc-dev, linux-kernel,
Mathias Krause
The address limit is already set in flush_old_exec() so this
set_fs(USER_DS) is redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
arch/powerpc/kernel/process.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 91e52df..885a2dd 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -831,8 +831,6 @@ void start_thread(struct pt_regs *regs, unsigned long start, unsigned long sp)
unsigned long load_addr = regs->gpr[2]; /* saved by ELF_PLAT_INIT */
#endif
- set_fs(USER_DS);
-
/*
* If we exec out of a kernel thread then thread.regs will not be
* set. Do it now.
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* [PATCH] s390, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
` (14 preceding siblings ...)
2011-06-10 13:10 ` [PATCH] ppc, " Mathias Krause
@ 2011-06-10 13:10 ` Mathias Krause
2011-06-10 13:10 ` [PATCH] sh, " Mathias Krause
` (4 subsequent siblings)
20 siblings, 0 replies; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:10 UTC (permalink / raw)
To: Martin Schwidefsky
Cc: Andrew Morton, Linus Torvalds, linux390, linux-s390, linux-kernel,
Mathias Krause
The address limit is already set in flush_old_exec() so those calls to
set_fs(USER_DS) are redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
arch/s390/include/asm/processor.h | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h
index 1300c30..4164533 100644
--- a/arch/s390/include/asm/processor.h
+++ b/arch/s390/include/asm/processor.h
@@ -118,14 +118,12 @@ struct stack_frame {
* Do necessary setup to start up a new thread.
*/
#define start_thread(regs, new_psw, new_stackp) do { \
- set_fs(USER_DS); \
regs->psw.mask = psw_user_bits; \
regs->psw.addr = new_psw | PSW_ADDR_AMODE; \
regs->gprs[15] = new_stackp; \
} while (0)
#define start_thread31(regs, new_psw, new_stackp) do { \
- set_fs(USER_DS); \
regs->psw.mask = psw_user32_bits; \
regs->psw.addr = new_psw | PSW_ADDR_AMODE; \
regs->gprs[15] = new_stackp; \
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* [PATCH] sh, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
` (15 preceding siblings ...)
2011-06-10 13:10 ` [PATCH] s390, " Mathias Krause
@ 2011-06-10 13:10 ` Mathias Krause
2011-06-14 6:33 ` Paul Mundt
2011-06-10 13:10 ` [PATCH] sparc, exec: remove redundant addr_limit assignment Mathias Krause
` (3 subsequent siblings)
20 siblings, 1 reply; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:10 UTC (permalink / raw)
To: Paul Mundt
Cc: Andrew Morton, Linus Torvalds, linux-sh, linux-kernel,
Mathias Krause
The address limit is already set in flush_old_exec() so those calls to
set_fs(USER_DS) are redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
arch/sh/include/asm/processor_64.h | 1 -
arch/sh/kernel/process_32.c | 2 --
2 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/arch/sh/include/asm/processor_64.h b/arch/sh/include/asm/processor_64.h
index 2a541dd..e25c4c7 100644
--- a/arch/sh/include/asm/processor_64.h
+++ b/arch/sh/include/asm/processor_64.h
@@ -150,7 +150,6 @@ struct thread_struct {
#define SR_USER (SR_MMU | SR_FD)
#define start_thread(_regs, new_pc, new_sp) \
- set_fs(USER_DS); \
_regs->sr = SR_USER; /* User mode. */ \
_regs->pc = new_pc - 4; /* Compensate syscall exit */ \
_regs->pc |= 1; /* Set SHmedia ! */ \
diff --git a/arch/sh/kernel/process_32.c b/arch/sh/kernel/process_32.c
index b473f0c..aaf6d59 100644
--- a/arch/sh/kernel/process_32.c
+++ b/arch/sh/kernel/process_32.c
@@ -102,8 +102,6 @@ EXPORT_SYMBOL(kernel_thread);
void start_thread(struct pt_regs *regs, unsigned long new_pc,
unsigned long new_sp)
{
- set_fs(USER_DS);
-
regs->pr = 0;
regs->sr = SR_FD;
regs->pc = new_pc;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* Re: [PATCH] sh, exec: remove redundant set_fs(USER_DS)
2011-06-10 13:10 ` [PATCH] sh, " Mathias Krause
@ 2011-06-14 6:33 ` Paul Mundt
0 siblings, 0 replies; 59+ messages in thread
From: Paul Mundt @ 2011-06-14 6:33 UTC (permalink / raw)
To: Mathias Krause; +Cc: Andrew Morton, Linus Torvalds, linux-sh, linux-kernel
On Fri, Jun 10, 2011 at 03:10:48PM +0200, Mathias Krause wrote:
> The address limit is already set in flush_old_exec() so those calls to
> set_fs(USER_DS) are redundant.
>
> Signed-off-by: Mathias Krause <minipli@googlemail.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 59+ messages in thread
* [PATCH] sparc, exec: remove redundant addr_limit assignment
2011-06-10 8:11 ` Mathias Krause
` (16 preceding siblings ...)
2011-06-10 13:10 ` [PATCH] sh, " Mathias Krause
@ 2011-06-10 13:10 ` Mathias Krause
2011-06-11 23:08 ` David Miller
2011-06-10 13:10 ` [PATCH] um, exec: remove redundant set_fs(USER_DS) Mathias Krause
` (2 subsequent siblings)
20 siblings, 1 reply; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:10 UTC (permalink / raw)
To: David S. Miller
Cc: Andrew Morton, Linus Torvalds, sparclinux, linux-kernel,
Mathias Krause
The address limit is already set in flush_old_exec() so this
assignment of USER_DS is redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
arch/sparc/kernel/process_32.c | 3 +--
arch/sparc/kernel/process_64.c | 3 ---
2 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
index c8cc461..f793742 100644
--- a/arch/sparc/kernel/process_32.c
+++ b/arch/sparc/kernel/process_32.c
@@ -380,8 +380,7 @@ void flush_thread(void)
#endif
}
- /* Now, this task is no longer a kernel thread. */
- current->thread.current_ds = USER_DS;
+ /* This task is no longer a kernel thread. */
if (current->thread.flags & SPARC_FLAG_KTHREAD) {
current->thread.flags &= ~SPARC_FLAG_KTHREAD;
diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
index c158a95..d959cd0 100644
--- a/arch/sparc/kernel/process_64.c
+++ b/arch/sparc/kernel/process_64.c
@@ -368,9 +368,6 @@ void flush_thread(void)
/* Clear FPU register state. */
t->fpsaved[0] = 0;
-
- if (get_thread_current_ds() != ASI_AIUS)
- set_fs(USER_DS);
}
/* It's a bit more tricky when 64-bit tasks are involved... */
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* Re: [PATCH] sparc, exec: remove redundant addr_limit assignment
2011-06-10 13:10 ` [PATCH] sparc, exec: remove redundant addr_limit assignment Mathias Krause
@ 2011-06-11 23:08 ` David Miller
2011-06-11 23:44 ` Al Viro
` (2 more replies)
0 siblings, 3 replies; 59+ messages in thread
From: David Miller @ 2011-06-11 23:08 UTC (permalink / raw)
To: minipli; +Cc: akpm, torvalds, sparclinux, linux-kernel
From: Mathias Krause <minipli@googlemail.com>
Date: Fri, 10 Jun 2011 15:10:53 +0200
> The address limit is already set in flush_old_exec() so this
> assignment of USER_DS is redundant.
>
> Signed-off-by: Mathias Krause <minipli@googlemail.com>
...
> @@ -368,9 +368,6 @@ void flush_thread(void)
>
> /* Clear FPU register state. */
> t->fpsaved[0] = 0;
> -
> - if (get_thread_current_ds() != ASI_AIUS)
> - set_fs(USER_DS);
> }
Yeah but now you're doing it unconditionally, the guard is here
because the %asi register write which set_fs() does is extremely
expensive on sparc64 and %99.99999 of the time we can avoid it.
^ permalink raw reply [flat|nested] 59+ messages in thread* Re: [PATCH] sparc, exec: remove redundant addr_limit assignment
2011-06-11 23:08 ` David Miller
@ 2011-06-11 23:44 ` Al Viro
2011-06-12 0:58 ` David Miller
2011-06-13 20:28 ` Mathias Krause
2011-06-17 18:45 ` Mathias Krause
2 siblings, 1 reply; 59+ messages in thread
From: Al Viro @ 2011-06-11 23:44 UTC (permalink / raw)
To: David Miller; +Cc: minipli, akpm, torvalds, sparclinux, linux-kernel
On Sat, Jun 11, 2011 at 04:08:42PM -0700, David Miller wrote:
> From: Mathias Krause <minipli@googlemail.com>
> Date: Fri, 10 Jun 2011 15:10:53 +0200
>
> > The address limit is already set in flush_old_exec() so this
> > assignment of USER_DS is redundant.
> >
> > Signed-off-by: Mathias Krause <minipli@googlemail.com>
> ...
> > @@ -368,9 +368,6 @@ void flush_thread(void)
> >
> > /* Clear FPU register state. */
> > t->fpsaved[0] = 0;
> > -
> > - if (get_thread_current_ds() != ASI_AIUS)
> > - set_fs(USER_DS);
> > }
>
> Yeah but now you're doing it unconditionally, the guard is here
> because the %asi register write which set_fs() does is extremely
> expensive on sparc64 and %99.99999 of the time we can avoid it.
OTOH, get_thread_current_ds() is cheap and moving that into set_fs()
itself wouldn't be particulary bad idea...
^ permalink raw reply [flat|nested] 59+ messages in thread
* Re: [PATCH] sparc, exec: remove redundant addr_limit assignment
2011-06-11 23:44 ` Al Viro
@ 2011-06-12 0:58 ` David Miller
2011-06-12 1:01 ` Linus Torvalds
0 siblings, 1 reply; 59+ messages in thread
From: David Miller @ 2011-06-12 0:58 UTC (permalink / raw)
To: viro; +Cc: minipli, akpm, torvalds, sparclinux, linux-kernel
From: Al Viro <viro@ZenIV.linux.org.uk>
Date: Sun, 12 Jun 2011 00:44:15 +0100
> On Sat, Jun 11, 2011 at 04:08:42PM -0700, David Miller wrote:
>> From: Mathias Krause <minipli@googlemail.com>
>> Date: Fri, 10 Jun 2011 15:10:53 +0200
>>
>> > @@ -368,9 +368,6 @@ void flush_thread(void)
>> >
>> > /* Clear FPU register state. */
>> > t->fpsaved[0] = 0;
>> > -
>> > - if (get_thread_current_ds() != ASI_AIUS)
>> > - set_fs(USER_DS);
>> > }
>>
>> Yeah but now you're doing it unconditionally, the guard is here
>> because the %asi register write which set_fs() does is extremely
>> expensive on sparc64 and %99.99999 of the time we can avoid it.
>
> OTOH, get_thread_current_ds() is cheap and moving that into set_fs()
> itself wouldn't be particulary bad idea...
The reason the test is only in this specific spot, is that's the only
place where the optimization makes any sense.
The rest of the time it's in compat layer code or similar, where we
know the set_fs() is actually necessary.
Therefore, expanding the test into every set_fs() call would be
wasteful.
^ permalink raw reply [flat|nested] 59+ messages in thread
* Re: [PATCH] sparc, exec: remove redundant addr_limit assignment
2011-06-12 0:58 ` David Miller
@ 2011-06-12 1:01 ` Linus Torvalds
2011-06-12 1:04 ` David Miller
0 siblings, 1 reply; 59+ messages in thread
From: Linus Torvalds @ 2011-06-12 1:01 UTC (permalink / raw)
To: David Miller; +Cc: viro, minipli, akpm, sparclinux, linux-kernel
On Sat, Jun 11, 2011 at 5:58 PM, David Miller <davem@davemloft.net> wrote:
>
> The reason the test is only in this specific spot, is that's the only
> place where the optimization makes any sense.
Well, considering that it didn't make any sense there *either*, that's
kind of pointless.
We always had the unconditional "set_fs()" in the exec path. It only
got moved, and as part of that conscious effort, the pointless
architecture churn is getting cleaned up.
Linus
^ permalink raw reply [flat|nested] 59+ messages in thread
* Re: [PATCH] sparc, exec: remove redundant addr_limit assignment
2011-06-11 23:08 ` David Miller
2011-06-11 23:44 ` Al Viro
@ 2011-06-13 20:28 ` Mathias Krause
2011-06-17 18:45 ` Mathias Krause
2 siblings, 0 replies; 59+ messages in thread
From: Mathias Krause @ 2011-06-13 20:28 UTC (permalink / raw)
To: David Miller; +Cc: akpm, torvalds, sparclinux, linux-kernel
On 12.06.2011, at 01:08 David Miller wrote:
> From: Mathias Krause <minipli@googlemail.com>
> Date: Fri, 10 Jun 2011 15:10:53 +0200
>
>> The address limit is already set in flush_old_exec() so this
>> assignment of USER_DS is redundant.
>>
>> Signed-off-by: Mathias Krause <minipli@googlemail.com>
> ...
>> @@ -368,9 +368,6 @@ void flush_thread(void)
>>
>> /* Clear FPU register state. */
>> t->fpsaved[0] = 0;
>> -
>> - if (get_thread_current_ds() != ASI_AIUS)
>> - set_fs(USER_DS);
>> }
>
> Yeah but now you're doing it unconditionally, the guard is here
> because the %asi register write which set_fs() does is extremely
> expensive on sparc64 and %99.99999 of the time we can avoid it.
As Linus already pointed out, that set_fs() was never called because
we already had (and still have) an unconditional set_fs() in the arch
independent code. So this patch just removes some dead code.
Mathias
^ permalink raw reply [flat|nested] 59+ messages in thread
* Re: [PATCH] sparc, exec: remove redundant addr_limit assignment
2011-06-11 23:08 ` David Miller
2011-06-11 23:44 ` Al Viro
2011-06-13 20:28 ` Mathias Krause
@ 2011-06-17 18:45 ` Mathias Krause
2 siblings, 0 replies; 59+ messages in thread
From: Mathias Krause @ 2011-06-17 18:45 UTC (permalink / raw)
To: David Miller; +Cc: akpm, torvalds, sparclinux, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1370 bytes --]
On 12.06.2011, 01:08 David Miller wrote:
> From: Mathias Krause <minipli@googlemail.com>
> Date: Fri, 10 Jun 2011 15:10:53 +0200
>
>> The address limit is already set in flush_old_exec() so this
>> assignment of USER_DS is redundant.
>>
>> Signed-off-by: Mathias Krause <minipli@googlemail.com>
> ...
>> @@ -368,9 +368,6 @@ void flush_thread(void)
>>
>> /* Clear FPU register state. */
>> t->fpsaved[0] = 0;
>> -
>> - if (get_thread_current_ds() != ASI_AIUS)
>> - set_fs(USER_DS);
>> }
>
> Yeah but now you're doing it unconditionally, the guard is here
> because the %asi register write which set_fs() does is extremely
> expensive on sparc64 and %99.99999 of the time we can avoid it.
David, can you please use the attached test program to give us some
numbers on how expensive the write to the %asi register is, relative to
the complexity of the whole exec() path. Please test it w/ and w/o the
attached patch. If the difference is significant it might be worth the
pain to push the set_fs() down to the arch specific code, e.g. into
flush_thread() as on SPARC, and remove it from flush_old_exec().
For the test something like:
$ for i in 1 2 3; do echo "run #$i:"; time exec_test 5000 /bin/true; done
or better:
$ perf stat -r3 exec_test 5000 /bin/true
should give some reasonable numbers.
I've no SPARC machine, so can't test myself.
Thanks,
Mathias
[-- Attachment #2: exec_test.c --]
[-- Type: application/octet-stream, Size: 999 bytes --]
#include <sys/mman.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
int main(int argc, char **argv, char **envp) {
unsigned long loops;
struct {
unsigned long parent;
unsigned long child;
} *err;
if (argc < 3) {
printf("usage: %s LOOPS CMD [ARGS]\n", argv[0]);
exit(1);
}
loops = strtoul(argv[1], NULL, 0);
err = mmap(NULL, sizeof(*err), PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
if (err == MAP_FAILED) {
printf("failed to create shared mapping (%s)\n", strerror(errno));
exit(1);
}
err->parent = err->child = 0;
while (loops--) {
switch (fork()) {
case 0:
execve(argv[2], &argv[2], envp);
err->child++;
exit(1);
break;
case -1:
err->parent++;
break;
default:
wait(NULL);
}
}
if (err->parent || err->child) {
printf("fork() errors: %lu\n", err->parent);
printf("exec() errors: %lu\n", err->child);
}
return 0;
}
[-- Attachment #3: no_unconditional_set_fs.diff --]
[-- Type: application/octet-stream, Size: 346 bytes --]
diff --git a/fs/exec.c b/fs/exec.c
index 97e0d52..31df75f 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1093,7 +1093,6 @@ int flush_old_exec(struct linux_binprm * bprm)
bprm->mm = NULL; /* We're using it now */
- set_fs(USER_DS);
current->flags &= ~(PF_RANDOMIZE | PF_KTHREAD);
flush_thread();
current->personality &= ~bprm->per_clear;
^ permalink raw reply related [flat|nested] 59+ messages in thread
* [PATCH] um, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
` (17 preceding siblings ...)
2011-06-10 13:10 ` [PATCH] sparc, exec: remove redundant addr_limit assignment Mathias Krause
@ 2011-06-10 13:10 ` Mathias Krause
2011-06-10 20:00 ` Richard Weinberger
2011-06-10 13:11 ` [PATCH] unicore32, " Mathias Krause
2011-06-10 15:52 ` [PATCH] init: use KERNEL_DS when trying to start init process Randy Dunlap
20 siblings, 1 reply; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:10 UTC (permalink / raw)
To: Jeff Dike
Cc: Andrew Morton, Linus Torvalds, user-mode-linux-devel,
linux-kernel, Mathias Krause, Richard Weinberger
The address limit is already set in flush_old_exec() so this
set_fs(USER_DS) is redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: Richard Weinberger <richard@nod.at>
---
arch/um/kernel/exec.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c
index 09bd7b5..939a4a6 100644
--- a/arch/um/kernel/exec.c
+++ b/arch/um/kernel/exec.c
@@ -38,7 +38,6 @@ void flush_thread(void)
void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
{
- set_fs(USER_DS);
PT_REGS_IP(regs) = eip;
PT_REGS_SP(regs) = esp;
}
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* [PATCH] unicore32, exec: remove redundant set_fs(USER_DS)
2011-06-10 8:11 ` Mathias Krause
` (18 preceding siblings ...)
2011-06-10 13:10 ` [PATCH] um, exec: remove redundant set_fs(USER_DS) Mathias Krause
@ 2011-06-10 13:11 ` Mathias Krause
2011-06-13 9:19 ` Guan Xuetao
2011-06-10 15:52 ` [PATCH] init: use KERNEL_DS when trying to start init process Randy Dunlap
20 siblings, 1 reply; 59+ messages in thread
From: Mathias Krause @ 2011-06-10 13:11 UTC (permalink / raw)
To: Guan Xuetao; +Cc: Andrew Morton, Linus Torvalds, linux-kernel, Mathias Krause
The address limit is already set in flush_old_exec() so this
set_fs(USER_DS) is redundant.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
arch/unicore32/include/asm/processor.h | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/arch/unicore32/include/asm/processor.h b/arch/unicore32/include/asm/processor.h
index e11cb07..f0d780a 100644
--- a/arch/unicore32/include/asm/processor.h
+++ b/arch/unicore32/include/asm/processor.h
@@ -53,7 +53,6 @@ struct thread_struct {
#define start_thread(regs, pc, sp) \
({ \
unsigned long *stack = (unsigned long *)sp; \
- set_fs(USER_DS); \
memset(regs->uregs, 0, sizeof(regs->uregs)); \
regs->UCreg_asr = USER_MODE; \
regs->UCreg_pc = pc & ~1; /* pc */ \
--
1.5.6.5
^ permalink raw reply related [flat|nested] 59+ messages in thread* Re: [PATCH] unicore32, exec: remove redundant set_fs(USER_DS)
2011-06-10 13:11 ` [PATCH] unicore32, " Mathias Krause
@ 2011-06-13 9:19 ` Guan Xuetao
2011-06-13 16:02 ` Mathias Krause
0 siblings, 1 reply; 59+ messages in thread
From: Guan Xuetao @ 2011-06-13 9:19 UTC (permalink / raw)
To: Mathias Krause; +Cc: Andrew Morton, Linus Torvalds, linux-kernel, arnd
On Fri, 2011-06-10 at 15:11 +0200, Mathias Krause wrote:
> The address limit is already set in flush_old_exec() so this
> set_fs(USER_DS) is redundant.
>
> Signed-off-by: Mathias Krause <minipli@googlemail.com>
> ---
> arch/unicore32/include/asm/processor.h | 1 -
> 1 files changed, 0 insertions(+), 1 deletions(-)
>
> diff --git a/arch/unicore32/include/asm/processor.h b/arch/unicore32/include/asm/processor.h
> index e11cb07..f0d780a 100644
> --- a/arch/unicore32/include/asm/processor.h
> +++ b/arch/unicore32/include/asm/processor.h
> @@ -53,7 +53,6 @@ struct thread_struct {
> #define start_thread(regs, pc, sp) \
> ({ \
> unsigned long *stack = (unsigned long *)sp; \
> - set_fs(USER_DS); \
> memset(regs->uregs, 0, sizeof(regs->uregs)); \
> regs->UCreg_asr = USER_MODE; \
> regs->UCreg_pc = pc & ~1; /* pc */ \
Hi Mathias,
I searched for the code in flush_old_exec(), but I can't find the code
you mentioned. Could you make it more clear?
And, if all fs codes (not only elf and aout) have the similar
implementations, perhaps all arch-specific codes should be manipulated
in the meanwhile.
Also Cc: Arnd Bergmann <arnd@arndb.de>
Thanks & Regards.
Guan Xuetao
^ permalink raw reply [flat|nested] 59+ messages in thread* Re: [PATCH] unicore32, exec: remove redundant set_fs(USER_DS)
2011-06-13 9:19 ` Guan Xuetao
@ 2011-06-13 16:02 ` Mathias Krause
2011-06-14 7:03 ` Guan Xuetao
0 siblings, 1 reply; 59+ messages in thread
From: Mathias Krause @ 2011-06-13 16:02 UTC (permalink / raw)
To: gxt; +Cc: Andrew Morton, Linus Torvalds, linux-kernel, arnd
On 13.06.2011, 11:19 Guan Xuetao wrote:
> On Fri, 2011-06-10 at 15:11 +0200, Mathias Krause wrote:
>> The address limit is already set in flush_old_exec() so this
>> set_fs(USER_DS) is redundant.
>>
>> Signed-off-by: Mathias Krause <minipli@googlemail.com>
>> ---
>> arch/unicore32/include/asm/processor.h | 1 -
>> 1 files changed, 0 insertions(+), 1 deletions(-)
>>
>> diff --git a/arch/unicore32/include/asm/processor.h b/arch/unicore32/include/asm/processor.h
>> index e11cb07..f0d780a 100644
>> --- a/arch/unicore32/include/asm/processor.h
>> +++ b/arch/unicore32/include/asm/processor.h
>> @@ -53,7 +53,6 @@ struct thread_struct {
>> #define start_thread(regs, pc, sp) \
>> ({ \
>> unsigned long *stack = (unsigned long *)sp; \
>> - set_fs(USER_DS); \
>> memset(regs->uregs, 0, sizeof(regs->uregs)); \
>> regs->UCreg_asr = USER_MODE; \
>> regs->UCreg_pc = pc & ~1; /* pc */ \
>
> Hi Mathias,
> I searched for the code in flush_old_exec(), but I can't find the code
> you mentioned. Could you make it more clear?
Sorry, this statement is based on a commit post v3.0-rc2. Before dac853a (exec:
delay address limit change until point of no return) it was done in
search_binary_handler(), now it is done in flush_old_exec(). Either way
set_fs(USER_DS) gets called before start_thread() so the call there is
redundant.
> And, if all fs codes (not only elf and aout) have the similar
> implementations,
I've checked that all binary format handler call flush_old_exec() before
start_thread(). So: yes.
> perhaps all arch-specific codes should be manipulated
> in the meanwhile.
That's what this LKML thread is for: https://lkml.org/lkml/2011/6/10/65
Thanks,
Mathias
^ permalink raw reply [flat|nested] 59+ messages in thread* Re: [PATCH] unicore32, exec: remove redundant set_fs(USER_DS)
2011-06-13 16:02 ` Mathias Krause
@ 2011-06-14 7:03 ` Guan Xuetao
0 siblings, 0 replies; 59+ messages in thread
From: Guan Xuetao @ 2011-06-14 7:03 UTC (permalink / raw)
To: Mathias Krause; +Cc: Andrew Morton, Linus Torvalds, linux-kernel, arnd
On Mon, 2011-06-13 at 18:02 +0200, Mathias Krause wrote:
> On 13.06.2011, 11:19 Guan Xuetao wrote:
> > On Fri, 2011-06-10 at 15:11 +0200, Mathias Krause wrote:
> >> The address limit is already set in flush_old_exec() so this
> >> set_fs(USER_DS) is redundant.
> >>
> >> Signed-off-by: Mathias Krause <minipli@googlemail.com>
> >> ---
> >> arch/unicore32/include/asm/processor.h | 1 -
> >> 1 files changed, 0 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/arch/unicore32/include/asm/processor.h b/arch/unicore32/include/asm/processor.h
> >> index e11cb07..f0d780a 100644
> >> --- a/arch/unicore32/include/asm/processor.h
> >> +++ b/arch/unicore32/include/asm/processor.h
> >> @@ -53,7 +53,6 @@ struct thread_struct {
> >> #define start_thread(regs, pc, sp) \
> >> ({ \
> >> unsigned long *stack = (unsigned long *)sp; \
> >> - set_fs(USER_DS); \
> >> memset(regs->uregs, 0, sizeof(regs->uregs)); \
> >> regs->UCreg_asr = USER_MODE; \
> >> regs->UCreg_pc = pc & ~1; /* pc */ \
> >
> > Hi Mathias,
> > I searched for the code in flush_old_exec(), but I can't find the code
> > you mentioned. Could you make it more clear?
>
> Sorry, this statement is based on a commit post v3.0-rc2. Before dac853a (exec:
> delay address limit change until point of no return) it was done in
> search_binary_handler(), now it is done in flush_old_exec(). Either way
> set_fs(USER_DS) gets called before start_thread() so the call there is
> redundant.
>
> > And, if all fs codes (not only elf and aout) have the similar
> > implementations,
>
> I've checked that all binary format handler call flush_old_exec() before
> start_thread(). So: yes.
>
> > perhaps all arch-specific codes should be manipulated
> > in the meanwhile.
>
> That's what this LKML thread is for: https://lkml.org/lkml/2011/6/10/65
>
> Thanks,
> Mathias
Thanks for your explanations.
The patch looks good to me.
Guan Xuetao
^ permalink raw reply [flat|nested] 59+ messages in thread
* Re: [PATCH] init: use KERNEL_DS when trying to start init process
2011-06-10 8:11 ` Mathias Krause
` (19 preceding siblings ...)
2011-06-10 13:11 ` [PATCH] unicore32, " Mathias Krause
@ 2011-06-10 15:52 ` Randy Dunlap
20 siblings, 0 replies; 59+ messages in thread
From: Randy Dunlap @ 2011-06-10 15:52 UTC (permalink / raw)
To: Mathias Krause
Cc: Andrew Morton, Linus Torvalds, Chris Metcalf, David S. Miller,
Chris Zankel, Al Viro, linux-kernel, stable, Rusty Russell
On Fri, 10 Jun 2011 10:11:39 +0200 Mathias Krause wrote:
> cat<<EOT >hello.c
> #include <unistd.h>
> #include <stdio.h>
>
> int main(void) {
> printf("Hello %s world!\n", sizeof(int) == sizeof(long) ? "32" : "64");
"Hello %s bit world!\n"
:)
> pause();
>
> return 0;
> }
> EOT
> * If you're running a 64 bit kernel /etc/init should start and print
> out "Hello 64 bit world!", otherwise the kernel should fail to start
> this binary and go ahead to /bin/init.
> * Finally, if /etc/init failed, /bin/init should start and print out
> "Hello 32 bit world!".
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
^ permalink raw reply [flat|nested] 59+ messages in thread