Skip to contentSkip to conversation

ACPI: Read TSC upon resume

PATCH In review Sameer Nanda 5 participants 12 messages Oct 6, 2010 – Oct 18, 2010 1 message not in the archive ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: Read TSC upon resume

Read the TSC upon resuming and print it out. This is useful in helping figure out amount of time spent in the BIOS when resuming from suspend.

Change-Id I1d6a32bd62421becddecd152d561763e5f3e1101
---
 drivers/acpi/sleep.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/acpi/sleep.c +4 -0
index c0fed2e..f0588fa 100644
@@ -214,6 +214,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
 	acpi_status status = AE_OK;
 	unsigned long flags = 0;
 	u32 acpi_state = acpi_target_sleep_state;
+	u64 tsc;
 
 	ACPI_FLUSH_CPU_CACHE();
 
@@ -235,6 +236,9 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
 
 	case ACPI_STATE_S3:
 		do_suspend_lowlevel();
+		rdtscll(tsc);
+		printk(KERN_INFO "TSC at resume: %llu\n",
+				(unsigned long long)tsc);
 		break;
 	}
 
Signature · 1 line
1.7.1
#1 lore raw
Quoted 5 lines · Sameer Nanda

Read the TSC upon resuming and print it out. This is useful in helping figure out amount of time spent in the BIOS when resuming from suspend.

Change-Id: I1d6a32bd62421becddecd152d561763e5f3e1101

What is this tag for? I don't think it matches anything the kernel community wants, do you?

And are you always going to be printing this out? Why do we want to know this every time?

Quoted 18 lines
---
 drivers/acpi/sleep.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/acpi/sleep.c +1 -0
index c0fed2e..f0588fa 100644
@@ -214,6 +214,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
 	acpi_status status = AE_OK;
 	unsigned long flags = 0;
 	u32 acpi_state = acpi_target_sleep_state;
+	u64 tsc;
 
 	ACPI_FLUSH_CPU_CACHE();
 

drivers/acpi/sleep.c static int acpi_suspend_enter(suspend_state_t pm_state) · line 241

Quoted 6 lines
drivers/acpi/sleep.c +3 -0
@@ -235,6 +236,9 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
 
 	case ACPI_STATE_S3:
 		do_suspend_lowlevel();
+		rdtscll(tsc);
+		printk(KERN_INFO "TSC at resume: %llu\n",
+				(unsigned long long)tsc);

How long does this take, will it slow down resume?

thanks,

greg k-h

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 7 lines · Sameer Nanda
Quoted 3 lines · Greg KH

And are you always going to be printing this out? Why do we want to know this every time?

Yes, every time. This helps track variance in BIOS resume times within a single boot.

Is that really something that users can do something about? I can understand when you are trying to work with a BIOS company, but otherwise, this seems quite pointless.

thanks,

greg k-h

#4 lore raw
Quoted 10 lines · Greg KH
Quoted 7 lines · Sameer Nanda
Quoted 3 lines · Greg KH

And are you always going to be printing this out?  Why do we want to know this every time?

Yes, every time.  This helps track variance in BIOS resume times within a single boot.

Is that really something that users can do something about?

Aside from complaining to the BIOS vendors, no :)

Quoted 8 lines

I can
understand when you are trying to work with a BIOS company, but otherwise, this seems quite pointless.

thanks,

greg k-h

Signature · 5 lines
Sameer
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw
Quoted 7 lines · Sameer Nanda
Quoted 6 lines · Greg KH
Quoted 5 lines · Sameer Nanda
Quoted 3 lines · Greg KH

And are you always going to be printing this out?  Why do we want to know this every time?

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Yes, every time.  This helps track variance in BIOS resume times within a single boot.

Is that really something that users can do something about?

Aside from complaining to the BIOS vendors, no :)

Then I would not recommend adding this patch, as it is irrelevant for 99.9999% of all Linux users.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
Quoted 11 lines · Greg KH
Quoted 10 lines · Sameer Nanda
Quoted 9 lines · Greg KH
Quoted 7 lines · Sameer Nanda
Quoted 3 lines · Greg KH

