* [PATCH] timer_list: Correct the show function for timer_list by using iter->now
[not found] <20130720054300.GA29718@xiaoyu.lan>
@ 2013-07-22 21:18 ` Nathan Zimmer
2013-07-23 7:18 ` Holger Hans Peter Freyther
0 siblings, 1 reply; 4+ messages in thread
From: Nathan Zimmer @ 2013-07-22 21:18 UTC (permalink / raw)
To: linux-kernel, holger; +Cc: Nathan Zimmer, stable, John Stultz, Thomas Gleixner
This patch corrects the issue with /proc/timer_list reported by Holger.
When reading from the proc file with a sufficently small buffer, 2k so not
really that small, there was one could get hung trying to read the file a
chunk at a time.
Signed-off-by Nathan Zimmer <nzimmer@sgi.com>
Reported-by: Holger Hans Peter Freyther <holger@freyther.de>
Cc: <stable@vger.kernel.org> # 3.10.x
Cc: John Stultz <john.stultz@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
kernel/time/timer_list.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
index 3bdf283..08d7fbd 100644
--- a/kernel/time/timer_list.c
+++ b/kernel/time/timer_list.c
@@ -265,10 +265,9 @@ static inline void timer_list_header(struct seq_file *m, u64 now)
static int timer_list_show(struct seq_file *m, void *v)
{
struct timer_list_iter *iter = v;
- u64 now = ktime_to_ns(ktime_get());
if (iter->cpu == -1 && !iter->second_pass)
- timer_list_header(m, now);
+ timer_list_header(m, iter->now);
else if (!iter->second_pass)
print_cpu(m, iter->cpu, iter->now);
#ifdef CONFIG_GENERIC_CLOCKEVENTS
--
1.8.2.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] timer_list: Correct the show function for timer_list by using iter->now
2013-07-22 21:18 ` [PATCH] timer_list: Correct the show function for timer_list by using iter->now Nathan Zimmer
@ 2013-07-23 7:18 ` Holger Hans Peter Freyther
2013-07-23 22:50 ` Nathan Zimmer
2013-07-24 14:31 ` [PATCH] timer_list: Correct the iterator for timer_list Nathan Zimmer
0 siblings, 2 replies; 4+ messages in thread
From: Holger Hans Peter Freyther @ 2013-07-23 7:18 UTC (permalink / raw)
To: Nathan Zimmer; +Cc: linux-kernel, stable, John Stultz, Thomas Gleixner
On Mon, Jul 22, 2013 at 04:18:31PM -0500, Nathan Zimmer wrote:
> This patch corrects the issue with /proc/timer_list reported by Holger.
> When reading from the proc file with a sufficently small buffer, 2k so not
> really that small, there was one could get hung trying to read the file a
> chunk at a time.
I think it makes sense to always use iter->now but it does not solve
the issue with dropbear/my test case. Or is this meant to be applied
on top of the previous patch?
holger
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] timer_list: Correct the show function for timer_list by using iter->now
2013-07-23 7:18 ` Holger Hans Peter Freyther
@ 2013-07-23 22:50 ` Nathan Zimmer
2013-07-24 14:31 ` [PATCH] timer_list: Correct the iterator for timer_list Nathan Zimmer
1 sibling, 0 replies; 4+ messages in thread
From: Nathan Zimmer @ 2013-07-23 22:50 UTC (permalink / raw)
To: Holger Hans Peter Freyther
Cc: linux-kernel, stable, John Stultz, Thomas Gleixner
On 07/23/2013 02:18 AM, Holger Hans Peter Freyther wrote:
> On Mon, Jul 22, 2013 at 04:18:31PM -0500, Nathan Zimmer wrote:
>> This patch corrects the issue with /proc/timer_list reported by Holger.
>> When reading from the proc file with a sufficently small buffer, 2k so not
>> really that small, there was one could get hung trying to read the file a
>> chunk at a time.
> I think it makes sense to always use iter->now but it does not solve
> the issue with dropbear/my test case. Or is this meant to be applied
> on top of the previous patch?
>
>
> holger
>
Ah sorry I networked booted the wrong kernel and got excited.
However after hitting my head against this for the better part of the
day I found
the root cause of my issue.
In seq_read about halfway down when we flush the buffer to userland.
m->index is advanced without calling m->op->next().
My iterator doesn't take notice of that and thus fails to advance.
/* if not empty - flush it first */
if (m->count) {
n = min(m->count, size);
err = copy_to_user(buf, m->buf + m->from, n);
if (err)
goto Efault;
m->count -= n;
m->from += n;
size -= n;
buf += n;
copied += n;
if (!m->count)
m->index++;
....
I'll need to think about how to correct it.
For the moment probably the right thing would be to revert b3956a896ea5
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] timer_list: Correct the iterator for timer_list
2013-07-23 7:18 ` Holger Hans Peter Freyther
2013-07-23 22:50 ` Nathan Zimmer
@ 2013-07-24 14:31 ` Nathan Zimmer
1 sibling, 0 replies; 4+ messages in thread
From: Nathan Zimmer @ 2013-07-24 14:31 UTC (permalink / raw)
To: linux-kernel, holger
Cc: mgalbraith, jkosina, Nathan Zimmer, stable, John Stultz,
Thomas Gleixner
This patch corrects the issue with /proc/timer_list reported by Holger.
When reading from the proc file with a sufficiently small buffer, 2k so not
really that small, there was one could get hung trying to read the file a
chunk at a time.
The timer_list_start function failed to account for the possibility that the
offset was adjusted outside the timer_list_next.
Signed-off-by: Nathan Zimmer <nzimmer@sgi.com>
Reported-by: Holger Hans Peter Freyther <holger@freyther.de>
Cc: <stable@vger.kernel.org> # 3.10.x
Cc: John Stultz <john.stultz@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
kernel/time/timer_list.c | 41 ++++++++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 17 deletions(-)
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
index 3bdf283..61ed862 100644
--- a/kernel/time/timer_list.c
+++ b/kernel/time/timer_list.c
@@ -265,10 +265,9 @@ static inline void timer_list_header(struct seq_file *m, u64 now)
static int timer_list_show(struct seq_file *m, void *v)
{
struct timer_list_iter *iter = v;
- u64 now = ktime_to_ns(ktime_get());
if (iter->cpu == -1 && !iter->second_pass)
- timer_list_header(m, now);
+ timer_list_header(m, iter->now);
else if (!iter->second_pass)
print_cpu(m, iter->cpu, iter->now);
#ifdef CONFIG_GENERIC_CLOCKEVENTS
@@ -298,33 +297,41 @@ void sysrq_timer_list_show(void)
return;
}
-static void *timer_list_start(struct seq_file *file, loff_t *offset)
+static void *move_iter(struct timer_list_iter *iter, loff_t offset)
{
- struct timer_list_iter *iter = file->private;
-
- if (!*offset) {
- iter->cpu = -1;
- iter->now = ktime_to_ns(ktime_get());
- } else if (iter->cpu >= nr_cpu_ids) {
+ for (; offset; offset--) {
+ iter->cpu = cpumask_next(iter->cpu, cpu_online_mask);
+ if (iter->cpu >= nr_cpu_ids) {
#ifdef CONFIG_GENERIC_CLOCKEVENTS
- if (!iter->second_pass) {
- iter->cpu = -1;
- iter->second_pass = true;
- } else
- return NULL;
+ if (!iter->second_pass) {
+ iter->cpu = -1;
+ iter->second_pass = true;
+ } else
+ return NULL;
#else
- return NULL;
+ return NULL;
#endif
+ }
}
return iter;
}
+static void *timer_list_start(struct seq_file *file, loff_t *offset)
+{
+ struct timer_list_iter *iter = file->private;
+
+ if (!*offset)
+ iter->now = ktime_to_ns(ktime_get());
+ iter->cpu = -1;
+ iter->second_pass = false;
+ return move_iter(iter, *offset);
+}
+
static void *timer_list_next(struct seq_file *file, void *v, loff_t *offset)
{
struct timer_list_iter *iter = file->private;
- iter->cpu = cpumask_next(iter->cpu, cpu_online_mask);
++*offset;
- return timer_list_start(file, offset);
+ return move_iter(iter, 1);
}
static void timer_list_stop(struct seq_file *seq, void *v)
--
1.8.2.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-07-24 14:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20130720054300.GA29718@xiaoyu.lan>
2013-07-22 21:18 ` [PATCH] timer_list: Correct the show function for timer_list by using iter->now Nathan Zimmer
2013-07-23 7:18 ` Holger Hans Peter Freyther
2013-07-23 22:50 ` Nathan Zimmer
2013-07-24 14:31 ` [PATCH] timer_list: Correct the iterator for timer_list Nathan Zimmer
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).