* [PATCH] leds: ledtrig-activity: use ktime_get_boot_ns()
@ 2018-06-18 14:41 Arnd Bergmann
2018-06-18 15:07 ` Pavel Machek
0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2018-06-18 14:41 UTC (permalink / raw)
To: Jacek Anaszewski, Pavel Machek
Cc: y2038, Arnd Bergmann, Kees Cook, Willy Tarreau, linux-leds,
linux-kernel
get_monotonic_boottime() is deprecated, so let's convert this to
the simpler ktime_get_boot_ns().
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/leds/trigger/ledtrig-activity.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/leds/trigger/ledtrig-activity.c b/drivers/leds/trigger/ledtrig-activity.c
index 5081894082bd..589c1bc4d0b9 100644
--- a/drivers/leds/trigger/ledtrig-activity.c
+++ b/drivers/leds/trigger/ledtrig-activity.c
@@ -37,7 +37,6 @@ static void led_activity_function(struct timer_list *t)
struct activity_data *activity_data = from_timer(activity_data, t,
timer);
struct led_classdev *led_cdev = activity_data->led_cdev;
- struct timespec boot_time;
unsigned int target;
unsigned int usage;
int delay;
@@ -57,7 +56,7 @@ static void led_activity_function(struct timer_list *t)
return;
}
- get_monotonic_boottime(&boot_time);
+ curr_boot = ktime_get_boot_ns();
cpus = 0;
curr_used = 0;
@@ -76,7 +75,6 @@ static void led_activity_function(struct timer_list *t)
* down to 16us, ensuring we won't overflow 32-bit computations below
* even up to 3k CPUs, while keeping divides cheap on smaller systems.
*/
- curr_boot = timespec_to_ns(&boot_time) * cpus;
diff_boot = (curr_boot - activity_data->last_boot) >> 16;
diff_used = (curr_used - activity_data->last_used) >> 16;
activity_data->last_boot = curr_boot;
--
2.9.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] leds: ledtrig-activity: use ktime_get_boot_ns()
2018-06-18 14:41 [PATCH] leds: ledtrig-activity: use ktime_get_boot_ns() Arnd Bergmann
@ 2018-06-18 15:07 ` Pavel Machek
2018-06-18 15:47 ` Arnd Bergmann
0 siblings, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2018-06-18 15:07 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Jacek Anaszewski, y2038, Kees Cook, Willy Tarreau, linux-leds,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1504 bytes --]
Hi!
> get_monotonic_boottime() is deprecated, so let's convert this to
> the simpler ktime_get_boot_ns().
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Have you tested it?
> diff --git a/drivers/leds/trigger/ledtrig-activity.c b/drivers/leds/trigger/ledtrig-activity.c
> index 5081894082bd..589c1bc4d0b9 100644
> --- a/drivers/leds/trigger/ledtrig-activity.c
> +++ b/drivers/leds/trigger/ledtrig-activity.c
> @@ -37,7 +37,6 @@ static void led_activity_function(struct timer_list *t)
> struct activity_data *activity_data = from_timer(activity_data, t,
> timer);
> struct led_classdev *led_cdev = activity_data->led_cdev;
> - struct timespec boot_time;
> unsigned int target;
> unsigned int usage;
> int delay;
> @@ -57,7 +56,7 @@ static void led_activity_function(struct timer_list *t)
> return;
> }
>
> - get_monotonic_boottime(&boot_time);
> + curr_boot = ktime_get_boot_ns();
>
> cpus = 0;
> curr_used = 0;
> @@ -76,7 +75,6 @@ static void led_activity_function(struct timer_list *t)
> * down to 16us, ensuring we won't overflow 32-bit computations below
> * even up to 3k CPUs, while keeping divides cheap on smaller systems.
> */
> - curr_boot = timespec_to_ns(&boot_time) * cpus;
Original code is pretty weird (notice the * cpus), so I'm
double-checking.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] leds: ledtrig-activity: use ktime_get_boot_ns()
2018-06-18 15:07 ` Pavel Machek
@ 2018-06-18 15:47 ` Arnd Bergmann
2018-06-18 15:55 ` Pavel Machek
2018-06-18 18:29 ` Willy Tarreau
0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2018-06-18 15:47 UTC (permalink / raw)
To: Pavel Machek
Cc: Jacek Anaszewski, y2038 Mailman List, Kees Cook, Willy Tarreau,
linux-leds, Linux Kernel Mailing List
On Mon, Jun 18, 2018 at 5:07 PM, Pavel Machek <pavel@ucw.cz> wrote:
> Hi!
>
>> get_monotonic_boottime() is deprecated, so let's convert this to
>> the simpler ktime_get_boot_ns().
>>
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Have you tested it?
No, only build-tested.
>> diff --git a/drivers/leds/trigger/ledtrig-activity.c b/drivers/leds/trigger/ledtrig-activity.c
>> index 5081894082bd..589c1bc4d0b9 100644
>> --- a/drivers/leds/trigger/ledtrig-activity.c
>> +++ b/drivers/leds/trigger/ledtrig-activity.c
>> @@ -37,7 +37,6 @@ static void led_activity_function(struct timer_list *t)
>> struct activity_data *activity_data = from_timer(activity_data, t,
>> timer);
>> struct led_classdev *led_cdev = activity_data->led_cdev;
>> - struct timespec boot_time;
>> unsigned int target;
>> unsigned int usage;
>> int delay;
>> @@ -57,7 +56,7 @@ static void led_activity_function(struct timer_list *t)
>> return;
>> }
>>
>> - get_monotonic_boottime(&boot_time);
>> + curr_boot = ktime_get_boot_ns();
>>
>> cpus = 0;
>> curr_used = 0;
>> @@ -76,7 +75,6 @@ static void led_activity_function(struct timer_list *t)
>> * down to 16us, ensuring we won't overflow 32-bit computations below
>> * even up to 3k CPUs, while keeping divides cheap on smaller systems.
>> */
>> - curr_boot = timespec_to_ns(&boot_time) * cpus;
>
> Original code is pretty weird (notice the * cpus), so I'm
> double-checking.
Ok, dropping the *cpus was not intentional, I'll repost a version that puts
it that back. Thanks for pointing this out!
Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] leds: ledtrig-activity: use ktime_get_boot_ns()
2018-06-18 15:47 ` Arnd Bergmann
@ 2018-06-18 15:55 ` Pavel Machek
2018-06-18 18:29 ` Willy Tarreau
1 sibling, 0 replies; 5+ messages in thread
From: Pavel Machek @ 2018-06-18 15:55 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Jacek Anaszewski, y2038 Mailman List, Kees Cook, Willy Tarreau,
linux-leds, Linux Kernel Mailing List
[-- Attachment #1: Type: text/plain, Size: 1610 bytes --]
> >> index 5081894082bd..589c1bc4d0b9 100644
> >> --- a/drivers/leds/trigger/ledtrig-activity.c
> >> +++ b/drivers/leds/trigger/ledtrig-activity.c
> >> @@ -37,7 +37,6 @@ static void led_activity_function(struct timer_list *t)
> >> struct activity_data *activity_data = from_timer(activity_data, t,
> >> timer);
> >> struct led_classdev *led_cdev = activity_data->led_cdev;
> >> - struct timespec boot_time;
> >> unsigned int target;
> >> unsigned int usage;
> >> int delay;
> >> @@ -57,7 +56,7 @@ static void led_activity_function(struct timer_list *t)
> >> return;
> >> }
> >>
> >> - get_monotonic_boottime(&boot_time);
> >> + curr_boot = ktime_get_boot_ns();
> >>
> >> cpus = 0;
> >> curr_used = 0;
> >> @@ -76,7 +75,6 @@ static void led_activity_function(struct timer_list *t)
> >> * down to 16us, ensuring we won't overflow 32-bit computations below
> >> * even up to 3k CPUs, while keeping divides cheap on smaller systems.
> >> */
> >> - curr_boot = timespec_to_ns(&boot_time) * cpus;
> >
> > Original code is pretty weird (notice the * cpus), so I'm
> > double-checking.
>
> Ok, dropping the *cpus was not intentional, I'll repost a version that puts
> it that back. Thanks for pointing this out!
Feel free to add my Acked-by to fixed version.
Thanks,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] leds: ledtrig-activity: use ktime_get_boot_ns()
2018-06-18 15:47 ` Arnd Bergmann
2018-06-18 15:55 ` Pavel Machek
@ 2018-06-18 18:29 ` Willy Tarreau
1 sibling, 0 replies; 5+ messages in thread
From: Willy Tarreau @ 2018-06-18 18:29 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Kees Cook, y2038 Mailman List, Linux Kernel Mailing List,
Jacek Anaszewski, Pavel Machek, linux-leds
Hi Arnd,
On Mon, Jun 18, 2018 at 05:47:28PM +0200, Arnd Bergmann wrote:
> On Mon, Jun 18, 2018 at 5:07 PM, Pavel Machek <pavel@ucw.cz> wrote:
> >> diff --git a/drivers/leds/trigger/ledtrig-activity.c b/drivers/leds/trigger/ledtrig-activity.c
> >> index 5081894082bd..589c1bc4d0b9 100644
> >> --- a/drivers/leds/trigger/ledtrig-activity.c
> >> +++ b/drivers/leds/trigger/ledtrig-activity.c
> >> @@ -37,7 +37,6 @@ static void led_activity_function(struct timer_list *t)
> >> struct activity_data *activity_data = from_timer(activity_data, t,
> >> timer);
> >> struct led_classdev *led_cdev = activity_data->led_cdev;
> >> - struct timespec boot_time;
> >> unsigned int target;
> >> unsigned int usage;
> >> int delay;
> >> @@ -57,7 +56,7 @@ static void led_activity_function(struct timer_list *t)
> >> return;
> >> }
> >>
> >> - get_monotonic_boottime(&boot_time);
> >> + curr_boot = ktime_get_boot_ns();
> >>
> >> cpus = 0;
> >> curr_used = 0;
> >> @@ -76,7 +75,6 @@ static void led_activity_function(struct timer_list *t)
> >> * down to 16us, ensuring we won't overflow 32-bit computations below
> >> * even up to 3k CPUs, while keeping divides cheap on smaller systems.
> >> */
> >> - curr_boot = timespec_to_ns(&boot_time) * cpus;
> >
> > Original code is pretty weird (notice the * cpus), so I'm
> > double-checking.
>
> Ok, dropping the *cpus was not intentional, I'll repost a version that puts
> it that back. Thanks for pointing this out!
Pavel is right, the *cpus is intentional. curr_boot contains the cumulated
time for all CPUs in order to measure an average usage over all of them.
By keeping it scaled by #cpus we avoid useless divides.
Cheers,
Willy
_______________________________________________
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-06-18 18:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-18 14:41 [PATCH] leds: ledtrig-activity: use ktime_get_boot_ns() Arnd Bergmann
2018-06-18 15:07 ` Pavel Machek
2018-06-18 15:47 ` Arnd Bergmann
2018-06-18 15:55 ` Pavel Machek
2018-06-18 18:29 ` Willy Tarreau
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).