Re: [resend][PATCH v2] mlock() doesn't wait to finishlru_add_drain_all()

From: Andrew Morton
Date: Mon Oct 12 2009 - 23:38:08 EST


On Tue, 13 Oct 2009 12:18:17 +0900 (JST) KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx> wrote:

> The problem is in __lru_cache_add().
>
> ============================================================
> void __lru_cache_add(struct page *page, enum lru_list lru)
> {
> struct pagevec *pvec = &get_cpu_var(lru_add_pvecs)[lru];
>
> page_cache_get(page);
> if (!pagevec_add(pvec, page))
> ____pagevec_lru_add(pvec, lru);
> put_cpu_var(lru_add_pvecs);
> }
> ============================================================
>
> current typical scenario is
> 1. preempt disable
> 2. assign lru_add_pvec
> 3. page_cache_get()
> 4. pvec->pages[pvec->nr++] = page;
> 5. preempt enable
>
> but the preempt disabling assume drain_cpu_pagevecs() run on process context.
> we need to convert it with irq_disabling.

Nope, preempt_disable()/enable() can be performed in hard IRQ context.
I see nothing in __lru_cache_add() which would cause problems when run
from hard IRQ.

Apart from latency, of course. Doing a full smp_call_function() in
lru_add_drain_all() might get expensive if it's ever called with any
great frequency.

A smart implementation might take a peek at other cpu's queues and omit
the cross-CPU call if the queue is empty, for example..

--
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/