lock_dep: Fix missing entry in /proc/lock_stat
PATCH 1/5 lock_dep: Fix missing entry in /proc/lock_stat
One entry is missing in the output of /proc/lock_stat.
The cause is, when ls_start() is called the 2nd time, we should start from stats[@pos-1] but not stats[@pos], because pos == 0 is the header.
--- kernel/lockdep_proc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/lockdep_proc.c +1 -1
@@ -634,7 +634,7 @@ static void *ls_start(struct seq_file *m, loff_t *pos)if (*pos ==0 )return SEQ_START_TOKEN ; - data->iter = data->stats + *pos; + data->iter = data->stats + (*pos -1 );if (data->iter >= data->iter_end) data->iter =NULL ;
Signature · 1 line
1.6.3
PATCH 2/5 lock_dep: Fix missing entries in /proc/lock_chains
Two entries are missing in the output of /proc/lock_chains.
One is chains[1]. When lc_next() is called the 1st time, chains[0] is returned. And when it's called the 2nd time, chains[2] is returned.
The other missing ons is, when lc_start() is called the 2nd time, we should start from chains[@pos-1] but not chains[@pos], because pos == 0 is the header.
--- kernel/lockdep_proc.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
kernel/lockdep_proc.c +4 -4
@@ -160,8 +160,8 @@ static void *lc_next(struct seq_file *m, void *v, loff_t *pos)else { chain = v; -if (*pos < nr_lock_chains) - chain = lock_chains + *pos; +if (*pos -1 < nr_lock_chains) + chain = lock_chains + (*pos -1 );else chain =NULL ; }
@@ -174,8 +174,8 @@ static void *lc_start(struct seq_file *m, loff_t *pos)if (*pos ==0 )return SEQ_START_TOKEN ; -if (*pos < nr_lock_chains) -return lock_chains + *pos; +if (*pos -1 < nr_lock_chains) +return lock_chains + (*pos -1 );return NULL ; }
Signature · 1 line
1.6.3
[tip:core/locking] lockdep: Fix missing entries in /proc/lock_chains
Commit-ID: e9d65725bdf5954283625ca4d770bfc34f2ae56a Gitweb: http://git.kernel.org/tip/e9d65725bdf5954283625ca4d770bfc34f2ae56a Author: Li Zefan <[email protected]> AuthorDate: Mon, 17 Aug 2009 13:39:49 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 17 Aug 2009 09:54:40 +0200
lockdep: Fix missing entries in /proc/lock_chains
Two entries are missing in the output of /proc/lock_chains.
One is chains[1]. When lc_next() is called the 1st time, chains[0] is returned. And when it's called the 2nd time, chains[2] is returned.
The other missing ons is, when lc_start() is called the 2nd time, we should start from chains[@pos-1] but not chains[@pos], because pos == 0 is the header.
LKML-Reference: <[email protected]>
--- kernel/lockdep_proc.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
kernel/lockdep_proc.c +4 -4
@@ -160,8 +160,8 @@ static void *lc_next(struct seq_file *m, void *v, loff_t *pos)else { chain = v; -if (*pos < nr_lock_chains) - chain = lock_chains + *pos; +if (*pos -1 < nr_lock_chains) + chain = lock_chains + (*pos -1 );else chain =NULL ; }
@@ -174,8 +174,8 @@ static void *lc_start(struct seq_file *m, loff_t *pos)if (*pos ==0 )return SEQ_START_TOKEN ; -if (*pos < nr_lock_chains) -return lock_chains + *pos; +if (*pos -1 < nr_lock_chains) +return lock_chains + (*pos -1 );return NULL ; }
PATCH 3/5 lockdep: Simplify lockdep seqfile code
In reply to Li ZefanUse seq_list_start_head() and seq_list_next().
--- kernel/lockdep_proc.c | 46 +++++----------------------------------------- 1 files changed, 5 insertions(+), 41 deletions(-)
kernel/lockdep_proc.c +5 -41
@@ -25,38 +25,12 @@static void *l_next (struct seq_file *m,void *v,loff_t *pos) { -struct lock_class *class; - - (*pos)++; - -if (v ==SEQ_START_TOKEN ) - class = m->private; -else { - class = v; - -if (class->lock_entry.next != &all_lock_classes) - class =list_entry (class->lock_entry.next, - struct lock_class, lock_entry); -else - class =NULL ; - } - -return class; +return seq_list_next (v, &all_lock_classes, pos); }static void *l_start (struct seq_file *m,loff_t *pos) { -struct lock_class *class; -loff_t i =0 ; - -if (*pos ==0 ) -return SEQ_START_TOKEN ; - -list_for_each_entry (class, &all_lock_classes, lock_entry) { -if (++i == *pos) -return class; - } -return NULL ; +return seq_list_start_head (&all_lock_classes, *pos); }static void l_stop (struct seq_file *m,void *v)
@@ -82,11 +56,11 @@ static void print_name(struct seq_file *m, struct lock_class *class)static int l_show (struct seq_file *m,void *v) { -struct lock_class *class = v; + struct lock_class *class = list_entry(v, struct lock_class, lock_entry);struct lock_list *entry;char usage[LOCK_USAGE_CHARS ]; -if (v ==SEQ_START_TOKEN ) { +if (v == &all_lock_classes) {seq_printf (m,"all lock classes:\n" );return 0 ; }
@@ -128,17 +102,7 @@ static const struct seq_operations lockdep_ops = {static int lockdep_open (struct inode *inode,struct file *file) { -int res =seq_open (file, &lockdep_ops); -if (!res) { -struct seq_file *m = file->private_data; - -if (!list_empty (&all_lock_classes)) - m->private =list_entry (all_lock_classes.next, - struct lock_class, lock_entry); -else - m->private =NULL ; - } -return res; +return seq_open (file, &lockdep_ops); }static const struct file_operations proc_lockdep_operations = {
Signature · 1 line
1.6.3
[tip:core/locking] lockdep: Simplify lockdep seqfile code
Commit-ID: 8109e1de8502421f9efff1359f2779b1adcc0724 Gitweb: http://git.kernel.org/tip/8109e1de8502421f9efff1359f2779b1adcc0724 Author: Li Zefan <[email protected]> AuthorDate: Mon, 17 Aug 2009 13:40:17 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 17 Aug 2009 09:54:40 +0200
lockdep: Simplify lockdep seqfile code
Use seq_list_start_head() and seq_list_next().
LKML-Reference: <[email protected]>
--- kernel/lockdep_proc.c | 46 +++++----------------------------------------- 1 files changed, 5 insertions(+), 41 deletions(-)
kernel/lockdep_proc.c +5 -41
@@ -25,38 +25,12 @@static void *l_next (struct seq_file *m,void *v,loff_t *pos) { -struct lock_class *class; - - (*pos)++; - -if (v ==SEQ_START_TOKEN ) - class = m->private; -else { - class = v; - -if (class->lock_entry.next != &all_lock_classes) - class =list_entry (class->lock_entry.next, - struct lock_class, lock_entry); -else - class =NULL ; - } - -return class; +return seq_list_next (v, &all_lock_classes, pos); }static void *l_start (struct seq_file *m,loff_t *pos) { -struct lock_class *class; -loff_t i =0 ; - -if (*pos ==0 ) -return SEQ_START_TOKEN ; - -list_for_each_entry (class, &all_lock_classes, lock_entry) { -if (++i == *pos) -return class; - } -return NULL ; +return seq_list_start_head (&all_lock_classes, *pos); }static void l_stop (struct seq_file *m,void *v)
@@ -82,11 +56,11 @@ static void print_name(struct seq_file *m, struct lock_class *class)static int l_show (struct seq_file *m,void *v) { -struct lock_class *class = v; + struct lock_class *class = list_entry(v, struct lock_class, lock_entry);struct lock_list *entry;char usage[LOCK_USAGE_CHARS ]; -if (v ==SEQ_START_TOKEN ) { +if (v == &all_lock_classes) {seq_printf (m,"all lock classes:\n" );return 0 ; }
@@ -128,17 +102,7 @@ static const struct seq_operations lockdep_ops = {static int lockdep_open (struct inode *inode,struct file *file) { -int res =seq_open (file, &lockdep_ops); -if (!res) { -struct seq_file *m = file->private_data; - -if (!list_empty (&all_lock_classes)) - m->private =list_entry (all_lock_classes.next, - struct lock_class, lock_entry); -else - m->private =NULL ; - } -return res; +return seq_open (file, &lockdep_ops); }static const struct file_operations proc_lockdep_operations = {
PATCH 4/5 lockdep: Simplify lockdep_chains seqfile code
In reply to Li Zefan- make lc_next() call lc_start()
- use lock_chains directly instead of storing it in m->private
--- kernel/lockdep_proc.c | 37 +++++++------------------------------ 1 files changed, 7 insertions(+), 30 deletions(-)
kernel/lockdep_proc.c +7 -30
@@ -113,26 +113,6 @@ static const struct file_operations proc_lockdep_operations = { };#ifdef CONFIG_PROVE_LOCKING -static void *lc_next (struct seq_file *m,void *v,loff_t *pos) -{ -struct lock_chain *chain; - - (*pos)++; - -if (v ==SEQ_START_TOKEN ) - chain = m->private; -else { - chain = v; - -if (*pos -1 < nr_lock_chains) - chain = lock_chains + (*pos -1 ); -else - chain =NULL ; - } - -return chain; -} -static void *lc_start (struct seq_file *m,loff_t *pos) {if (*pos ==0 )
@@ -144,6 +124,12 @@ static void *lc_start(struct seq_file *m, loff_t *pos)return NULL ; } +static void *lc_next (struct seq_file *m,void *v,loff_t *pos) +{ + (*pos)++; +return lc_start (m, pos); +} +static void lc_stop (struct seq_file *m,void *v) { }
@@ -184,16 +170,7 @@ static const struct seq_operations lockdep_chains_ops = {static int lockdep_chains_open (struct inode *inode,struct file *file) { -int res =seq_open (file, &lockdep_chains_ops); -if (!res) { -struct seq_file *m = file->private_data; - -if (nr_lock_chains) - m->private = lock_chains; -else - m->private =NULL ; - } -return res; +return seq_open (file, &lockdep_chains_ops); }static const struct file_operations proc_lockdep_chains_operations = {
Signature · 1 line
1.6.3
[tip:core/locking] lockdep: Simplify lockdep_chains seqfile code
Commit-ID: 12aac19d4ba41019a1748f49d3c5d259b1bfb26d Gitweb: http://git.kernel.org/tip/12aac19d4ba41019a1748f49d3c5d259b1bfb26d Author: Li Zefan <[email protected]> AuthorDate: Mon, 17 Aug 2009 13:40:39 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 17 Aug 2009 09:54:41 +0200
lockdep: Simplify lockdep_chains seqfile code
- make lc_next() call lc_start()
- use lock_chains directly instead of storing it in m->private
LKML-Reference: <[email protected]>
--- kernel/lockdep_proc.c | 37 +++++++------------------------------ 1 files changed, 7 insertions(+), 30 deletions(-)
kernel/lockdep_proc.c +7 -30
@@ -113,26 +113,6 @@ static const struct file_operations proc_lockdep_operations = { };#ifdef CONFIG_PROVE_LOCKING -static void *lc_next (struct seq_file *m,void *v,loff_t *pos) -{ -struct lock_chain *chain; - - (*pos)++; - -if (v ==SEQ_START_TOKEN ) - chain = m->private; -else { - chain = v; - -if (*pos -1 < nr_lock_chains) - chain = lock_chains + (*pos -1 ); -else - chain =NULL ; - } - -return chain; -} -static void *lc_start (struct seq_file *m,loff_t *pos) {if (*pos ==0 )
@@ -144,6 +124,12 @@ static void *lc_start(struct seq_file *m, loff_t *pos)return NULL ; } +static void *lc_next (struct seq_file *m,void *v,loff_t *pos) +{ + (*pos)++; +return lc_start (m, pos); +} +static void lc_stop (struct seq_file *m,void *v) { }
@@ -184,16 +170,7 @@ static const struct seq_operations lockdep_chains_ops = {static int lockdep_chains_open (struct inode *inode,struct file *file) { -int res =seq_open (file, &lockdep_chains_ops); -if (!res) { -struct seq_file *m = file->private_data; - -if (nr_lock_chains) - m->private = lock_chains; -else - m->private =NULL ; - } -return res; +return seq_open (file, &lockdep_chains_ops); }static const struct file_operations proc_lockdep_chains_operations = {
PATCH 5/5 lockdep: Simplify lock_stat seqfile code
In reply to Li Zefan- make ls_next() call ls_start()
- remove redundant code in lock_stat_release()
--- kernel/lockdep_proc.c | 29 +++++++---------------------- 1 files changed, 7 insertions(+), 22 deletions(-)
kernel/lockdep_proc.c +7 -22
@@ -383,7 +383,6 @@ struct lock_stat_data { };struct lock_stat_seq { -struct lock_stat_data *iter;struct lock_stat_data *iter_end;struct lock_stat_data stats[MAX_LOCKDEP_KEYS ]; };
@@ -571,34 +570,22 @@ static void seq_header(struct seq_file *m)static void *ls_start (struct seq_file *m,loff_t *pos) {struct lock_stat_seq *data = m->private; +struct lock_stat_data *iter;if (*pos ==0 )return SEQ_START_TOKEN ; - data->iter = data->stats + (*pos -1 ); -if (data->iter >= data->iter_end) - data->iter =NULL ; + iter = data->stats + (*pos -1 ); +if (iter >= data->iter_end) + iter =NULL ; -return data->iter; +return iter; }static void *ls_next (struct seq_file *m,void *v,loff_t *pos) { -struct lock_stat_seq *data = m->private; - (*pos)++; - -if (v ==SEQ_START_TOKEN ) - data->iter = data->stats; -else { - data->iter = v; - data->iter++; - } - -if (data->iter == data->iter_end) - data->iter =NULL ; - -return data->iter; +return ls_start (m, pos); }static void ls_stop (struct seq_file *m,void *v)
@@ -636,7 +623,6 @@ static int lock_stat_open(struct inode *inode, struct file *file)struct lock_stat_data *iter = data->stats;struct seq_file *m = file->private_data; - data->iter = iter;list_for_each_entry (class, &all_lock_classes, lock_entry) { iter->class = class; iter->stats =lock_stats (class);
@@ -644,7 +630,7 @@ static int lock_stat_open(struct inode *inode, struct file *file) } data->iter_end = iter; -sort (data->stats, data->iter_end - data->iter, +sort (data->stats, data->iter_end - data->stats,sizeof (struct lock_stat_data ), lock_stat_cmp,NULL );
@@ -679,7 +665,6 @@ static int lock_stat_release(struct inode *inode, struct file *file)struct seq_file *seq = file->private_data;vfree (seq->private); - seq->private =NULL ;return seq_release (inode, file); }
Signature · 1 line
1.6.3
[tip:core/locking] lockdep: Simplify lock_stat seqfile code
Commit-ID: 96004bb2a1e4ccad2b1eeb92e51031d1e8e609e3 Gitweb: http://git.kernel.org/tip/96004bb2a1e4ccad2b1eeb92e51031d1e8e609e3 Author: Li Zefan <[email protected]> AuthorDate: Mon, 17 Aug 2009 13:40:59 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 17 Aug 2009 09:54:41 +0200
lockdep: Simplify lock_stat seqfile code
- make ls_next() call ls_start()
- remove redundant code in lock_stat_release()
LKML-Reference: <[email protected]>
--- kernel/lockdep_proc.c | 29 +++++++---------------------- 1 files changed, 7 insertions(+), 22 deletions(-)
kernel/lockdep_proc.c +7 -22
@@ -383,7 +383,6 @@ struct lock_stat_data { };struct lock_stat_seq { -struct lock_stat_data *iter;struct lock_stat_data *iter_end;struct lock_stat_data stats[MAX_LOCKDEP_KEYS ]; };
@@ -571,34 +570,22 @@ static void seq_header(struct seq_file *m)static void *ls_start (struct seq_file *m,loff_t *pos) {struct lock_stat_seq *data = m->private; +struct lock_stat_data *iter;if (*pos ==0 )return SEQ_START_TOKEN ; - data->iter = data->stats + (*pos -1 ); -if (data->iter >= data->iter_end) - data->iter =NULL ; + iter = data->stats + (*pos -1 ); +if (iter >= data->iter_end) + iter =NULL ; -return data->iter; +return iter; }static void *ls_next (struct seq_file *m,void *v,loff_t *pos) { -struct lock_stat_seq *data = m->private; - (*pos)++; - -if (v ==SEQ_START_TOKEN ) - data->iter = data->stats; -else { - data->iter = v; - data->iter++; - } - -if (data->iter == data->iter_end) - data->iter =NULL ; - -return data->iter; +return ls_start (m, pos); }static void ls_stop (struct seq_file *m,void *v)
@@ -636,7 +623,6 @@ static int lock_stat_open(struct inode *inode, struct file *file)struct lock_stat_data *iter = data->stats;struct seq_file *m = file->private_data; - data->iter = iter;list_for_each_entry (class, &all_lock_classes, lock_entry) { iter->class = class; iter->stats =lock_stats (class);
@@ -644,7 +630,7 @@ static int lock_stat_open(struct inode *inode, struct file *file) } data->iter_end = iter; -sort (data->stats, data->iter_end - data->iter, +sort (data->stats, data->iter_end - data->stats,sizeof (struct lock_stat_data ), lock_stat_cmp,NULL );
@@ -679,7 +665,6 @@ static int lock_stat_release(struct inode *inode, struct file *file)struct seq_file *seq = file->private_data;vfree (seq->private); - seq->private =NULL ;return seq_release (inode, file); }
Nice fixes and cleanups - i've applied them to tip:core/locking.
Thanks,
Ingo
[tip:core/locking] lockdep: Fix missing entry in /proc/lock_stat
In reply to Li ZefanCommit-ID: 212274347fc4d2a7c56bf6c953b02c809e7e0be1 Gitweb: http://git.kernel.org/tip/212274347fc4d2a7c56bf6c953b02c809e7e0be1 Author: Li Zefan <[email protected]> AuthorDate: Mon, 17 Aug 2009 13:39:33 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 17 Aug 2009 09:54:39 +0200
lockdep: Fix missing entry in /proc/lock_stat
One entry is missing in the output of /proc/lock_stat.
The cause is, when ls_start() is called the 2nd time, we should start from stats[@pos-1] but not stats[@pos], because pos == 0 is the header.
LKML-Reference: <[email protected]>
--- kernel/lockdep_proc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/lockdep_proc.c +1 -1
@@ -634,7 +634,7 @@ static void *ls_start(struct seq_file *m, loff_t *pos)if (*pos ==0 )return SEQ_START_TOKEN ; - data->iter = data->stats + *pos; + data->iter = data->stats + (*pos -1 );if (data->iter >= data->iter_end) data->iter =NULL ;