Re: kmap() while holding spinlock

Ingo Molnar (mingo@elte.hu)
Thu, 26 Jul 2001 14:17:55 +0200 (CEST)


On Thu, 26 Jul 2001, Anton Blanchard wrote:

> do_wp_page calls break_cow with the page_table_lock held.
>
> Since I dont think we can drop the lock, do we need a kmap_atomic for
> these?

calling kmap() with a spinlock held is indeed Very Bad, and break_cow()
uses kmap(). I dont know why this didnt get noticed earlier. Perhaps
because kmap() schedules very rarely.

the solution is to either use (per-CPU) atomic_kmap(), or to do the
clearing (and copying) speculatively, after allocating the page but before
locking the pagetable lock. This might lead to a bit more work in the
pagefault-race case, but we dont care about that window. It will on the
other hand reduce pagetable_lock contention (because the clearing/copying
is done outside the lock), so perhaps this solution is better.

Ingo

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