diff options
author | Jeff Layton <jlayton@redhat.com> | 2013-06-21 08:58:21 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-07-08 05:36:41 -0400 |
commit | 0bc77381c1b1600e659eb7322c39d1753615722d (patch) | |
tree | 6e2adc4932f0fc136d08da5ba5adb032970a1b05 /fs/seq_file.c | |
parent | 99b072bb38c9b398bc7c3fc8a0f30d0801f78750 (diff) |
seq_file: add seq_list_*_percpu helpers
When we convert the file_lock_list to a set of percpu lists, we'll need
a way to iterate over them in order to output /proc/locks info. Add
some seq_list_*_percpu helpers to handle that.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Acked-by: J. Bruce Fields <bfields@fieldses.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/seq_file.c')
-rw-r--r-- | fs/seq_file.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c index 774c1eb7f1c9..3135c2525c76 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
@@ -921,3 +921,57 @@ struct hlist_node *seq_hlist_next_rcu(void *v, | |||
921 | return rcu_dereference(node->next); | 921 | return rcu_dereference(node->next); |
922 | } | 922 | } |
923 | EXPORT_SYMBOL(seq_hlist_next_rcu); | 923 | EXPORT_SYMBOL(seq_hlist_next_rcu); |
924 | |||
925 | /** | ||
926 | * seq_hlist_start_precpu - start an iteration of a percpu hlist array | ||
927 | * @head: pointer to percpu array of struct hlist_heads | ||
928 | * @cpu: pointer to cpu "cursor" | ||
929 | * @pos: start position of sequence | ||
930 | * | ||
931 | * Called at seq_file->op->start(). | ||
932 | */ | ||
933 | struct hlist_node * | ||
934 | seq_hlist_start_percpu(struct hlist_head __percpu *head, int *cpu, loff_t pos) | ||
935 | { | ||
936 | struct hlist_node *node; | ||
937 | |||
938 | for_each_possible_cpu(*cpu) { | ||
939 | hlist_for_each(node, per_cpu_ptr(head, *cpu)) { | ||
940 | if (pos-- == 0) | ||
941 | return node; | ||
942 | } | ||
943 | } | ||
944 | return NULL; | ||
945 | } | ||
946 | EXPORT_SYMBOL(seq_hlist_start_percpu); | ||
947 | |||
948 | /** | ||
949 | * seq_hlist_next_percpu - move to the next position of the percpu hlist array | ||
950 | * @v: pointer to current hlist_node | ||
951 | * @head: pointer to percpu array of struct hlist_heads | ||
952 | * @cpu: pointer to cpu "cursor" | ||
953 | * @pos: start position of sequence | ||
954 | * | ||
955 | * Called at seq_file->op->next(). | ||
956 | */ | ||
957 | struct hlist_node * | ||
958 | seq_hlist_next_percpu(void *v, struct hlist_head __percpu *head, | ||
959 | int *cpu, loff_t *pos) | ||
960 | { | ||
961 | struct hlist_node *node = v; | ||
962 | |||
963 | ++*pos; | ||
964 | |||
965 | if (node->next) | ||
966 | return node->next; | ||
967 | |||
968 | for (*cpu = cpumask_next(*cpu, cpu_possible_mask); *cpu < nr_cpu_ids; | ||
969 | *cpu = cpumask_next(*cpu, cpu_possible_mask)) { | ||
970 | struct hlist_head *bucket = per_cpu_ptr(head, *cpu); | ||
971 | |||
972 | if (!hlist_empty(bucket)) | ||
973 | return bucket->first; | ||
974 | } | ||
975 | return NULL; | ||
976 | } | ||
977 | EXPORT_SYMBOL(seq_hlist_next_percpu); | ||