While optimizing icache management on arm64, I found that we don't consistently clear PGA_WRITEABLE on fictitious, managed pages. Some functions do, e.g., pmap_remove_all(), but several do not. At worst, this is just a pessimization, but there is no good reason to be inconsistent Clear PGA_WRITEABLE in those that previously did not.
Details
Details
Diff Detail
Diff Detail
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
| sys/amd64/amd64/pmap.c | ||
|---|---|---|
| 5321 | Is it worth making a static function like this static void
pmap_might_be_clear_writeable(vm_page_t m)
{
if (!TAILQ_EMPTY(&m->md.pv_list))
return;
if ((m->flags & PG_FICTITIOUS) == 0 &&
!TAILQ_EMPTY(&pa_to_pvh(tpte & PG_FRAME)->pv_list)
return;
vm_page_aflag_clear(m, PGA_WRITEABLE);
} | |
| sys/amd64/amd64/pmap.c | ||
|---|---|---|
| 7279 | Some sites check whether PGA_WRITEABLE is set before checking whether or not to clear it. Others don't, but I can't see a good reason for the inconsistency. | |
| sys/amd64/amd64/pmap.c | ||
|---|---|---|
| 7279 | This one is the easiest to explain. It is most likely replacing a mapping to a COW page, and the additional check avoids what would be a pointless atomic. The other is pmap_remove_pages(), where we are also destroying a lot of R/O and COW mappings. In the other cases, I think it is less clear what type of mapping it is. | |
| sys/amd64/amd64/pmap.c | ||
|---|---|---|
| 7279 | Would you like me to add /* The old page is likely COW. */ here? | |
| sys/amd64/amd64/pmap.c | ||
|---|---|---|
| 7279 | '... so check for writeable first' or like? | |