But that's ok.
If you have the logic that
if (put_page_testzero(pmd_page)) {
... do the lower-level free ...
__free_pages_ok(pmd_page, 0);
}
then you automatically have exactly the behaviour you want, with no
locking at all (except for the "local" locking inherent in the atomic
decrement-and-test).
What you have is:
- _if_ the count was > 1, then you do nothing at all (except for
decrementing your count)
- for the last user (and for that _only_), where the count was 1 and goes
to zero, you'll do the inside of the "if ()" statement, and actually
clean up the page table and free the pmd.
So you not only get the optimization you want, you also quite naturally
get the "exclusive last user" case.
Linus
-
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/