Skip to contentSkip to conversation

staging: vc04_services: Use usleep_range() instead of msleep()

PATCH In review Mihaela Muraru 4 participants 10 messages Oct 1, 2017 – Oct 3, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: vc04_services: Use usleep_range() instead of msleep()

Since msleep() will often sleep 20 ms for any value given in the 1~20ms range, use usleep_range() for a precise wakeup.

Issue found by checkpatch.pl.

---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +1 -1
index 631ff73..daf18e8 100644
@@ -357,7 +357,7 @@ int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle,
 		if (status != VCHIQ_RETRY)
 			break;
 
-		msleep(1);
+		usleep_range(1000, 2000);
 	}
 
 	return vchiq_status_to_vchi(status);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 2 lines · Mihaela Muraru

Since msleep() will often sleep 20 ms for any value given in the 1~20ms range, use usleep_range() for a precise wakeup.

Why did you choose these particular argument values?

julia

Quoted 31 lines

Issue found by checkpatch.pl.

---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +1 -2
index 631ff73..daf18e8 100644
@@ -357,7 +357,7 @@ int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle,
 		if (status != VCHIQ_RETRY)
 			break;
 
-		msleep(1);
+		usleep_range(1000, 2000);
 	}
 
 	return vchiq_status_to_vchi(status);
--

2.7.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20171001073056.GA7890%40domino-MS-16Y1.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 10 lines · Julia Lawall
Quoted 2 lines · Mihaela Muraru

Since msleep() will often sleep 20 ms for any value given in the 1~20ms range, use usleep_range() for a precise wakeup.

Why did you choose these particular argument values?

julia

Those values are from Documentation/timers/timers-howto.txt, file that also suggest to use usleep_range() instead of msleep().

Should I mention it in log message and send patch v2?

Thank you,

Mihaela

Quoted 30 lines
Quoted 30 lines

Issue found by checkpatch.pl.

---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +1 -2
index 631ff73..daf18e8 100644
@@ -357,7 +357,7 @@ int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle,
 		if (status != VCHIQ_RETRY)
 			break;
 
-		msleep(1);
+		usleep_range(1000, 2000);
 	}
 
 	return vchiq_status_to_vchi(status);
--

2.7.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20171001073056.GA7890%40domino-MS-16Y1.
For more options, visit https://groups.google.com/d/optout.

#3 lore raw
In reply to Mihaela Muraru

Hi Mihaela,

Am 01.10.2017 um 09:30 schrieb Mihaela Muraru:

Quoted 15 lines

Since msleep() will often sleep 20 ms for any value given in the 1~20ms range, use usleep_range() for a precise wakeup.

Issue found by checkpatch.pl.

---
  drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +0 -0
index 631ff73..daf18e8 100644

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle, · line 360

Quoted 5 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +1 -1
@@ -357,7 +357,7 @@ int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle,
  		if (status != VCHIQ_RETRY)
  			break;
 
-		msleep(1);
+		usleep_range(1000, 2000);

since this code has been working downstream for many years, we must be careful with such functional changes.

Did you test this code on a Raspberry Pi?

Regards
Stefan

Quoted 3 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +0 -0
  	}
 
  	return vchiq_status_to_vchi(status);
#4 lore raw
In reply to Mihaela Muraru

Hi Phil,

Quoted 9 lines

Mihaela Muraru <[email protected]> hat am 1. Oktober 2017 um 09:30 geschrieben:

Since msleep() will often sleep 20 ms for any value given in the 1~20ms range, use usleep_range() for a precise wakeup.

Issue found by checkpatch.pl.

the vchiq driver calls 3 times msleep with parameter 1 (millisec). Depending on the kernel config the actual time of sleeping would be larger. In order to fix these checkpatch warning i see two options:

1) Use usleep_range in order to achieve the 1 millisec at cost of a higher CPU load

2) Increase the msleep values to 20 in order to keep the current runtime behavior

Do you have any preference?

Regards
Stefan

Quoted 20 lines
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +1 -1
index 631ff73..daf18e8 100644
@@ -357,7 +357,7 @@ int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle,
 		if (status != VCHIQ_RETRY)
 			break;
 
