aboutsummaryrefslogtreecommitdiffstats
path: root/fs/seq_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/seq_file.c')
-rw-r--r--fs/seq_file.c54
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}
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);