linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] acpi: Minor cleanup eliminating redundant PMTIMER_TICKS to NS conversion
@ 2010-04-22 23:48 Venkatesh Pallipadi
  2010-05-18  1:47 ` Venkatesh Pallipadi
  2010-05-28 19:10 ` [PATCH] acpi: Minor cleanup eliminating redundant PMTIMER_TICKS to NS conversion Len Brown
  0 siblings, 2 replies; 6+ messages in thread
From: Venkatesh Pallipadi @ 2010-04-22 23:48 UTC (permalink / raw)
  To: Len Brown; +Cc: ACPI list, Venkatesh Pallipadi

acpi_enter_[simple,bm] does
idle timing in ns, convert it to timeval, then to us, then to
pmtimer_ticks and then back to ns.

This patch changes things to
idle timing in ns, convert it to us, and then to pmtimer_ticks.

Just saves an imul along this path, but makes the code cleaner.

Signed-off-by: Venkatesh Pallipadi <venki@google.com>
---
 drivers/acpi/processor_idle.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 5939e7f..9e734ce 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -869,6 +869,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
 	struct acpi_processor *pr;
 	struct acpi_processor_cx *cx = cpuidle_get_statedata(state);
 	ktime_t  kt1, kt2;
+	s64 idle_time_ns;
 	s64 idle_time;
 	s64 sleep_ticks = 0;
 
@@ -910,12 +911,14 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
 	sched_clock_idle_sleep_event();
 	acpi_idle_do_entry(cx);
 	kt2 = ktime_get_real();
-	idle_time =  ktime_to_us(ktime_sub(kt2, kt1));
+	idle_time_ns = ktime_to_ns(ktime_sub(kt2, kt1));
+	idle_time = idle_time_ns;
+	do_div(idle_time, NSEC_PER_USEC);
 
 	sleep_ticks = us_to_pm_timer_ticks(idle_time);
 
 	/* Tell the scheduler how much we idled: */
-	sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS);
+	sched_clock_idle_wakeup_event(idle_time_ns);
 
 	local_irq_enable();
 	current_thread_info()->status |= TS_POLLING;
@@ -943,6 +946,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
 	struct acpi_processor *pr;
 	struct acpi_processor_cx *cx = cpuidle_get_statedata(state);
 	ktime_t  kt1, kt2;
+	s64 idle_time_ns;
 	s64 idle_time;
 	s64 sleep_ticks = 0;
 
@@ -1025,11 +1029,13 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
 		spin_unlock(&c3_lock);
 	}
 	kt2 = ktime_get_real();
-	idle_time =  ktime_to_us(ktime_sub(kt2, kt1));
+	idle_time_ns = ktime_to_us(ktime_sub(kt2, kt1));
+	idle_time = idle_time_ns;
+	do_div(idle_time, NSEC_PER_USEC);
 
 	sleep_ticks = us_to_pm_timer_ticks(idle_time);
 	/* Tell the scheduler how much we idled: */
-	sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS);
+	sched_clock_idle_wakeup_event(idle_time_ns);
 
 	local_irq_enable();
 	current_thread_info()->status |= TS_POLLING;
-- 
1.7.0.1


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

* Re: [PATCH] acpi: Minor cleanup eliminating redundant PMTIMER_TICKS to NS conversion
  2010-04-22 23:48 [PATCH] acpi: Minor cleanup eliminating redundant PMTIMER_TICKS to NS conversion Venkatesh Pallipadi
