[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-aio
Subject: Re: [PATCH 17/21] Percpu tag allocator
From: Oleg Nesterov <oleg () redhat ! com>
Date: 2013-06-11 17:42:38
Message-ID: 20130611174238.GA8139 () redhat ! com
[Download RAW message or body]
On 06/10, Kent Overstreet wrote:
>
> On Wed, May 15, 2013 at 05:41:21PM +0200, Oleg Nesterov wrote:
> >
> > Do you really think that, say,
> >
> > unsigned tag_alloc(struct tag_pool *pool, bool wait)
> > {
> > struct tag_cpu_freelist *tags;
> > unsigned ret = 0;
> > retry:
> > tags = get_cpu_ptr(pool->tag_cpu);
> > local_irq_disable();
> > if (!tags->nr_free && pool->nr_free) {
> > spin_lock(&pool->wq.lock);
> > if (pool->nr_free)
> > move_tags(...);
> > spin_unlock(&pool->wq.lock);
> > }
> >
> > if (tags->nr_free)
> > ret = tags->free[--tags->nr_free];
> > local_irq_enable();
> > put_cpu_var(pool->tag_cpu);
> >
> > if (ret || !wait)
> > return ret;
> >
> > __wait_event(&pool->wq, pool->nr_free);
> > goto retry;
> > }
> >
> > will be much slower?
>
> The overhead from doing nested irqsave/restore() sucks. I've had it bite
> me hard with the recent aio work.
Not sure I understand... Only __wait_event() does irqsave/restore and
we are going to sleep anyway.
> But screw it, it's not going to matter
> that much here.
Yes.
And, imho, even if we need some optimizations here, it would be better
to make a separate patch backed by the numbers or at least the detailed
explanation.
> > Question. tag_free() does move_tags+wakeup if nr_free = pool->watermark * 2.
> > Perhaps it should should also take waitqueue_active() into account ?
> > tag_alloc() can sleep more than necessary, it seems.
>
> No.
>
> By "sleeping more than necessary" you mean sleeping when there's tags
> available on other percpu freelists.
Yes,
> That's just unavoidable if the thing's to be percpu - efficient use of
> available tags requires global knowledge. Sleeping less would require
> more global cacheline contention, and would defeat the purpose of this
> code.
Yes, yes, I understand, there is a tradeoff. Just it is still not clear
to me what would be better "in practice"... So,
> So when you're deciding how many tag structs to allocate, you just
> double the number you'd allocate otherwise when you're using this code.
I am not sure this is really needed.
But OK, I see your point, thanks.
Oleg.
--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to majordomo@kvack.org. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"aart@kvack.org">aart@kvack.org</a>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic