Re: oops if free a locked page

Linus Torvalds (torvalds@transmeta.com)
Tue, 22 Jun 1999 14:40:59 -0700 (PDT)


On Tue, 22 Jun 1999, Andrea Arcangeli wrote:
>
> Yes, but I wasn't talking about the pagecache code, it was just to point
> out that would make far more sense to Oops also in the case we did a
> free_page() on a locked page with reference count > 1.

No, it's often ok (in fact quite common) to free a page that is locked.

Think of one common schenario:
- a user has mapped a file read-only
- another user has a write mapping or is busy writing to the file
some other way
- bdflush happens, the write-out is started
- the read-only mapping is free'd, and THAT particular copy of the page
does a free_page(). It does not know (and SHOULD not know) that the
page is currently locked because somebody else is preparing to flush it
to disk

So it really is an error only if the last user drops the page with the
lock held: that implies that the entity that locked the page in the first
place has not done proper reference counting (because there is obviously
somebody still with references to the page - otherwise it would never get
unlocked).

Linus

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