On Sun Jun  8 14:17:16 EDT 2014, quans...@quanstro.net wrote:
> On Sun Jun  8 13:55:52 EDT 2014, cinap_len...@felloff.net wrote:
> > right. the question is, how did it vanish from the image cache.
> 
> i think it is in the image cache, but .ref >1.

perhaps independent of your question,
my assumption is correct, and proven.

the problem was that pagereclaim() only looked through
pga.pgsza[0], but since 2MiB pages were introduced in nix,
no pages could ever be reclaimed this way, since they would
be in pga.pgsza[1].

i don't think this really addresses your question, or my
original problem though.  the corrected version which i think
should work for any architecture is below.  i intend to
incorporate charles locking changes later on.
(lock(&lga.pgsza[lg]) instead of the whole thing.)
i think those changes (in the 9atom /sys/src/9 kernels)
are good stuff.

- erik
---
/*
 * Called from imagereclaim, to try to release Images.
 * The (ignored) argument indicates a preferred image for release.
 */
void
pagereclaim(Image*)
{
        int lg, n;
        usize sz;
        Page *p;

        lock(&pga);

        /*
         * All the pages with images backing them are at the
         * end of the list (see putpage) so start there and work
         * backward.  Assume the smallest page size (BOTCH).
         */
        sz = 0;
        n = 0;
        for(lg = 0; lg < m->npgsz; lg++)
                for(p = pga.pgsza[lg].tail; p != nil; p = p->prev){
                        if(p->image != nil && p->ref == 0 && canlock(p)){
                                if(p->ref == 0) {
                                        n++;
                                        sz += 1<<m->pgszlg2[lg];
                                        uncachepage(p);
                                }
                        unlock(p);
                        if(sz >= 20*MiB && n>5)
                                break;
                }
        }
        unlock(&pga);
}

Reply via email to