[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20130131155726.05d09b21.akpm@linux-foundation.org>
Date: Thu, 31 Jan 2013 15:57:26 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Jan Kara <jack@...e.cz>
Cc: LKML <linux-kernel@...r.kernel.org>, linux-fsdevel@...r.kernel.org,
linux-mm@...ck.org
Subject: Re: [PATCH 1/6] lib: Implement range locks
On Thu, 31 Jan 2013 22:49:49 +0100
Jan Kara <jack@...e.cz> wrote:
> Implement range locking using interval tree.
>
> ...
>
> +void range_lock(struct range_lock_tree *tree, struct range_lock *lock)
> +{
> + struct interval_tree_node *node;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&tree->lock, flags);
> + node = interval_tree_iter_first(&tree->root, lock->node.start,
> + lock->node.last);
> + while (node) {
> + lock->blocking_ranges++;
> + node = interval_tree_iter_next(node, lock->node.start,
> + lock->node.last);
> + }
> + interval_tree_insert(&lock->node, &tree->root);
> + /* Do we need to go to sleep? */
> + while (lock->blocking_ranges) {
> + lock->task = current;
> + __set_current_state(TASK_UNINTERRUPTIBLE);
> + spin_unlock_irqrestore(&tree->lock, flags);
> + schedule();
> + spin_lock_irqsave(&tree->lock, flags);
> + }
> + spin_unlock_irqrestore(&tree->lock, flags);
> +}
>
> ...
>
> +void range_unlock(struct range_lock_tree *tree, struct range_lock *lock)
> +{
> + struct interval_tree_node *node;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&tree->lock, flags);
> + interval_tree_remove(&lock->node, &tree->root);
> + node = interval_tree_iter_first(&tree->root, lock->node.start,
> + lock->node.last);
> + while (node) {
> + range_lock_unblock((struct range_lock *)node);
> + node = interval_tree_iter_next(node, lock->node.start,
> + lock->node.last);
> + }
> + spin_unlock_irqrestore(&tree->lock, flags);
> +}
What are the worst-case interrupt-off durations here?
I note that the new exported functions in this patchset are
refreshingly free of documentation ;)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists