Re: [PATCH -v3 6/8] fsnotify: add group priorities

From: Peter Zijlstra
Date: Thu Nov 27 2008 - 11:25:26 EST


On Tue, 2008-11-25 at 12:21 -0500, Eric Paris wrote:
> In preperation for blocking fsnotify calls group priorities must be added.
> When multiple groups request the same event type the lowest priority group
> will receive the notification first.

> @@ -114,9 +117,26 @@ struct fsnotify_group *fsnotify_find_group(unsigned int group_num, unsigned long
>
> group->ops = ops;
>
> - /* add it */
> - list_add_rcu(&group->group_list, &fsnotify_groups);
> + /* Do we need to be the first entry? */
> + if (list_empty(&fsnotify_groups)) {
> + list_add_rcu(&group->group_list, &fsnotify_groups);
> + goto out;
> + }
> +
> + list_for_each_entry(group_iter, &fsnotify_groups, group_list) {
> + /* insert in front of this one? */
> + if (priority < group_iter->priority) {
> + /* I used list_add_tail() to insert in front of group_iter... */
> + list_add_tail_rcu(&group->group_list, &group_iter->group_list);
> + break;
> + }
>
> + /* are we at the end? if so insert at end */
> + if (list_is_last(&group_iter->group_list, &fsnotify_groups)) {
> + list_add_tail_rcu(&group->group_list, &fsnotify_groups);
> + break;
> + }
> + }
> out:
> mutex_unlock(&fsnotify_grp_mutex);
> fsnotify_recalc_global_mask();

What priority range do you need to cater for, and how many groups? I can
imagine for many groups and limit range a priority list might be better
suited.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/