timer_cpu_notify() should return NOTIFY_OK and nothing else. Anything else would trigger a BUG_ON(). Return value of this routine is already checked correctly but is done after issuing a call to init_timer_stats(). The right order would be to check the error case first and then call init_timer_stats(). Lets do it.
Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- kernel/timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/timer.c b/kernel/timer.c index f64a98c..e8e7839 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -1674,9 +1674,9 @@ void __init init_timers(void)
err = timer_cpu_notify(&timers_nb, (unsigned long)CPU_UP_PREPARE, (void *)(long)smp_processor_id()); - init_timer_stats(); - BUG_ON(err != NOTIFY_OK); + + init_timer_stats(); register_cpu_notifier(&timers_nb); open_softirq(TIMER_SOFTIRQ, run_timer_softirq); }
Currently we are using two lowest bit of base for internal purpose and so they both should be zero in the allocated address. The code was doing the right thing before this patch came in:
commit c5f66e99b7cb091e3d51ae8e8156892e8feb7fa3 Author: Tejun Heo tj@kernel.org Date: Wed Aug 8 11:10:28 2012 -0700
timer: Implement TIMER_IRQSAFE
Tejun probably forgot to update this piece of code which checks if the lowest 'n' bits are zero or not and so wasn't updated according to the new flag. Lets use TIMER_FLAG_MASK in the calculations here, so that this code wouldn't require a change later on with another flag in.
Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- kernel/timer.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/kernel/timer.c b/kernel/timer.c index e8e7839..d52a8ff 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -1548,9 +1548,8 @@ static int init_timers_cpu(int cpu) if (!base) return -ENOMEM;
- /* Make sure that tvec_base is 2 byte aligned */ - if (tbase_get_deferrable(base)) { - WARN_ON(1); + /* Make sure tvec_base has TIMER_FLAG_MASK bits free */ + if (WARN_ON(base != tbase_get_base(base))) { kfree(base); return -ENOMEM; }
On Fri, 28 Feb 2014, Viresh Kumar wrote:
Currently we are using two lowest bit of base for internal purpose and so they both should be zero in the allocated address. The code was doing the right thing before this patch came in:
commit c5f66e99b7cb091e3d51ae8e8156892e8feb7fa3 Author: Tejun Heo tj@kernel.org Date: Wed Aug 8 11:10:28 2012 -0700
timer: Implement TIMER_IRQSAFE
Tejun probably forgot to update this piece of code which checks if the lowest 'n' bits are zero or not and so wasn't updated according to the new flag. Lets use TIMER_FLAG_MASK in the calculations here, so that this code wouldn't require a change later on with another flag in.
Are you planning to introduce more flag horror? Don't go there. The timer_list code is about to be rewritten completely and I'm not going to add new features to the existing code base.
Signed-off-by: Viresh Kumar viresh.kumar@linaro.org
kernel/timer.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/kernel/timer.c b/kernel/timer.c index e8e7839..d52a8ff 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -1548,9 +1548,8 @@ static int init_timers_cpu(int cpu) if (!base) return -ENOMEM;
/* Make sure that tvec_base is 2 byte aligned */
if (tbase_get_deferrable(base)) {
WARN_ON(1);
/* Make sure tvec_base has TIMER_FLAG_MASK bits free */
if (WARN_ON(base != tbase_get_base(base))) { kfree(base); return -ENOMEM; }
-- 1.7.12.rc2.18.g61b472e
On 28-Feb-2014, at 4:22 pm, Thomas Gleixner tglx@linutronix.de wrote:
On Fri, 28 Feb 2014, Viresh Kumar wrote:
Currently we are using two lowest bit of base for internal purpose and so they both should be zero in the allocated address. The code was doing the right thing before this patch came in:
commit c5f66e99b7cb091e3d51ae8e8156892e8feb7fa3 Author: Tejun Heo tj@kernel.org Date: Wed Aug 8 11:10:28 2012 -0700
timer: Implement TIMER_IRQSAFE
Tejun probably forgot to update this piece of code which checks if the lowest 'n' bits are zero or not and so wasn't updated according to the new flag. Lets use TIMER_FLAG_MASK in the calculations here, so that this code wouldn't require a change later on with another flag in.
Are you planning to introduce more flag horror? Don't go there. The timer_list code is about to be rewritten completely and I'm not going to add new features to the existing code base.
Not at all. I was just trying to understand this framework and found this Issue.
Hi Thomas,
On 28 February 2014 18:52, Thomas Gleixner tglx@linutronix.de wrote:
On Fri, 28 Feb 2014, Viresh Kumar wrote:
Currently we are using two lowest bit of base for internal purpose and so they both should be zero in the allocated address. The code was doing the right thing before this patch came in:
commit c5f66e99b7cb091e3d51ae8e8156892e8feb7fa3 Author: Tejun Heo tj@kernel.org Date: Wed Aug 8 11:10:28 2012 -0700
timer: Implement TIMER_IRQSAFE
Tejun probably forgot to update this piece of code which checks if the lowest 'n' bits are zero or not and so wasn't updated according to the new flag. Lets use TIMER_FLAG_MASK in the calculations here, so that this code wouldn't require a change later on with another flag in.
Are you planning to introduce more flag horror? Don't go there. The timer_list code is about to be rewritten completely and I'm not going to add new features to the existing code base.
Do you already have stuff prepared that can be shared on that? I am asking because I am working on some CPU isolation stuff for Networking domain and it looks like I need to add another of these flags :( .. I know its just not acceptable and so wanted your thoughts on how can I get things fixed.
Peter asked me to implement something like cpuset.quiesce to move away all timers/workqueues/etc from a cpuset. It was proposed here:
https://lkml.org/lkml/2014/1/15/186
Now, I was looking to migrate away the timers first but I obviously shouldn't migrate the pinned timers. One way out to identify PINNED timers is to mark them PINNED with the flag bits, which you wouldn't allow. Can you give some other idea with which I can get this solved.
-- viresh
On 11 March 2014 15:56, Viresh Kumar viresh.kumar@linaro.org wrote:
Hi Thomas,
On 28 February 2014 18:52, Thomas Gleixner tglx@linutronix.de wrote:
On Fri, 28 Feb 2014, Viresh Kumar wrote:
Currently we are using two lowest bit of base for internal purpose and so they both should be zero in the allocated address. The code was doing the right thing before this patch came in:
commit c5f66e99b7cb091e3d51ae8e8156892e8feb7fa3 Author: Tejun Heo tj@kernel.org Date: Wed Aug 8 11:10:28 2012 -0700
timer: Implement TIMER_IRQSAFE
Tejun probably forgot to update this piece of code which checks if the lowest 'n' bits are zero or not and so wasn't updated according to the new flag. Lets use TIMER_FLAG_MASK in the calculations here, so that this code wouldn't require a change later on with another flag in.
Are you planning to introduce more flag horror? Don't go there. The timer_list code is about to be rewritten completely and I'm not going to add new features to the existing code base.
Do you already have stuff prepared that can be shared on that? I am asking because I am working on some CPU isolation stuff for Networking domain and it looks like I need to add another of these flags :( .. I know its just not acceptable and so wanted your thoughts on how can I get things fixed.
Peter asked me to implement something like cpuset.quiesce to move away all timers/workqueues/etc from a cpuset. It was proposed here:
https://lkml.org/lkml/2014/1/15/186
Now, I was looking to migrate away the timers first but I obviously shouldn't migrate the pinned timers. One way out to identify PINNED timers is to mark them PINNED with the flag bits, which you wouldn't allow. Can you give some other idea with which I can get this solved.
Ping!!
On Tue, 18 Mar 2014, Viresh Kumar wrote:
On 11 March 2014 15:56, Viresh Kumar viresh.kumar@linaro.org wrote:
Now, I was looking to migrate away the timers first but I obviously shouldn't migrate the pinned timers. One way out to identify PINNED timers is to mark them PINNED with the flag bits, which you wouldn't allow. Can you give some other idea with which I can get this solved.
Sigh, I really hoped to find some time to finish the rework, but then you get to debug bugs, solve the problem and are rewarded with a full inbox. Lather, rinse, repeat...
Go ahead and make the timer base aligned with more room for some bits to tweak. The new stuff will have a flags field where stuff like pinned is stored.
Thanks,
tglx
linaro-kernel@lists.linaro.org