And are you always going to be printing this out? Why do we want to know this every time?

Yes, every time. This helps track variance in BIOS resume times within a single boot.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Is that really something that users can do something about?

Aside from complaining to the BIOS vendors, no :)

Then I would not recommend adding this patch, as it is irrelevant for 99.9999% of all Linux users.

It may be somewhat useful, but the rdtscll() call seems to be x86-specific, in which case it shouldn't be used at this place.

Thanks,
Rafael

#7 lore raw
Quoted 26 lines

-----Original Message-----
From: [email protected] [mailto:linux-acpi- [email protected]] On Behalf Of Rafael J. Wysocki
Sent: Thursday, October 07, 2010 2:44 PM
To: Greg KH
Cc: Sameer Nanda; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] ACPI: Read TSC upon resume

Quoted 5 lines · Greg KH
Quoted 4 lines · Sameer Nanda
Quoted 3 lines · Greg KH
Quoted 2 lines · Sameer Nanda
Quoted 1 line · Greg KH

And are you always going to be printing this out? Why do we

want to

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

know this every time?

Yes, every time. This helps track variance in BIOS resume times

within a

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

single boot.

Is that really something that users can do something about?

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Aside from complaining to the BIOS vendors, no :)

Then I would not recommend adding this patch, as it is irrelevant for 99.9999% of all Linux users.

It may be somewhat useful, but the rdtscll() call seems to be x86- specific, in
which case it shouldn't be used at this place.

Also, in the case of an intel core 2 duo cpu, the tsc is not stable, hence upon resume the cpu is spinning up and the first tsc's will be slower.
During idle-time the tsc will not be incremented. The tsc is only stably incremented upon 100% cpu usage. It also doesn't increment faster in turbo mode in case of some core 2 duo and certainly the Nehalem cpu's. Calculating in time in terms of tsc might not be so reliable.

Quoted 8 lines

Thanks,
Rafael
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw
Quoted 31 lines · Reinoud
Quoted 31 lines

-----Original Message-----
From: [email protected] [mailto:linux-acpi- [email protected]] On Behalf Of Rafael J. Wysocki
Sent: Thursday, October 07, 2010 2:44 PM
To: Greg KH
Cc: Sameer Nanda; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] ACPI: Read TSC upon resume

Quoted 5 lines · Greg KH
Quoted 4 lines · Sameer Nanda
Quoted 3 lines · Greg KH
Quoted 2 lines · Sameer Nanda
Quoted 1 line · Greg KH

And are you always going to be printing this out? Why do we

want to

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

know this every time?

Yes, every time. This helps track variance in BIOS resume times

within a

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

single boot.

Is that really something that users can do something about?

Aside from complaining to the BIOS vendors, no :)

Then I would not recommend adding this patch, as it is irrelevant for 99.9999% of all Linux users.

Quoted 7 lines
Quoted 3 lines

It may be somewhat useful, but the rdtscll() call seems to be x86- specific, in
which case it shouldn't be used at this place.

Also, in the case of an intel core 2 duo cpu, the tsc is not stable, hence upon resume the cpu is spinning up and the first tsc's will be slower.
During idle-time the tsc will not be incremented. The tsc is only stably incremented upon 100% cpu usage. It also doesn't increment faster in turbo mode in case of some core 2 duo and certainly the Nehalem cpu's. Calculating in time in terms of tsc might not be so reliable.

If I'm wrong, please feel free to fix me.

I have 2 questions to your answer:

1. CPU has a flag named constant_tsc to keep TSC always working in a constant way, so it is irrelvant to the CPU freq. whether in turbo mode or any P-state CPU currently belongs to, TSC should be not affected. IIRC, this flag should exist long before, at least before Core 2 duo. If so, TSC shoule be stable in this kind of environment.

2. though during idle-time TSC will not be incremented, here I want to
remind it is right before Westmere (TSC not always running), and you mentioned "upon resume the cpu is spinning up and the first tsc's will be slower", I don't know if this commit cd7240c0b can fix it up. --
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw
In reply to Greg KH