@ 2010-05-18  1:47 ` Venkatesh Pallipadi
  2010-05-28 19:09   ` Len Brown
  2010-05-28 19:10 ` [PATCH] acpi: Minor cleanup eliminating redundant PMTIMER_TICKS to NS conversion Len Brown
  1 sibling, 1 reply; 6+ messages in thread
From: Venkatesh Pallipadi @ 2010-05-18  1:47 UTC (permalink / raw)
  To: Len Brown; +Cc: ACPI list, Venkatesh Pallipadi

An incremental patch that removes some more redundancy in idle entry/exit.

Subject: [PATCH] acpi: Eliminate us to pm ticks conversion in common path

acpi_enter_[simple|bm] routines does us to pm tick conversion on every
idle wakeup and the value is only used in /proc/acpi display. We can
store the time in us and convert it into pm ticks before printing instead and
avoid the conversion in the common path. That also means no
unnecessary conversion overhead when ACPI_PROCFS is disabled.

Signed-off-by: Venkatesh Pallipadi <venki@google.com>
---
 drivers/acpi/processor_idle.c |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 9e734ce..336da8d 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -80,7 +80,7 @@ module_param(nocst, uint, 0000);
 static unsigned int latency_factor __read_mostly = 2;
 module_param(latency_factor, uint, 0644);

-static s64 us_to_pm_timer_ticks(s64 t)
+static u64 us_to_pm_timer_ticks(s64 t)
 {
 	return div64_u64(t * PM_TIMER_FREQUENCY, 1000000);
 }
@@ -741,10 +741,10 @@ static int acpi_processor_power_seq_show(struct
seq_file *seq, void *offset)
 		else
 			seq_puts(seq, "demotion[--] ");

-		seq_printf(seq, "latency[%03d] usage[%08d] duration[%020llu]\n",
+		seq_printf(seq, "latency[%03d] usage[%08d] duration[%020Lu]\n",
 			   pr->power.states[i].latency,
 			   pr->power.states[i].usage,
-			   (unsigned long long)pr->power.states[i].time);
+			   us_to_pm_timer_ticks(pr->power.states[i].time));
 	}

       end:
@@ -871,7 +871,6 @@ static int acpi_idle_enter_simple(struct
cpuidle_device *dev,
 	ktime_t  kt1, kt2;
 	s64 idle_time_ns;
 	s64 idle_time;
-	s64 sleep_ticks = 0;

 	pr = __get_cpu_var(processors);

@@ -915,8 +914,6 @@ static int acpi_idle_enter_simple(struct
cpuidle_device *dev,
 	idle_time = idle_time_ns;
 	do_div(idle_time, NSEC_PER_USEC);

-	sleep_ticks = us_to_pm_timer_ticks(idle_time);
-
 	/* Tell the scheduler how much we idled: */
 	sched_clock_idle_wakeup_event(idle_time_ns);

@@ -926,7 +923,7 @@ static int acpi_idle_enter_simple(struct
cpuidle_device *dev,
 	cx->usage++;

 	lapic_timer_state_broadcast(pr, cx, 0);
-	cx->time += sleep_ticks;
+	cx->time += idle_time;
 	return idle_time;
 }

@@ -948,7 +945,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
 	ktime_t  kt1, kt2;
 	s64 idle_time_ns;
 	s64 idle_time;
-	s64 sleep_ticks = 0;


 	pr = __get_cpu_var(processors);
@@ -1033,7 +1029,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
 	idle_time = idle_time_ns;
 	do_div(idle_time, NSEC_PER_USEC);

-	sleep_ticks = us_to_pm_timer_ticks(idle_time);
 	/* Tell the scheduler how much we idled: */
 	sched_clock_idle_wakeup_event(idle_time_ns);

@@ -1043,7 +1038,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
 	cx->usage++;

 	lapic_timer_state_broadcast(pr, cx, 0);
-	cx->time += sleep_ticks;
+	cx->time += idle_time;
 	return idle_time;
 }

-- 
1.7.0.1

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

* Re: [PATCH] acpi: Minor cleanup eliminating redundant PMTIMER_TICKS to NS conversion
  2010-05-18  1:47 ` Venkatesh Pallipadi
@ 2010-05-28 19:09   ` Len Brown
  2010-06-02 17:01     ` [PATCH] acpi: Eliminate us to pm ticks conversion in common path Venkatesh Pallipadi
  0 siblings, 1 reply; 6+ messages in thread
From: Len Brown @ 2010-05-28 19:09 UTC (permalink / raw)
  To: Venkatesh Pallipadi; +Cc: ACPI list

Venki,
I could not apply this one -- malformed?

thanks,
Len Brown, Intel Open Source Technology Center


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

* Re: [PATCH] acpi: Minor cleanup eliminating redundant PMTIMER_TICKS to NS conversion
  2010-04-22 23:48 [PATCH] acpi: Minor cleanup eliminating redundant PMTIMER_TICKS to NS conversion Venkatesh Pallipadi
  2010-05-18  1:47 ` Venkatesh Pallipadi
@ 2010-05-28 19:10 ` Len Brown
  1 sibling, 0 replies; 6+ messages in thread