-		msleep(1);
+		usleep_range(1000, 2000);
 	}
 
 	return vchiq_status_to_vchi(status);
Signature · 1 line
2.7.4
#5 lore raw

Hi Stefan,

Quoted 12 lines · Stefan Wahren

Hi Phil,

Quoted 9 lines

Mihaela Muraru <[email protected]> hat am 1. Oktober 2017 um 09:30 geschrieben:

Since msleep() will often sleep 20 ms for any value given in the 1~20ms range, use usleep_range() for a precise wakeup.

Issue found by checkpatch.pl.

Quoted 7 lines

the vchiq driver calls 3 times msleep with parameter 1 (millisec). Depending on the kernel config the actual time of sleeping would be larger. In order to fix these checkpatch warning i see two options:

1) Use usleep_range in order to achieve the 1 millisec at cost of a higher CPU load

2) Increase the msleep values to 20 in order to keep the current runtime behavior

Do you have any preference?

I have no preference in principal - the decision should be based on performance measurement using the bulk test. If checkpatch is correct then using msleep(20) should make no observable difference(*).

In this case the precise delay is not critical, the aim being just to relinquish the CPU for a while, but it seems there is no way to express that - an msleep_range function would be useful here, even if it was just to keep checkpatch quiet.

Phil

(*)I don't really believe this.

Quoted 24 lines

Regards
Stefan

Quoted 20 lines
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +1 -1
index 631ff73..daf18e8 100644
@@ -357,7 +357,7 @@ int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle,
 		if (status != VCHIQ_RETRY)
 			break;
 
-		msleep(1);
+		usleep_range(1000, 2000);
 	}
 
 	return vchiq_status_to_vchi(status);
Signature · 1 line
2.7.4
#6 lore raw

Hi Phil,

Quoted 23 lines

Phil Elwell <[email protected]> hat am 3. Oktober 2017 um 10:15 geschrieben:

Hi Stefan,

Quoted 16 lines · Stefan Wahren

Hi Phil,

Quoted 9 lines

Mihaela Muraru <[email protected]> hat am 1. Oktober 2017 um 09:30 geschrieben:

Since msleep() will often sleep 20 ms for any value given in the 1~20ms range, use usleep_range() for a precise wakeup.

Issue found by checkpatch.pl.

the vchiq driver calls 3 times msleep with parameter 1 (millisec). Depending on the kernel config the actual time of sleeping would be larger. In order to fix these checkpatch warning i see two options:

1) Use usleep_range in order to achieve the 1 millisec at cost of a higher CPU load

Quoted 7 lines
Quoted 3 lines

2) Increase the msleep values to 20 in order to keep the current runtime behavior

Do you have any preference?

I have no preference in principal - the decision should be based on performance measurement using the bulk test. If checkpatch is correct then using msleep(20) should make no observable difference(*).

recently i made bulk tests because of the page_address/kmap issue, but the results wasn't very stable (especially for bigger buffers).

I did the following:

time vchiq_test -b 4 10000
time vchiq_test -b 8 10000
time vchiq_test -b 16 10000
time vchiq_test -b 32 10000
time vchiq_test -b 64 10000
time vchiq_test -b 128 10000
time vchiq_test -b 256 10000

Could you please provide some reasonable parameter / cases for bulk test with vchiq_test?

Quoted 32 lines

In this case the precise delay is not critical, the aim being just to relinquish the CPU for a while, but it seems there is no way to express that - an msleep_range function would be useful here, even if it was just to keep checkpatch quiet.

Phil

(*)I don't really believe this.

Quoted 24 lines

Regards
Stefan

Quoted 20 lines
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +1 -1
index 631ff73..daf18e8 100644
@@ -357,7 +357,7 @@ int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle,
 		if (status != VCHIQ_RETRY)
 			break;
 
-		msleep(1);
+		usleep_range(1000, 2000);
 	}
 
 	return vchiq_status_to_vchi(status);
Signature · 1 line
2.7.4
#7 lore raw
Quoted 45 lines · Stefan Wahren

Hi Phil,

Quoted 23 lines

