Re: [PATCH] lockdep: lock_set_subclass - reset a held lock's subclass

From: Hugh Dickins
Date: Fri Aug 01 2008 - 16:00:00 EST


On Fri, 1 Aug 2008, Jeremy Fitzhardinge wrote:
>
> I have a function traversing a pagetable in vaddr order (low to high), taking
> pte locks as it builds up batches of pte page updates. When the batch is
> issued, it releases all the locks, and won't end up holding more than ~16 at a
> time.
>
> So, I think this is OK. There are no internal lock ordering issues, and I
> don't think there'll be any bad interactions from someone trying to take pte
> locks for two separate pagetables. I don't think there's anyone else trying
> to take more than one pte lock at once, but if there were "lock low vaddr then
> high" seems like a reasonable locking rule (or more precisely "lowest" to deal
> with the case of a pte page being aliased at multiple vaddrs).

Please check the spin_lock_nested() in move_ptes() in mm/mremap.c.

If you have down_write(&mm->mmap_sem) then you should be safe,
but may need to do something to placate lockdep. If you don't
have down_write(&mm->mmap_sem), then I think you're in trouble?

Not a big deal, the move_ptes() locking can be adjusted to suit
your rule, it was just easier to do it the way it is at the time.

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