Mike Kelly via Bug reports for the GNU Hurd, le sam. 20 déc. 2025 18:29:19 
+0000, a ecrit:
> Eviction strategy no longer chooses external pages when the total external 
> page count becomes low (4% of total). This primitive algorithm improves 
> performance considerably through retention of code pages which would 
> otherwise be continuously paged out and paged in.
> ---
>  vm/vm_page.c | 46 +++++++++++++++++++++++++---------------------
>  1 file changed, 25 insertions(+), 21 deletions(-)
> 
> diff --git a/vm/vm_page.c b/vm/vm_page.c
> index ba3a52ff..1489fb7a 100644
> --- a/vm/vm_page.c
> +++ b/vm/vm_page.c
> @@ -2021,9 +2021,8 @@ vm_page_balance(void)
>  }
>  
>  static boolean_t
> -vm_page_evict_once(boolean_t external, boolean_t alloc_paused)
> +vm_page_evict_once(boolean_t alloc_paused)
>  {
> -    boolean_t evicted;
>      unsigned int i;
>  
>      /*
> @@ -2032,12 +2031,29 @@ vm_page_evict_once(boolean_t external, boolean_t 
> alloc_paused)
>       */
>  
>      for (i = vm_page_segs_size - 1; i < vm_page_segs_size; i--) {
> -        evicted = vm_page_seg_evict(vm_page_seg_get(i),
> -                                    external, alloc_paused);
> +      struct vm_page_seg* seg = vm_page_seg_get(i);
> +      unsigned long nr_ext_pages = (seg->active_pages.external.nr_pages +
> +                                 seg->inactive_pages.external.nr_pages);
>  
> -        if (evicted) {
> -            return TRUE;
> -        }
> +      if (nr_ext_pages)
> +     {
> +       unsigned long nr_int_pages
> +         = (seg->active_pages.internal.nr_pages +
> +            seg->inactive_pages.internal.nr_pages);
> +
> +       /* Don't page out external pages if they total less than 1
> +          in N pageable pages in this segment. This is an
> +          extremely primitive starting position for an actual
> +          eviction strategy. */
> +       if ((nr_int_pages / nr_ext_pages) <= /*N*/ 25 &&

I don't remember the details of what we currently have, but in my mind,
what we should have is:

- try to evict external inactive pages,
- else try to evict internal inactive pages,
- else try to evict external active pages,
- else try to evict internal active pages,

so that we don't pressure external active pages unless we don't have
inactive pages at all any more. I don't think we are doing that ATM?
That would probably avoid hardcoding a 1/25 ratio, and just rely on
respective active/inactive ratios.

While you are at it, we are seeing on buildds some file content
corruptions, leading to various compilation issues such as 

/usr/include/i386-gnu/c++/15/bits/c++io.h:1:3: error: stray ‘\2’ in program

This seems to be happening with builds of large programs that put
pressure on page-out and such. Notably, building qtcreator seems
stressful. The bogus content remains as such on the disk, and the bogus
content is aligned on a page boundary, so it looks as if the page was
removed and reused+overwritten before the content has hit the disk, and
thus the overwritten content is written to the disk, and reloaded as
such.

Samuel

Reply via email to