Page MenuHomeFreeBSD

Handle pmap_enter() over an existing 4/2M page on i386.
ClosedPublic

Authored by kib on Oct 22 2016, 10:40 AM.
Tags
None
Referenced Files
F102150100: D8323.diff
Fri, Nov 8, 6:05 AM
F102149699: D8323.id21614.diff
Fri, Nov 8, 5:57 AM
Unknown Object (File)
Fri, Nov 8, 3:29 AM
Unknown Object (File)
Thu, Nov 7, 1:11 AM
Unknown Object (File)
Mon, Nov 4, 4:08 PM
Unknown Object (File)
Tue, Oct 29, 3:30 PM
Unknown Object (File)
Sun, Oct 20, 10:21 AM
Unknown Object (File)
Fri, Oct 18, 9:12 AM
Subscribers

Details

Summary

This change apparently sit in my local tree for long time.

I do not see why it is impossible for e.g. two threads to fault on the same address simultaneously, then one thread creates the mapping in pmap_enter() and promotes it, and only then the second thread enters pmap_enter(), either due to locking or locking and scheduling. In this case, amd64 pmap demotes large page first, while i386 panics for some contrast.

Handle the i386 pmap_enter() same as amd64, demote.

Test Plan

I believe it was done after some actual Peter report of 'panic("pmap_enter: attempted pmap_enter on 4MB page")', but the situation is very hard to reproduce.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 5706
Build 6000: CI src buildJenkins

Event Timeline

kib retitled this revision from to Handle pmap_enter() over an existing 4/2M page on i386..
kib updated this object.
kib edited the test plan for this revision. (Show Details)
kib added reviewers: alc, markj.
kib set the repository for this revision to rS FreeBSD src repository - subversion.
kib added a subscriber: pho.

Unless the mapping is a kernel virtual address, the demotion is already being performed at the start of pmap_allocpte().

In D8323#173239, @alc wrote:

Unless the mapping is a kernel virtual address, the demotion is already being performed at the start of pmap_allocpte().

Yes. It is probably practically impossible to have a promotion on the kernel (sub)map entry handled by pmap_enter() on i386.

But still, I would like to either add the demotion call for KVA just for completeness, or a comment noting what you said + note to the panic that it is for kernel addresses. What do you prefer ?

In D8323#173301, @kib wrote:
In D8323#173239, @alc wrote:

Unless the mapping is a kernel virtual address, the demotion is already being performed at the start of pmap_allocpte().

Yes. It is probably practically impossible to have a promotion on the kernel (sub)map entry handled by pmap_enter() on i386.

But still, I would like to either add the demotion call for KVA just for completeness, or a comment noting what you said + note to the panic that it is for kernel addresses. What do you prefer ?

Let's do the former. I don't see a downside to making it work for KVA.

sys/i386/i386/pmap.c
3473

If pmap_demote_pde() can't allocate a page table page (and returns FALSE), then we need to execute the "else if". Take a look at how I wrote this on amd64 with the demotion call included in the test expression of the "if". You need to do the same here.

For KVA, pde must exist and be valid, and demotion failure is impossible, due to pmap_growkernel() preallocating the page table page, am I wrong ? If not, I propose to leave the UVA case as is, and just call pmap_demote_pde() for KVA.

kib edited edge metadata.

Only add code for KVA demotion.

alc edited edge metadata.
In D8323#173555, @kib wrote:

For KVA, pde must exist and be valid, and demotion failure is impossible, due to pmap_growkernel() preallocating the page table page, am I wrong ? If not, I propose to leave the UVA case as is, and just call pmap_demote_pde() for KVA.

You are correct.

sys/i386/i386/pmap.c
3488

"va is for KVA, so pmap_demote_pde() will never fail to install a page table page.

This revision is now accepted and ready to land.Oct 25 2016, 5:27 PM
sys/i386/i386/pmap.c
3501–3503

As an aside to this change, the above comment makes no sense. The page table page allocation has already occurred.

kib edited edge metadata.

Update comments.

This revision now requires review to proceed.Oct 25 2016, 5:54 PM
sys/i386/i386/pmap.c
3501

You use "should" in the next sentence, and these two sentences are related. I would use "should" here as well.

3502

"... should have either ..."

3503

You don't need the "," here.

sys/i386/i386/pmap.c
3503

Also, "... demoted the existing ..."

kib edited edge metadata.

Grammar fixes.

alc edited edge metadata.
This revision is now accepted and ready to land.Oct 25 2016, 6:32 PM
markj edited edge metadata.
This revision was automatically updated to reflect the committed changes.