aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/seq_file.c54
-rw-r--r--include/linux/seq_file.h6
2 files changed, 60 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}
923EXPORT_SYMBOL(seq_hlist_next_rcu); 923EXPORT_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 */
933struct hlist_node *
934seq_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}
946EXPORT_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 */
957struct hlist_node *
958seq_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}
977EXPORT_SYMBOL(seq_hlist_next_percpu);
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 2da29ac178fc..4e32edc8f506 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -173,4 +173,10 @@ extern struct hlist_node *seq_hlist_start_head_rcu(struct hlist_head *head,
173extern struct hlist_node *seq_hlist_next_rcu(void *v, 173extern struct hlist_node *seq_hlist_next_rcu(void *v,
174 struct hlist_head *head, 174 struct hlist_head *head,
175 loff_t *ppos); 175 loff_t *ppos);
176
177/* Helpers for iterating over per-cpu hlist_head-s in seq_files */
178extern struct hlist_node *seq_hlist_start_percpu(struct hlist_head __percpu *head, int *cpu, loff_t pos);
179
180extern struct hlist_node *seq_hlist_next_percpu(void *v, struct hlist_head __percpu *head, int *cpu, loff_t *pos);
181
176#endif 182#endif