(resending as plain text, sorry if you got dupe messages)

Quoted 9 lines · Greg KH
Quoted 5 lines · Sameer Nanda

Read the TSC upon resuming and print it out. This is useful in helping figure out amount of time spent in the BIOS when resuming from suspend.

Change-Id: I1d6a32bd62421becddecd152d561763e5f3e1101

What is this tag for?  I don't think it matches anything the kernel community wants, do you?

Yeah, its not needed. Let me resubmit the patch without this tag.

Quoted 3 lines

And are you always going to be printing this out?  Why do we want to know this every time?

Yes, every time. This helps track variance in BIOS resume times within a single boot.

Quoted 20 lines
Quoted 20 lines

---
 drivers/acpi/sleep.c |    4 ++++

 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/acpi/sleep.c +1 -0
index c0fed2e..f0588fa 100644
@@ -214,6 +214,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
       acpi_status status = AE_OK;
       unsigned long flags = 0;
       u32 acpi_state = acpi_target_sleep_state;
+     u64 tsc;
 
       ACPI_FLUSH_CPU_CACHE();
 
@@ -235,6 +236,9 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
 
Quoted 7 lines
Quoted 5 lines

      case ACPI_STATE_S3:
              do_suspend_lowlevel();
+             rdtscll(tsc);
+             printk(KERN_INFO "TSC at resume: %llu\n",
+                             (unsigned long long)tsc);

How long does this take, will it slow down resume?

The impact is ~10us (as measured on an Intel Atom N455 @ 1.66Ghz). Given that resume time is currently of the order of 1sec, its in the noise range.

Thanks for the feedback!

Quoted 5 lines

thanks,

greg k-h

Signature · 1 line
Sameer
#10 lore raw
Quoted 50 lines · Sameer Nanda

(resending as plain text, sorry if you got dupe messages)

Quoted 9 lines · Greg KH
Quoted 5 lines · Sameer Nanda

Read the TSC upon resuming and print it out. This is useful in helping figure out amount of time spent in the BIOS when resuming from suspend.

Change-Id: I1d6a32bd62421becddecd152d561763e5f3e1101

What is this tag for? I don't think it matches anything the kernel community wants, do you?

Yeah, its not needed. Let me resubmit the patch without this tag.

Quoted 3 lines

And are you always going to be printing this out? Why do we want to know this every time?

Yes, every time. This helps track variance in BIOS resume times within a single boot.

Quoted 20 lines
Quoted 20 lines
---
 drivers/acpi/sleep.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/acpi/sleep.c +1 -0
index c0fed2e..f0588fa 100644
@@ -214,6 +214,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
      acpi_status status = AE_OK;
      unsigned long flags = 0;
      u32 acpi_state = acpi_target_sleep_state;
+     u64 tsc;
 
      ACPI_FLUSH_CPU_CACHE();
 
@@ -235,6 +236,9 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
 
Quoted 7 lines

drivers/acpi/sleep.c static int acpi_suspend_enter(suspend_state_t pm_state) · line 241

Quoted 5 lines
drivers/acpi/sleep.c +3 -0
      case ACPI_STATE_S3:
              do_suspend_lowlevel();
+             rdtscll(tsc);
+             printk(KERN_INFO "TSC at resume: %llu\n",
+                             (unsigned long long)tsc);

How long does this take, will it slow down resume?

Quoted 3 lines

The impact is ~10us (as measured on an Intel Atom N455 @ 1.66Ghz). Given that resume time is currently of the order of 1sec, its in the noise range.

Do I think correctly that it assumes the TSC will be updated in the sleep state?

Rafael

#11 lore raw
Quoted 51 lines · Rafael J. Wysocki
Quoted 50 lines · Sameer Nanda

(resending as plain text, sorry if you got dupe messages)

Quoted 9 lines · Greg KH
Quoted 5 lines · Sameer Nanda

Read the TSC upon resuming and print it out. This is useful in helping figure out amount of time spent in the BIOS when resuming from suspend.

Change-Id: I1d6a32bd62421becddecd152d561763e5f3e1101

