seq_file: Add seq_cpumask_list(), seq_nodemask_list()
PATCH 2/4 seq_file: Add seq_cpumask_list(), seq_nodemask_list()
seq_cpumask_list(), seq_nodemask_list() are very like seq_cpumask(), seq_nodemask(), but they print human readable string.
---
fs/seq_file.c +16 -0
@@ -465,6 +465,22 @@ int seq_bitmap(struct seq_file *m, unsigned long *bits, unsigned int nr_bits) }EXPORT_SYMBOL (seq_bitmap); +int seq_bitmap_list (struct seq_file *m,unsigned long *bits, +unsigned int nr_bits) +{ +if (m->count < m->size) { +int len =bitmap_scnlistprintf (m->buf + m->count, + m->size - m->count, bits, nr_bits); +if (m->count + len < m->size) { + m->count += len; +return 0 ; + } + } + m->count = m->size; +return -1 ; +} +EXPORT_SYMBOL (seq_bitmap_list); +static void *single_start (struct seq_file *p,loff_t *pos) {return NULL + (*pos ==0 );
include/linux/seq_file.h +13 -0
@@ -60,6 +60,19 @@ static inline int seq_nodemask(struct seq_file *m, nodemask_t *mask)return seq_bitmap (m, mask->bits,MAX_NUMNODES ); } +int seq_bitmap_list (struct seq_file *m,unsigned long *bits, +unsigned int nr_bits); + +static inline int seq_cpumask_list (struct seq_file *m,cpumask_t *mask) +{ +return seq_bitmap_list (m, mask->bits,NR_CPUS ); +} + +static inline int seq_nodemask_list (struct seq_file *m,nodemask_t *mask) +{ +return seq_bitmap_list (m, mask->bits,MAX_NUMNODES ); +} +int single_open (struct file *,int (*)(struct seq_file *,void *),void *);int single_release (struct inode *,struct file *);void *__seq_open_private (struct file *,const struct seq_operations *,int );
include/linux/seq_file.h static inline int seq_nodemask(struct seq_file *m, nodemask_t *mask) · line 69
Quoted 4 lines · On Sun, 12 Oct 2008 17:29:25 +0800 Lai Jiangshan <[email protected]> wrote:
include/linux/seq_file.h +4
-0+static inline int seq_cpumask_list (struct seq_file *m,cpumask_t *mask) +{ +return seq_bitmap_list (m, mask->bits,NR_CPUS ); +}
Is it possible to avoid using NR_CPUS? In some situations it'd be much more efficient to use the runtime-determined max possible cpu index.
But I don't immediately recall how to get at that number. num_possible_cpus() assumes that there are no holes in the CPU identifier list.
Quoted 11 lines · Andrew Morton
include/linux/seq_file.h static inline int seq_nodemask(struct seq_file *m, nodemask_t *mask) · line 69
Quoted 4 lines · On Sun, 12 Oct 2008 17:29:25 +0800 Lai Jiangshan <[email protected]> wrote:
include/linux/seq_file.h +4
-0+static inline int seq_cpumask_list (struct seq_file *m,cpumask_t *mask) +{ +return seq_bitmap_list (m, mask->bits,NR_CPUS ); +}Is it possible to avoid using
NR_CPUS? In some situations it'd be much more efficient to use the runtime-determined max possible cpu index.
Quoted 4 lines
But I don't immediately recall how to get at that number.
num_possible_cpus()assumes that there are no holes in the CPU identifier list.
nr_cpu_ids represents the max index +1 of the possible cpus. (Usually the same as num_possible_cpus() except a.) it doesn't need to do the cpus_weight() op, and b.) *if* (a big if) the cpu indices are sparse, then they wouldn't be the same values.)
Thanks,
Mike
Quoted 17 lines · On Thu, 16 Oct 2008 15:56:30 -0700 Mike Travis <[email protected]> wrote:
Quoted 11 lines · Andrew Morton
include/linux/seq_file.h static inline int seq_nodemask(struct seq_file *m, nodemask_t *mask) · line 69
Quoted 4 lines · On Sun, 12 Oct 2008 17:29:25 +0800 Lai Jiangshan <[email protected]> wrote:
include/linux/seq_file.h +4
-0+static inline int seq_cpumask_list (struct seq_file *m,cpumask_t *mask) +{ +return seq_bitmap_list (m, mask->bits,NR_CPUS ); +}Is it possible to avoid using
NR_CPUS? In some situations it'd be much more efficient to use the runtime-determined max possible cpu index.Quoted 4 lines
But I don't immediately recall how to get at that number.
num_possible_cpus()assumes that there are no holes in the CPU identifier list.
Quoted 4 lines
nr_cpu_idsrepresents the max index +1 of the possible cpus. (Usually the same asnum_possible_cpus()except a.) it doesn't need to do thecpus_weight()op, and b.) *if* (a big if) the cpu indices are sparse, then they wouldn't be the same values.)
OK, thanks. I was foggily looking for max_possible_cpus(), to match num_online_cpus(), num_possible_cpus(), num_present_cpus(). Silly me.