[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130204164142.GG7523@quack.suse.cz>
Date: Mon, 4 Feb 2013 17:41:42 +0100
From: Jan Kara <jack@...e.cz>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Jan Kara <jack@...e.cz>, 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-01-13 15:57:26, Andrew Morton wrote:
> 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?
Good question. In theory, it could be relatively long, e.g. when there
are lots of DIOs in flight against a range which is locked. I'll do some
measurements to get some idea.
> I note that the new exported functions in this patchset are
> refreshingly free of documentation ;)
They are *so* obvious ;) Point taken... Thanks for review.
Honza
--
Jan Kara <jack@...e.cz>
SUSE Labs, CR
--
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