Phil Elwell <[email protected]> hat am 3. Oktober 2017 um 10:15 geschrieben:

Hi Stefan,

Quoted 16 lines · Stefan Wahren

Hi Phil,

Quoted 9 lines

Mihaela Muraru <[email protected]> hat am 1. Oktober 2017 um 09:30 geschrieben:

Since msleep() will often sleep 20 ms for any value given in the 1~20ms range, use usleep_range() for a precise wakeup.

Issue found by checkpatch.pl.

the vchiq driver calls 3 times msleep with parameter 1 (millisec). Depending on the kernel config the actual time of sleeping would be larger. In order to fix these checkpatch warning i see two options:

1) Use usleep_range in order to achieve the 1 millisec at cost of a higher CPU load

Quoted 7 lines
Quoted 3 lines

2) Increase the msleep values to 20 in order to keep the current runtime behavior

Do you have any preference?

I have no preference in principal - the decision should be based on performance measurement using the bulk test. If checkpatch is correct then using msleep(20) should make no observable difference(*).

recently i made bulk tests because of the page_address/kmap issue, but the results wasn't very stable (especially for bigger buffers).

I did the following:

time vchiq_test -b 4 10000
time vchiq_test -b 8 10000
time vchiq_test -b 16 10000
time vchiq_test -b 32 10000
time vchiq_test -b 64 10000
time vchiq_test -b 128 10000
time vchiq_test -b 256 10000

Quoted 1 line

Could you please provide some reasonable parameter / cases for bulk test with vchiq_test?

Bulk performance is affected by memory fragmentation - it is quicker to transfer contiguous pages. I suggest picking one size - 128KB, say - and running it once for a large number of iterations. If you were to reboot and retry I would expect a relatively similar result. Then reboot and try the other configuration.

    time vchiq_test -b 128 10000
Quoted 33 lines
Quoted 33 lines

In this case the precise delay is not critical, the aim being just to relinquish the CPU for a while, but it seems there is no way to express that - an msleep_range function would be useful here, even if it was just to keep checkpatch quiet.

Phil

(*)I don't really believe this.

Quoted 24 lines

Regards
Stefan

Quoted 20 lines
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +1 -1
index 631ff73..daf18e8 100644
@@ -357,7 +357,7 @@ int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle,
 		if (status != VCHIQ_RETRY)
 			break;
 
-		msleep(1);
+		usleep_range(1000, 2000);
 	}
 
 	return vchiq_status_to_vchi(status);
Signature · 1 line
2.7.4
#8 lore raw

Hi Phil,

Quoted 49 lines

Phil Elwell <[email protected]> hat am 3. Oktober 2017 um 15:22 geschrieben:

Quoted 45 lines · Stefan Wahren

Hi Phil,

Quoted 23 lines

Phil Elwell <[email protected]> hat am 3. Oktober 2017 um 10:15 geschrieben:

Hi Stefan,

Quoted 16 lines · Stefan Wahren

Hi Phil,

Quoted 9 lines

Mihaela Muraru <[email protected]> hat am 1. Oktober 2017 um 09:30 geschrieben:

Since msleep() will often sleep 20 ms for any value given in the 1~20ms range, use usleep_range() for a precise wakeup.

Issue found by checkpatch.pl.

the vchiq driver calls 3 times msleep with parameter 1 (millisec). Depending on the kernel config the actual time of sleeping would be larger. In order to fix these checkpatch warning i see two options:

1) Use usleep_range in order to achieve the 1 millisec at cost of a higher CPU load

Quoted 7 lines
Quoted 3 lines

2) Increase the msleep values to 20 in order to keep the current runtime behavior

Do you have any preference?

I have no preference in principal - the decision should be based on performance measurement using the bulk test. If checkpatch is correct then using msleep(20) should make no observable difference(*).

recently i made bulk tests because of the page_address/kmap issue, but the results wasn't very stable (especially for bigger buffers).

I did the following:

time vchiq_test -b 4 10000
time vchiq_test -b 8 10000
time vchiq_test -b 16 10000
time vchiq_test -b 32 10000
time vchiq_test -b 64 10000
time vchiq_test -b 128 10000
time vchiq_test -b 256 10000

