On 10/05/22(Tue) 20:23, Mark Kettenis wrote:
> > Date: Tue, 10 May 2022 18:45:21 +0200
> > From: Martin Pieuchot <[email protected]>
> > 
> > On 05/05/22(Thu) 14:54, Martin Pieuchot wrote:
> > > Diff below introduces a new wrapper to manipulate active/inactive page
> > > queues. 
> > > 
> > > ok?
> > 
> > Anyone?
> 
> Sorry I started looking at this and got distracted.
> 
> I'm not sure about the changes to uvm_pageactivate().  It doesn't
> quite match what NetBSD does, but I guess NetBSD assumes that
> uvm_pageactiave() isn't called for a page that is already active?  And
> that's something we can't guarantee?

It does look at what NetBSD did 15 years ago.  We're not ready to synchronize
with NetBSD -current yet. 

We're getting there!

> The diff is correct though in the sense that it is equivalent to the
> code we already have.  So if this definitely is the direction you want
> to go:
> 
> ok kettenis@
> 
> > > Index: uvm/uvm_page.c
> > > ===================================================================
> > > RCS file: /cvs/src/sys/uvm/uvm_page.c,v
> > > retrieving revision 1.165
> > > diff -u -p -r1.165 uvm_page.c
> > > --- uvm/uvm_page.c        4 May 2022 14:58:26 -0000       1.165
> > > +++ uvm/uvm_page.c        5 May 2022 12:49:13 -0000
> > > @@ -987,16 +987,7 @@ uvm_pageclean(struct vm_page *pg)
> > >   /*
> > >    * now remove the page from the queues
> > >    */
> > > - if (pg->pg_flags & PQ_ACTIVE) {
> > > -         TAILQ_REMOVE(&uvm.page_active, pg, pageq);
> > > -         flags_to_clear |= PQ_ACTIVE;
> > > -         uvmexp.active--;
> > > - }
> > > - if (pg->pg_flags & PQ_INACTIVE) {
> > > -         TAILQ_REMOVE(&uvm.page_inactive, pg, pageq);
> > > -         flags_to_clear |= PQ_INACTIVE;
> > > -         uvmexp.inactive--;
> > > - }
> > > + uvm_pagedequeue(pg);
> > >  
> > >   /*
> > >    * if the page was wired, unwire it now.
> > > @@ -1243,16 +1234,7 @@ uvm_pagewire(struct vm_page *pg)
> > >   MUTEX_ASSERT_LOCKED(&uvm.pageqlock);
> > >  
> > >   if (pg->wire_count == 0) {
> > > -         if (pg->pg_flags & PQ_ACTIVE) {
> > > -                 TAILQ_REMOVE(&uvm.page_active, pg, pageq);
> > > -                 atomic_clearbits_int(&pg->pg_flags, PQ_ACTIVE);
> > > -                 uvmexp.active--;
> > > -         }
> > > -         if (pg->pg_flags & PQ_INACTIVE) {
> > > -                 TAILQ_REMOVE(&uvm.page_inactive, pg, pageq);
> > > -                 atomic_clearbits_int(&pg->pg_flags, PQ_INACTIVE);
> > > -                 uvmexp.inactive--;
> > > -         }
> > > +         uvm_pagedequeue(pg);
> > >           uvmexp.wired++;
> > >   }
> > >   pg->wire_count++;
> > > @@ -1324,28 +1306,32 @@ uvm_pageactivate(struct vm_page *pg)
> > >   KASSERT(uvm_page_owner_locked_p(pg));
> > >   MUTEX_ASSERT_LOCKED(&uvm.pageqlock);
> > >  
> > > + uvm_pagedequeue(pg);
> > > + if (pg->wire_count == 0) {
> > > +         TAILQ_INSERT_TAIL(&uvm.page_active, pg, pageq);
> > > +         atomic_setbits_int(&pg->pg_flags, PQ_ACTIVE);
> > > +         uvmexp.active++;
> > > +
> > > + }
> > > +}
> > > +
> > > +/*
> > > + * uvm_pagedequeue: remove a page from any paging queue
> > > + */
> > > +void
> > > +uvm_pagedequeue(struct vm_page *pg)
> > > +{
> > > + if (pg->pg_flags & PQ_ACTIVE) {
> > > +         TAILQ_REMOVE(&uvm.page_active, pg, pageq);
> > > +         atomic_clearbits_int(&pg->pg_flags, PQ_ACTIVE);
> > > +         uvmexp.active--;
> > > + }
> > >   if (pg->pg_flags & PQ_INACTIVE) {
> > >           TAILQ_REMOVE(&uvm.page_inactive, pg, pageq);
> > >           atomic_clearbits_int(&pg->pg_flags, PQ_INACTIVE);
> > >           uvmexp.inactive--;
> > >   }
> > > - if (pg->wire_count == 0) {
> > > -         /*
> > > -          * if page is already active, remove it from list so we
> > > -          * can put it at tail.  if it wasn't active, then mark
> > > -          * it active and bump active count
> > > -          */
> > > -         if (pg->pg_flags & PQ_ACTIVE)
> > > -                 TAILQ_REMOVE(&uvm.page_active, pg, pageq);
> > > -         else {
> > > -                 atomic_setbits_int(&pg->pg_flags, PQ_ACTIVE);
> > > -                 uvmexp.active++;
> > > -         }
> > > -
> > > -         TAILQ_INSERT_TAIL(&uvm.page_active, pg, pageq);
> > > - }
> > >  }
> > > -
> > >  /*
> > >   * uvm_pagezero: zero fill a page
> > >   */
> > > Index: uvm/uvm_page.h
> > > ===================================================================
> > > RCS file: /cvs/src/sys/uvm/uvm_page.h,v
> > > retrieving revision 1.67
> > > diff -u -p -r1.67 uvm_page.h
> > > --- uvm/uvm_page.h        29 Jan 2022 06:25:33 -0000      1.67
> > > +++ uvm/uvm_page.h        5 May 2022 12:49:13 -0000
> > > @@ -224,6 +224,7 @@ boolean_t     uvm_page_physget(paddr_t *);
> > >  #endif
> > >  
> > >  void             uvm_pageactivate(struct vm_page *);
> > > +void             uvm_pagedequeue(struct vm_page *);
> > >  vaddr_t          uvm_pageboot_alloc(vsize_t);
> > >  void             uvm_pagecopy(struct vm_page *, struct vm_page *);
> > >  void             uvm_pagedeactivate(struct vm_page *);
> > > 
> > 
> > 

Reply via email to