All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Removed unnecessary use of local variable in v3.12.
@ 2014-05-15 10:38 Meenakshi Aggarwal
  2015-02-16 15:58 ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 2+ messages in thread
From: Meenakshi Aggarwal @ 2014-05-15 10:38 UTC (permalink / raw)
  To: linux-rt-users; +Cc: Meenakshi Aggarwal

This patch remove use of temporary variable 'ip' which optimizes the code and results in
reduction of assembly instructions and hence improves latency.

Benefit of 18 lines of assembly instructions is observed on e6500 core.

Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@freescale.com>
---
 kernel/sched/core.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 8749d20..cdf43f8 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2296,13 +2296,16 @@ void __kprobes add_preempt_count(int val)
 	DEBUG_LOCKS_WARN_ON((preempt_count() & PREEMPT_MASK) >=
 				PREEMPT_MASK - 10);
 #endif
-	if (preempt_count() == val) {
-		unsigned long ip = get_parent_ip(CALLER_ADDR1);
+
+	if (preempt_count() == val)
 #ifdef CONFIG_DEBUG_PREEMPT
-		current->preempt_disable_ip = ip;
+		trace_preempt_off(CALLER_ADDR0,
+			current->preempt_disable_ip =
+			get_parent_ip(CALLER_ADDR1));
+#else
+		trace_preempt_off(CALLER_ADDR0, get_parent_ip(CALLER_ADDR1));
 #endif
-		trace_preempt_off(CALLER_ADDR0, ip);
-	}
+
 }
 EXPORT_SYMBOL(add_preempt_count);
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Removed unnecessary use of local variable in v3.12.
  2014-05-15 10:38 [PATCH] Removed unnecessary use of local variable in v3.12 Meenakshi Aggarwal
@ 2015-02-16 15:58 ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2015-02-16 15:58 UTC (permalink / raw)
  To: Meenakshi Aggarwal; +Cc: linux-rt-users

* Meenakshi Aggarwal | 2014-05-15 16:08:54 [+0530]:

>--- a/kernel/sched/core.c
>+++ b/kernel/sched/core.c
>@@ -2296,13 +2296,16 @@ void __kprobes add_preempt_count(int val)
> 	DEBUG_LOCKS_WARN_ON((preempt_count() & PREEMPT_MASK) >=
> 				PREEMPT_MASK - 10);
> #endif
>-	if (preempt_count() == val) {
>-		unsigned long ip = get_parent_ip(CALLER_ADDR1);
>+
>+	if (preempt_count() == val)
> #ifdef CONFIG_DEBUG_PREEMPT
>-		current->preempt_disable_ip = ip;
>+		trace_preempt_off(CALLER_ADDR0,
>+			current->preempt_disable_ip =
>+			get_parent_ip(CALLER_ADDR1));

So if I apply this, I can imagine tglx will run to his armoury looking
for a fine axe and then throwing it at me. So sorry, but I can't apply
this.
I suggest you look into gcc and figure out why this hackery of yours
saves 18 instructions. It does not make sense to me because all you do
is to inline replace ip with "get_parent_ip(CALLER_ADDR1)". It might be
that the compiler unrolls the stack each time ip is accessed but this is
clearly a compiler short comming.

Sebastian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-16 15:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-15 10:38 [PATCH] Removed unnecessary use of local variable in v3.12 Meenakshi Aggarwal
2015-02-16 15:58 ` Sebastian Andrzej Siewior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.