* [PATCH] intel_ips: Convert timers to use timer_setup()
@ 2017-10-05 0:54 Kees Cook
2017-10-05 8:41 ` Andy Shevchenko
0 siblings, 1 reply; 7+ messages in thread
From: Kees Cook @ 2017-10-05 0:54 UTC (permalink / raw)
To: linux-kernel
Cc: Darren Hart, Andy Shevchenko, platform-driver-x86, Thomas Gleixner
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly. Moves timer structure off stack and
into struct ips_driver.
Cc: Darren Hart <dvhart@infradead.org>
Cc: Andy Shevchenko <andy@infradead.org>
Cc: platform-driver-x86@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
This requires commit 686fef928bba ("timer: Prepare to change timer
callback argument type") in v4.14-rc3, but should be otherwise
stand-alone.
---
drivers/platform/x86/intel_ips.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c
index 58dcee562d64..056afb731d79 100644
--- a/drivers/platform/x86/intel_ips.c
+++ b/drivers/platform/x86/intel_ips.c
@@ -300,6 +300,7 @@ struct ips_driver {
struct task_struct *monitor;
struct task_struct *adjust;
struct dentry *debug_root;
+ struct timer_list timer;
/* Average CPU core temps (all averages in .01 degrees C for precision) */
u16 ctv1_avg_temp;
@@ -942,9 +943,10 @@ static u32 calc_avg_power(struct ips_driver *ips, u32 *array)
return avg;
}
-static void monitor_timeout(unsigned long arg)
+static void monitor_timeout(struct timer_list *t)
{
- wake_up_process((struct task_struct *)arg);
+ struct ips_driver *ips = from_timer(ips, t, timer);
+ wake_up_process(ips->monitor);
}
/**
@@ -961,7 +963,6 @@ static void monitor_timeout(unsigned long arg)
static int ips_monitor(void *data)
{
struct ips_driver *ips = data;
- struct timer_list timer;
unsigned long seqno_timestamp, expire, last_msecs, last_sample_period;
int i;
u32 *cpu_samples, *mchp_samples, old_cpu_power;
@@ -1049,8 +1050,7 @@ static int ips_monitor(void *data)
schedule_timeout_interruptible(msecs_to_jiffies(IPS_SAMPLE_PERIOD));
last_sample_period = IPS_SAMPLE_PERIOD;
- setup_deferrable_timer_on_stack(&timer, monitor_timeout,
- (unsigned long)current);
+ timer_setup(&ips->timer, monitor_timeout, TIMER_DEFERRABLE);
do {
u32 cpu_val, mch_val;
u16 val;
@@ -1107,7 +1107,7 @@ static int ips_monitor(void *data)
expire = jiffies + msecs_to_jiffies(IPS_SAMPLE_PERIOD);
__set_current_state(TASK_INTERRUPTIBLE);
- mod_timer(&timer, expire);
+ mod_timer(&ips->timer, expire);
schedule();
/* Calculate actual sample period for power averaging */
@@ -1116,8 +1116,7 @@ static int ips_monitor(void *data)
last_sample_period = 1;
} while (!kthread_should_stop());
- del_timer_sync(&timer);
- destroy_timer_on_stack(&timer);
+ del_timer_sync(&ips->timer);
dev_dbg(&ips->dev->dev, "ips-monitor thread stopped\n");
--
2.7.4
--
Kees Cook
Pixel Security
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] intel_ips: Convert timers to use timer_setup()
2017-10-05 0:54 [PATCH] intel_ips: Convert timers to use timer_setup() Kees Cook
@ 2017-10-05 8:41 ` Andy Shevchenko
2017-11-02 19:55 ` Kees Cook
0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2017-10-05 8:41 UTC (permalink / raw)
To: Kees Cook
Cc: linux-kernel, Darren Hart, Andy Shevchenko, Platform Driver,
Thomas Gleixner
On Thu, Oct 5, 2017 at 3:54 AM, Kees Cook <keescook@chromium.org> wrote:
> In preparation for unconditionally passing the struct timer_list pointer to
> all timer callbacks, switch to using the new timer_setup() and from_timer()
> to pass the timer pointer explicitly. Moves timer structure off stack and
> into struct ips_driver.
Pushed to my testing queue, thanks!
>
> Cc: Darren Hart <dvhart@infradead.org>
> Cc: Andy Shevchenko <andy@infradead.org>
> Cc: platform-driver-x86@vger.kernel.org
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
> This requires commit 686fef928bba ("timer: Prepare to change timer
> callback argument type") in v4.14-rc3, but should be otherwise
> stand-alone.
> ---
> drivers/platform/x86/intel_ips.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c
> index 58dcee562d64..056afb731d79 100644
> --- a/drivers/platform/x86/intel_ips.c
> +++ b/drivers/platform/x86/intel_ips.c
> @@ -300,6 +300,7 @@ struct ips_driver {
> struct task_struct *monitor;
> struct task_struct *adjust;
> struct dentry *debug_root;
> + struct timer_list timer;
>
> /* Average CPU core temps (all averages in .01 degrees C for precision) */
> u16 ctv1_avg_temp;
> @@ -942,9 +943,10 @@ static u32 calc_avg_power(struct ips_driver *ips, u32 *array)
> return avg;
> }
>
> -static void monitor_timeout(unsigned long arg)
> +static void monitor_timeout(struct timer_list *t)
> {
> - wake_up_process((struct task_struct *)arg);
> + struct ips_driver *ips = from_timer(ips, t, timer);
> + wake_up_process(ips->monitor);
> }
>
> /**
> @@ -961,7 +963,6 @@ static void monitor_timeout(unsigned long arg)
> static int ips_monitor(void *data)
> {
> struct ips_driver *ips = data;
> - struct timer_list timer;
> unsigned long seqno_timestamp, expire, last_msecs, last_sample_period;
> int i;
> u32 *cpu_samples, *mchp_samples, old_cpu_power;
> @@ -1049,8 +1050,7 @@ static int ips_monitor(void *data)
> schedule_timeout_interruptible(msecs_to_jiffies(IPS_SAMPLE_PERIOD));
> last_sample_period = IPS_SAMPLE_PERIOD;
>
> - setup_deferrable_timer_on_stack(&timer, monitor_timeout,
> - (unsigned long)current);
> + timer_setup(&ips->timer, monitor_timeout, TIMER_DEFERRABLE);
> do {
> u32 cpu_val, mch_val;
> u16 val;
> @@ -1107,7 +1107,7 @@ static int ips_monitor(void *data)
> expire = jiffies + msecs_to_jiffies(IPS_SAMPLE_PERIOD);
>
> __set_current_state(TASK_INTERRUPTIBLE);
> - mod_timer(&timer, expire);
> + mod_timer(&ips->timer, expire);
> schedule();
>
> /* Calculate actual sample period for power averaging */
> @@ -1116,8 +1116,7 @@ static int ips_monitor(void *data)
> last_sample_period = 1;
> } while (!kthread_should_stop());
>
> - del_timer_sync(&timer);
> - destroy_timer_on_stack(&timer);
> + del_timer_sync(&ips->timer);
>
> dev_dbg(&ips->dev->dev, "ips-monitor thread stopped\n");
>
> --
> 2.7.4
>
>
> --
> Kees Cook
> Pixel Security
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] intel_ips: Convert timers to use timer_setup()
2017-10-05 8:41 ` Andy Shevchenko
@ 2017-11-02 19:55 ` Kees Cook
2017-11-03 12:26 ` Andy Shevchenko
0 siblings, 1 reply; 7+ messages in thread
From: Kees Cook @ 2017-11-02 19:55 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-kernel, Darren Hart, Andy Shevchenko, Platform Driver,
Thomas Gleixner
On Thu, Oct 5, 2017 at 1:41 AM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Thu, Oct 5, 2017 at 3:54 AM, Kees Cook <keescook@chromium.org> wrote:
>> In preparation for unconditionally passing the struct timer_list pointer to
>> all timer callbacks, switch to using the new timer_setup() and from_timer()
>> to pass the timer pointer explicitly. Moves timer structure off stack and
>> into struct ips_driver.
>
> Pushed to my testing queue, thanks!
Hi,
I don't see this in -next yet. Should the tip tree carry this conversion?
Thanks!
-Kees
>
>>
>> Cc: Darren Hart <dvhart@infradead.org>
>> Cc: Andy Shevchenko <andy@infradead.org>
>> Cc: platform-driver-x86@vger.kernel.org
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>> ---
>> This requires commit 686fef928bba ("timer: Prepare to change timer
>> callback argument type") in v4.14-rc3, but should be otherwise
>> stand-alone.
>> ---
>> drivers/platform/x86/intel_ips.c | 15 +++++++--------
>> 1 file changed, 7 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c
>> index 58dcee562d64..056afb731d79 100644
>> --- a/drivers/platform/x86/intel_ips.c
>> +++ b/drivers/platform/x86/intel_ips.c
>> @@ -300,6 +300,7 @@ struct ips_driver {
>> struct task_struct *monitor;
>> struct task_struct *adjust;
>> struct dentry *debug_root;
>> + struct timer_list timer;
>>
>> /* Average CPU core temps (all averages in .01 degrees C for precision) */
>> u16 ctv1_avg_temp;
>> @@ -942,9 +943,10 @@ static u32 calc_avg_power(struct ips_driver *ips, u32 *array)
>> return avg;
>> }
>>
>> -static void monitor_timeout(unsigned long arg)
>> +static void monitor_timeout(struct timer_list *t)
>> {
>> - wake_up_process((struct task_struct *)arg);
>> + struct ips_driver *ips = from_timer(ips, t, timer);
>> + wake_up_process(ips->monitor);
>> }
>>
>> /**
>> @@ -961,7 +963,6 @@ static void monitor_timeout(unsigned long arg)
>> static int ips_monitor(void *data)
>> {
>> struct ips_driver *ips = data;
>> - struct timer_list timer;
>> unsigned long seqno_timestamp, expire, last_msecs, last_sample_period;
>> int i;
>> u32 *cpu_samples, *mchp_samples, old_cpu_power;
>> @@ -1049,8 +1050,7 @@ static int ips_monitor(void *data)
>> schedule_timeout_interruptible(msecs_to_jiffies(IPS_SAMPLE_PERIOD));
>> last_sample_period = IPS_SAMPLE_PERIOD;
>>
>> - setup_deferrable_timer_on_stack(&timer, monitor_timeout,
>> - (unsigned long)current);
>> + timer_setup(&ips->timer, monitor_timeout, TIMER_DEFERRABLE);
>> do {
>> u32 cpu_val, mch_val;
>> u16 val;
>> @@ -1107,7 +1107,7 @@ static int ips_monitor(void *data)
>> expire = jiffies + msecs_to_jiffies(IPS_SAMPLE_PERIOD);
>>
>> __set_current_state(TASK_INTERRUPTIBLE);
>> - mod_timer(&timer, expire);
>> + mod_timer(&ips->timer, expire);
>> schedule();
>>
>> /* Calculate actual sample period for power averaging */
>> @@ -1116,8 +1116,7 @@ static int ips_monitor(void *data)
>> last_sample_period = 1;
>> } while (!kthread_should_stop());
>>
>> - del_timer_sync(&timer);
>> - destroy_timer_on_stack(&timer);
>> + del_timer_sync(&ips->timer);
>>
>> dev_dbg(&ips->dev->dev, "ips-monitor thread stopped\n");
>>
>> --
>> 2.7.4
>>
>>
>> --
>> Kees Cook
>> Pixel Security
>
>
>
> --
> With Best Regards,
> Andy Shevchenko
--
Kees Cook
Pixel Security
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] intel_ips: Convert timers to use timer_setup()
2017-11-02 19:55 ` Kees Cook
@ 2017-11-03 12:26 ` Andy Shevchenko
2017-11-18 1:30 ` Kees Cook
0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2017-11-03 12:26 UTC (permalink / raw)
To: Kees Cook
Cc: linux-kernel, Darren Hart, Andy Shevchenko, Platform Driver,
Thomas Gleixner
On Thu, Nov 2, 2017 at 9:55 PM, Kees Cook <keescook@chromium.org> wrote:
> On Thu, Oct 5, 2017 at 1:41 AM, Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
>> On Thu, Oct 5, 2017 at 3:54 AM, Kees Cook <keescook@chromium.org> wrote:
>>> In preparation for unconditionally passing the struct timer_list pointer to
>>> all timer callbacks, switch to using the new timer_setup() and from_timer()
>>> to pass the timer pointer explicitly. Moves timer structure off stack and
>>> into struct ips_driver.
>>
>> Pushed to my testing queue, thanks!
>
> Hi,
>
> I don't see this in -next yet. Should the tip tree carry this conversion?
I thought it was a result of discussion since we lack of patch that
brought the core change.
However, because I merged Wolfram's immutable branch in order to apply
Hans' fix, I can carry your patch as well.
Either would be fine with me.
Going ahead, I applied it to my review and testing queue, thanks!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] intel_ips: Convert timers to use timer_setup()
2017-11-03 12:26 ` Andy Shevchenko
@ 2017-11-18 1:30 ` Kees Cook
2017-11-20 19:45 ` Darren Hart
0 siblings, 1 reply; 7+ messages in thread
From: Kees Cook @ 2017-11-18 1:30 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-kernel, Darren Hart, Andy Shevchenko, Platform Driver,
Thomas Gleixner
On Fri, Nov 3, 2017 at 5:26 AM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Thu, Nov 2, 2017 at 9:55 PM, Kees Cook <keescook@chromium.org> wrote:
>> On Thu, Oct 5, 2017 at 1:41 AM, Andy Shevchenko
>> <andy.shevchenko@gmail.com> wrote:
>>> On Thu, Oct 5, 2017 at 3:54 AM, Kees Cook <keescook@chromium.org> wrote:
>>>> In preparation for unconditionally passing the struct timer_list pointer to
>>>> all timer callbacks, switch to using the new timer_setup() and from_timer()
>>>> to pass the timer pointer explicitly. Moves timer structure off stack and
>>>> into struct ips_driver.
>>>
>>> Pushed to my testing queue, thanks!
>>
>> Hi,
>>
>> I don't see this in -next yet. Should the tip tree carry this conversion?
>
> I thought it was a result of discussion since we lack of patch that
> brought the core change.
>
> However, because I merged Wolfram's immutable branch in order to apply
> Hans' fix, I can carry your patch as well.
>
> Either would be fine with me.
>
> Going ahead, I applied it to my review and testing queue, thanks!
Hi again!
I'm just checking on this patch -- I haven't seen it in a pull request
to Linus yet (for the merge window he's threatened will be small).
This is one of the remaining conversion patches I need in v4.15. Is
this still planned to be merged for v4.15?
Thanks!
-Kees
--
Kees Cook
Pixel Security
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] intel_ips: Convert timers to use timer_setup()
2017-11-18 1:30 ` Kees Cook
@ 2017-11-20 19:45 ` Darren Hart
2017-11-20 19:46 ` Kees Cook
0 siblings, 1 reply; 7+ messages in thread
From: Darren Hart @ 2017-11-20 19:45 UTC (permalink / raw)
To: Kees Cook
Cc: Andy Shevchenko, linux-kernel, Andy Shevchenko, Platform Driver,
Thomas Gleixner
On Fri, Nov 17, 2017 at 05:30:48PM -0800, Kees Cook wrote:
> On Fri, Nov 3, 2017 at 5:26 AM, Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Thu, Nov 2, 2017 at 9:55 PM, Kees Cook <keescook@chromium.org> wrote:
> >> On Thu, Oct 5, 2017 at 1:41 AM, Andy Shevchenko
> >> <andy.shevchenko@gmail.com> wrote:
> >>> On Thu, Oct 5, 2017 at 3:54 AM, Kees Cook <keescook@chromium.org> wrote:
> >>>> In preparation for unconditionally passing the struct timer_list pointer to
> >>>> all timer callbacks, switch to using the new timer_setup() and from_timer()
> >>>> to pass the timer pointer explicitly. Moves timer structure off stack and
> >>>> into struct ips_driver.
> >>>
> >>> Pushed to my testing queue, thanks!
> >>
> >> Hi,
> >>
> >> I don't see this in -next yet. Should the tip tree carry this conversion?
> >
> > I thought it was a result of discussion since we lack of patch that
> > brought the core change.
> >
> > However, because I merged Wolfram's immutable branch in order to apply
> > Hans' fix, I can carry your patch as well.
> >
> > Either would be fine with me.
> >
> > Going ahead, I applied it to my review and testing queue, thanks!
>
> Hi again!
>
> I'm just checking on this patch -- I haven't seen it in a pull request
> to Linus yet (for the merge window he's threatened will be small).
> This is one of the remaining conversion patches I need in v4.15. Is
> this still planned to be merged for v4.15?
Hi Kees,
It went out the day after your note above in the platform-drivers-x86-v4.15-1
pull request. We're working through some issues with this pull request with
Linus now, but yes, it will make 4.15.
--
Darren Hart
VMware Open Source Technology Center
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] intel_ips: Convert timers to use timer_setup()
2017-11-20 19:45 ` Darren Hart
@ 2017-11-20 19:46 ` Kees Cook
0 siblings, 0 replies; 7+ messages in thread
From: Kees Cook @ 2017-11-20 19:46 UTC (permalink / raw)
To: Darren Hart
Cc: Andy Shevchenko, linux-kernel, Andy Shevchenko, Platform Driver,
Thomas Gleixner
On Mon, Nov 20, 2017 at 11:45 AM, Darren Hart <dvhart@infradead.org> wrote:
> On Fri, Nov 17, 2017 at 05:30:48PM -0800, Kees Cook wrote:
>> On Fri, Nov 3, 2017 at 5:26 AM, Andy Shevchenko
>> <andy.shevchenko@gmail.com> wrote:
>> > On Thu, Nov 2, 2017 at 9:55 PM, Kees Cook <keescook@chromium.org> wrote:
>> >> On Thu, Oct 5, 2017 at 1:41 AM, Andy Shevchenko
>> >> <andy.shevchenko@gmail.com> wrote:
>> >>> On Thu, Oct 5, 2017 at 3:54 AM, Kees Cook <keescook@chromium.org> wrote:
>> >>>> In preparation for unconditionally passing the struct timer_list pointer to
>> >>>> all timer callbacks, switch to using the new timer_setup() and from_timer()
>> >>>> to pass the timer pointer explicitly. Moves timer structure off stack and
>> >>>> into struct ips_driver.
>> >>>
>> >>> Pushed to my testing queue, thanks!
>> >>
>> >> Hi,
>> >>
>> >> I don't see this in -next yet. Should the tip tree carry this conversion?
>> >
>> > I thought it was a result of discussion since we lack of patch that
>> > brought the core change.
>> >
>> > However, because I merged Wolfram's immutable branch in order to apply
>> > Hans' fix, I can carry your patch as well.
>> >
>> > Either would be fine with me.
>> >
>> > Going ahead, I applied it to my review and testing queue, thanks!
>>
>> Hi again!
>>
>> I'm just checking on this patch -- I haven't seen it in a pull request
>> to Linus yet (for the merge window he's threatened will be small).
>> This is one of the remaining conversion patches I need in v4.15. Is
>> this still planned to be merged for v4.15?
>
> Hi Kees,
>
> It went out the day after your note above in the platform-drivers-x86-v4.15-1
> pull request. We're working through some issues with this pull request with
> Linus now, but yes, it will make 4.15.
Awesome, thanks! I see it in the tree now. Yay! :)
-Kees
--
Kees Cook
Pixel Security
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-11-20 19:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-05 0:54 [PATCH] intel_ips: Convert timers to use timer_setup() Kees Cook
2017-10-05 8:41 ` Andy Shevchenko
2017-11-02 19:55 ` Kees Cook
2017-11-03 12:26 ` Andy Shevchenko
2017-11-18 1:30 ` Kees Cook
2017-11-20 19:45 ` Darren Hart
2017-11-20 19:46 ` Kees Cook
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).