Re: pmap attempts at copying to executable pages both on mips and powerpc/booke

Nick Hudson <[email protected]> Wed, 28 Sep 2016 12:40:21 +0100
Newsgroups gmane.os.netbsd.devel.kernel,gmane.os.netbsd.ports.mips.devel,gmane.os.netbsd.ports.powerpc
Message-ID <[email protected]>
On 09/20/16 12:34, Rin Okuyama wrote:

[snip...]

> However, unfortunately, something is still wrong. top(1) reports 
> resources
> of some processes are negative:
>
>   % top
>   ...
>     PID USERNAME PRI NICE   SIZE   RES STATE      TIME   WCPU CPU COMMAND
>   ...
>     573 root      85    0  4304K -3832K nanoslp    0:01  0.00% 0.00% cron
>   ...
>
>
The problem is here...

https://nxr.netbsd.org/xref/src/sys/uvm/pmap/pmap.c#1275

    1275     if (pte_valid_p(opte) && pte_to_paddr(opte) != pa) {
    1276         pmap_remove(pmap, va, va + NBPG);
    1277         PMAP_COUNT(user_mappings_changed);
    1278     }
    1279
    1280     KASSERT(pte_valid_p(npte));
    1281     const bool resident = pte_valid_p(opte);
    1282     if (resident) {
    1283         update_flags |= PMAP_TLB_NEED_IPI;
    1284     } else {
    1285         pmap->pm_stats.resident_count++;
    1286     }

if the mapping changes PA then the resident_count gets reduced by 
pmap_{,pte_}remove, but not increased again.

I'm working on a fix.

Nick