> I don't *have* an eviction strategy, because I don't *need* one, > because I'm never evicting anything. > > The mappings are of small cost, but not zero cost, so it's worth a > reference count to keep them around.
You need to drain the cache once in a while. You need some kind of strategy. > No time stamp necessary, you just maintain an LRU list which has all > the currently unused mappings. When a ref count goes to zero, the > entry is dropped on the end of the list, and when you need a new > mapping, you pull from the front of the list, vm_deallocate the > specified region, and then vm_map anew (with anywhere==TRUE, btw). Fine, but this is extra memory per region and it needs to be updated fairly often. This is all gotten rid of when we just clear a mapping when the kernel does. > > Why is the kernel dropping the page if it is active in the first > > place? This logic seems suspect. > > ANY page may be paged out at ANY time. You MUST make that assumption > and be extremely careful that you are not assuming ANYTHING about when > the kernel will schedule a pageout. You should assume, when writing > for correctness, that a complete pageout happens of anything you care > about between every two instructions. You cannot assume "oh, I just > used this in the last instruction, so it will still be around." > > You don't need to worry about such cases for performance: they can be > assumed to be rare. But you must worry about them for corrected: they > cannot be assumed to be impossible. Of course you are right and I have taken this into account. If a mapping has user references, the mapping is not removed. It is likely that the page will be pulled back into memory in the near future anyways because of the user mapping. But likely is certainly not enough of a reassurance. So, in the case where the mapping cache is completely full and we need to force some pages out, we search for pages that have no user references. Clearly this is an unoptimal eviction strategy, however, it should be rare enough satisfies the correctness requirement. My assumption is that in the majority of cases, the reason Mach is doing a page out is because it is reacting to memory pressure. I feel that this is a reasonable assumption as long as we are prepared for the other cases (which we are). > > The interesting corner case is what happens if there are user > > references and the kernel drops the page. Well, in this case, we > > just leave the mapping in place based on the assumption that the > > page will be faulted back in momentarily (otherwise, why would there > > by a reference?). > > This is incorrect. You might be just about to drop the reference, > having already completed all the uses of the page, when the page gets > paged out. Fine, it is not rigorously correct, however, leaving it in the cache, as I describe above, does not hurt the system. Neal _______________________________________________ Bug-hurd mailing list [EMAIL PROTECTED] http://lists.gnu.org/mailman/listinfo/bug-hurd