Re: flush_tlb_page in unuse_pte

Mark Hemment (markhe@nextd.demon.co.uk)
Wed, 27 Aug 1997 18:44:57 +0100 (BST)


On Wed, 27 Aug 1997, Bill Hawes wrote:

> Mark Hemment wrote:
> Hi Mark,
> Thanks for your comments, but I'm afraid I still don't understand the
> need for the flush_tlb_page, given that the page is currently swapped
> out. Swapoff is essentially performing a swapin for all pages written
> to the swapfile being closed, and I didn't see an equivalent
> flush_tlb_page in the code used for a regular swapin. I'll look again
> though ...

Your right. The TLB only needs to be flushed when;
a) Removing information from a PTE
b) Making the protections stronger
c) ...something else...?

Removing info would be unloading the mappings from a page (either
dropping it, or writing it to swap). Any TLB entry must be consistent
with the PTE in this case.
Making the protections stronger (such as removing write perms) also
requires an invalidation.

Adding info to a PTE (such as making it contain a present page) makes
any TLB entry inconsistent, but not invalid. The page-fault handlers look
at the value in the PTE before continuing their processing, so there is no
problem here. (They always re-check the PTE after blocking as well).
It's the same when permissions are weakened. If write perms are added
to a PTE, there is no reason to flush the TLB (unless we are executing in
the context which contains the PTE).
Of course, I expect there are some exceptions.

As loading a page from swap falls under the catagory of "adding info", I
cannot see why the flush is needed in unuse_pte() either.

Regards,

markhe

------------------------------------------------------------------
Mark Hemment, Unix/C Software Engineer (Contractor)
markhe@nextd.demon.co.uk http://www.nextd.demon.co.uk/
"Success has many fathers, failure is a B**TARD!" - anon
------------------------------------------------------------------