From: Len Brown @ 2010-05-28 19:10 UTC (permalink / raw)
  To: Venkatesh Pallipadi; +Cc: ACPI list

applied

thanks,
Len Brown, Intel Open Source Technology Center


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

* [PATCH] acpi: Eliminate us to pm ticks conversion in common path
  2010-05-28 19:09   ` Len Brown
@ 2010-06-02 17:01     ` Venkatesh Pallipadi
  2010-06-04  7:44       ` Len Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Venkatesh Pallipadi @ 2010-06-02 17:01 UTC (permalink / raw)
  To: Len Brown; +Cc: ACPI list, Venkatesh Pallipadi

Is this one better?

Thanks,
Venki


acpi_enter_[simple|bm] routines does us to pm tick conversion on every
idle wakeup and the value is only used in /proc/acpi display. We can
store the time in us and convert it into pm ticks before printing instead and
avoid the conversion in the common path.

Signed-off-by: Venkatesh Pallipadi <venki@google.com>
---
 drivers/acpi/processor_idle.c |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 2e8c27d..71c9608 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -80,7 +80,7 @@ module_param(nocst, uint, 0000);
 static unsigned int latency_factor __read_mostly = 2;
 module_param(latency_factor, uint, 0644);
 
-static s64 us_to_pm_timer_ticks(s64 t)
+static u64 us_to_pm_timer_ticks(s64 t)
 {
 	return div64_u64(t * PM_TIMER_FREQUENCY, 1000000);
 }
@@ -731,10 +731,10 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
 
 		seq_puts(seq, "demotion[--] ");
 
-		seq_printf(seq, "latency[%03d] usage[%08d] duration[%020llu]\n",
+		seq_printf(seq, "latency[%03d] usage[%08d] duration[%020Lu]\n",
 			   pr->power.states[i].latency,
 			   pr->power.states[i].usage,
-			   (unsigned long long)pr->power.states[i].time);
+			   us_to_pm_timer_ticks(pr->power.states[i].time));
 	}
 
       end:
@@ -861,7 +861,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
 	ktime_t  kt1, kt2;
 	s64 idle_time_ns;
 	s64 idle_time;
-	s64 sleep_ticks = 0;
 
 	pr = __get_cpu_var(processors);
 
@@ -906,8 +905,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
 	idle_time = idle_time_ns;
 	do_div(idle_time, NSEC_PER_USEC);
 
-	sleep_ticks = us_to_pm_timer_ticks(idle_time);
-
 	/* Tell the scheduler how much we idled: */
 	sched_clock_idle_wakeup_event(idle_time_ns);
 
@@ -918,7 +915,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
 	cx->usage++;
 
 	lapic_timer_state_broadcast(pr, cx, 0);
-	cx->time += sleep_ticks;
+	cx->time += idle_time;
 	return idle_time;
 }
 
@@ -940,7 +937,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
 	ktime_t  kt1, kt2;
 	s64 idle_time_ns;
 	s64 idle_time;
-	s64 sleep_ticks = 0;
 
 
 	pr = __get_cpu_var(processors);
@@ -1026,7 +1022,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
 	idle_time = idle_time_ns;
 	do_div(idle_time, NSEC_PER_USEC);
 
-	sleep_ticks = us_to_pm_timer_ticks(idle_time);
 	/* Tell the scheduler how much we idled: */
 	sched_clock_idle_wakeup_event(idle_time_ns);
 
@@ -1037,7 +1032,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
 	cx->usage++;
 
 	lapic_timer_state_broadcast(pr, cx, 0);
-	cx->time += sleep_ticks;
+	cx->time += idle_time;
 	return idle_time;
 }
 
-- 
1.7.0.1


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

* Re: [PATCH] acpi: Eliminate us to pm ticks conversion in common path
  2010-06-02 17:01     ` [PATCH] acpi: Eliminate us to pm ticks conversion in common path Venkatesh Pallipadi