What is this tag for?  I don't think it matches anything the kernel community wants, do you?

Yeah, its not needed.  Let me resubmit the patch without this tag.

Quoted 3 lines

And are you always going to be printing this out?  Why do we want to know this every time?

Yes, every time.  This helps track variance in BIOS resume times within a single boot.

Quoted 27 lines
Quoted 20 lines

---
 drivers/acpi/sleep.c |    4 ++++

 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/acpi/sleep.c +1 -0
index c0fed2e..f0588fa 100644
@@ -214,6 +214,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
       acpi_status status = AE_OK;
       unsigned long flags = 0;
       u32 acpi_state = acpi_target_sleep_state;
+     u64 tsc;
 
       ACPI_FLUSH_CPU_CACHE();
 
@@ -235,6 +236,9 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
 
Quoted 5 lines

      case ACPI_STATE_S3:
              do_suspend_lowlevel();
+             rdtscll(tsc);
+             printk(KERN_INFO "TSC at resume: %llu\n",
+                             (unsigned long long)tsc);

How long does this take, will it slow down resume?

Quoted 5 lines
Quoted 3 lines

The impact is ~10us (as measured on an Intel Atom N455 @ 1.66Ghz). Given that resume time is currently of the order of 1sec, its in the noise range.

Do I think correctly that it assumes the TSC will be updated in the sleep state?

No, it actually banks on TSC not being updated while the system is in S3 state. Theory here being that upon resuming from S3, the CPU gets reset and so TSC starts counting up from 0. Therefore, reading the TSC value in the kernel upon resuming gives the number of cycles spent in the BIOS in resume path.

Quoted 3 lines

Rafael

Signature · 5 lines
Sameer
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#12 lore raw
Quoted 56 lines · Sameer Nanda
Quoted 55 lines · Rafael J. Wysocki
Quoted 53 lines · Sameer Nanda

(resending as plain text, sorry if you got dupe messages)

Quoted 9 lines · Greg KH
Quoted 5 lines · Sameer Nanda

Read the TSC upon resuming and print it out. This is useful in helping figure out amount of time spent in the BIOS when resuming from suspend.

Change-Id: I1d6a32bd62421becddecd152d561763e5f3e1101

What is this tag for? I don't think it matches anything the kernel community wants, do you?

Yeah, its not needed. Let me resubmit the patch without this tag.

Quoted 3 lines

And are you always going to be printing this out? Why do we want to know this every time?

Yes, every time. This helps track variance in BIOS resume times within a single boot.

Quoted 20 lines
Quoted 20 lines
---
 drivers/acpi/sleep.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/acpi/sleep.c +1 -0
index c0fed2e..f0588fa 100644
@@ -214,6 +214,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
      acpi_status status = AE_OK;
      unsigned long flags = 0;
      u32 acpi_state = acpi_target_sleep_state;
+     u64 tsc;
 
      ACPI_FLUSH_CPU_CACHE();
 
@@ -235,6 +236,9 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
 
Quoted 7 lines

drivers/acpi/sleep.c static int acpi_suspend_enter(suspend_state_t pm_state) · line 241

Quoted 5 lines
drivers/acpi/sleep.c +3 -0
      case ACPI_STATE_S3:
              do_suspend_lowlevel();
+             rdtscll(tsc);
+             printk(KERN_INFO "TSC at resume: %llu\n",
+                             (unsigned long long)tsc);

How long does this take, will it slow down resume?

The impact is ~10us (as measured on an Intel Atom N455 @ 1.66Ghz). Given that resume time is currently of the order of 1sec, its in the noise range.

Quoted 6 lines
Quoted 1 line

Do I think correctly that it assumes the TSC will be updated in the sleep state?

No, it actually banks on TSC not being updated while the system is in S3 state. Theory here being that upon resuming from S3, the CPU gets reset and so TSC starts counting up from 0. Therefore, reading the TSC value in the kernel upon resuming gives the number of cycles spent in the BIOS in resume path.

Ah that. OK, that's more clear now.

Thanks,
Rafael