Quoted 4 lines
Quoted 1 line

Could you please provide some reasonable parameter / cases for bulk test with vchiq_test?

Bulk performance is affected by memory fragmentation - it is quicker to transfer contiguous pages. I suggest picking one size - 128KB, say - and running it once for a large number of iterations. If you were to reboot and retry I would expect a relatively similar result. Then reboot and try the other configuration.

Thanks

Quoted 2 lines
    time vchiq_test -b 128 10000

are 10000 iterations sufficient?

Quoted 34 lines
Quoted 34 lines
Quoted 34 lines

In this case the precise delay is not critical, the aim being just to relinquish the CPU for a while, but it seems there is no way to express that - an msleep_range function would be useful here, even if it was just to keep checkpatch quiet.

Phil

(*)I don't really believe this.

Quoted 24 lines

Regards
Stefan

Quoted 20 lines
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +1 -1
index 631ff73..daf18e8 100644
@@ -357,7 +357,7 @@ int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle,
 		if (status != VCHIQ_RETRY)
 			break;
 
-		msleep(1);
+		usleep_range(1000, 2000);
 	}
 
 	return vchiq_status_to_vchi(status);
Signature · 1 line
2.7.4
#9 lore raw
Quoted 54 lines · Stefan Wahren

Hi Phil,

Quoted 52 lines

Phil Elwell <[email protected]> hat am 3. Oktober 2017 um 15:22 geschrieben:

Quoted 46 lines · Stefan Wahren

Hi Phil,

Quoted 23 lines

Phil Elwell <[email protected]> hat am 3. Oktober 2017 um 10:15 geschrieben:

Hi Stefan,

Quoted 16 lines · Stefan Wahren

Hi Phil,

Quoted 9 lines

Mihaela Muraru <[email protected]> hat am 1. Oktober 2017 um 09:30 geschrieben:

Since msleep() will often sleep 20 ms for any value given in the 1~20ms range, use usleep_range() for a precise wakeup.

Issue found by checkpatch.pl.

the vchiq driver calls 3 times msleep with parameter 1 (millisec). Depending on the kernel config the actual time of sleeping would be larger. In order to fix these checkpatch warning i see two options:

1) Use usleep_range in order to achieve the 1 millisec at cost of a higher CPU load

Quoted 7 lines
Quoted 3 lines

2) Increase the msleep values to 20 in order to keep the current runtime behavior

Do you have any preference?

I have no preference in principal - the decision should be based on performance measurement using the bulk test. If checkpatch is correct then using msleep(20) should make no observable difference(*).

recently i made bulk tests because of the page_address/kmap issue, but the results wasn't very stable (especially for bigger buffers).

I did the following:

time vchiq_test -b 4 10000
time vchiq_test -b 8 10000
time vchiq_test -b 16 10000
time vchiq_test -b 32 10000
time vchiq_test -b 64 10000
time vchiq_test -b 128 10000
time vchiq_test -b 256 10000

Could you please provide some reasonable parameter / cases for bulk test with vchiq_test?

Quoted 8 lines
Quoted 1 line

Bulk performance is affected by memory fragmentation - it is quicker to transfer contiguous pages. I suggest picking one size - 128KB, say - and running it once for a large number of iterations. If you were to reboot and retry I would expect a relatively similar result. Then reboot and try the other configuration.

Thanks

Quoted 2 lines
    time vchiq_test -b 128 10000

are 10000 iterations sufficient?

How long is a piece of string? Make it a million if you like.

Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines

In this case the precise delay is not critical, the aim being just to relinquish the CPU for a while, but it seems there is no way to express that - an msleep_range function would be useful here, even if it was just to keep checkpatch quiet.

Phil

(*)I don't really believe this.

Quoted 24 lines

Regards
Stefan

Quoted 20 lines
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +1 -1
index 631ff73..daf18e8 100644
@@ -357,7 +357,7 @@ int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle,
 		if (status != VCHIQ_RETRY)
 			break;
 
-		msleep(1);
+		usleep_range(1000, 2000);
 	}
 
 	return vchiq_status_to_vchi(status);
Signature · 1 line
2.7.4