@ 2010-06-04  7:44       ` Len Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Len Brown @ 2010-06-04  7:44 UTC (permalink / raw)
  To: Venkatesh Pallipadi; +Cc: ACPI list

> Is this one better?

Yes, but the patch I'm really looking forward to
removed /proc/acpi/processor/*/power altogether...

applied,
thanks,
-Len Brown, Intel Open Source Technology Center

> 
> acpi_enter_[simple|bm] routines does us to pm tick conversion on every
> idle wakeup and the value is only used in /proc/acpi display. We can
> store the time in us and convert it into pm ticks before printing instead and
> avoid the conversion in the common path.
> 
> Signed-off-by: Venkatesh Pallipadi <venki@google.com>
> ---
>  drivers/acpi/processor_idle.c |   15 +++++----------
>  1 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
> index 2e8c27d..71c9608 100644
> --- a/drivers/acpi/processor_idle.c
> +++ b/drivers/acpi/processor_idle.c
> @@ -80,7 +80,7 @@ module_param(nocst, uint, 0000);
>  static unsigned int latency_factor __read_mostly = 2;
>  module_param(latency_factor, uint, 0644);
>  
> -static s64 us_to_pm_timer_ticks(s64 t)
> +static u64 us_to_pm_timer_ticks(s64 t)
>  {
>  	return div64_u64(t * PM_TIMER_FREQUENCY, 1000000);
>  }
> @@ -731,10 +731,10 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
>  
>  		seq_puts(seq, "demotion[--] ");
>  
> -		seq_printf(seq, "latency[%03d] usage[%08d] duration[%020llu]\n",
> +		seq_printf(seq, "latency[%03d] usage[%08d] duration[%020Lu]\n",
>  			   pr->power.states[i].latency,
>  			   pr->power.states[i].usage,
> -			   (unsigned long long)pr->power.states[i].time);
> +			   us_to_pm_timer_ticks(pr->power.states[i].time));
>  	}
>  
>        end:
> @@ -861,7 +861,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
>  	ktime_t  kt1, kt2;
>  	s64 idle_time_ns;
>  	s64 idle_time;
> -	s64 sleep_ticks = 0;
>  
>  	pr = __get_cpu_var(processors);
>  
> @@ -906,8 +905,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
>  	idle_time = idle_time_ns;
>  	do_div(idle_time, NSEC_PER_USEC);
>  
> -	sleep_ticks = us_to_pm_timer_ticks(idle_time);
> -
>  	/* Tell the scheduler how much we idled: */
>  	sched_clock_idle_wakeup_event(idle_time_ns);
>  
> @@ -918,7 +915,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
>  	cx->usage++;
>  
>  	lapic_timer_state_broadcast(pr, cx, 0);
> -	cx->time += sleep_ticks;
> +	cx->time += idle_time;
>  	return idle_time;
>  }
>  
> @@ -940,7 +937,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
>  	ktime_t  kt1, kt2;
>  	s64 idle_time_ns;
>  	s64 idle_time;
> -	s64 sleep_ticks = 0;
>  
>  
>  	pr = __get_cpu_var(processors);
> @@ -1026,7 +1022,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
>  	idle_time = idle_time_ns;
>  	do_div(idle_time, NSEC_PER_USEC);
>  
> -	sleep_ticks = us_to_pm_timer_ticks(idle_time);
>  	/* Tell the scheduler how much we idled: */
>  	sched_clock_idle_wakeup_event(idle_time_ns);
>  
> @@ -1037,7 +1032,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
>  	cx->usage++;
>  
>  	lapic_timer_state_broadcast(pr, cx, 0);
> -	cx->time += sleep_ticks;
> +	cx->time += idle_time;
>  	return idle_time;
>  }
>  
> -- 
> 1.7.0.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

end of thread, other threads:[~2010-06-04  7:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-22 23:48 [PATCH] acpi: Minor cleanup eliminating redundant PMTIMER_TICKS to NS conversion Venkatesh Pallipadi
2010-05-18  1:47 ` Venkatesh Pallipadi
2010-05-28 19:09   ` Len Brown
2010-06-02 17:01     ` [PATCH] acpi: Eliminate us to pm ticks conversion in common path Venkatesh Pallipadi
2010-06-04  7:44       ` Len Brown
2010-05-28 19:10 ` [PATCH] acpi: Minor cleanup eliminating redundant PMTIMER_TICKS to NS conversion Len Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).