> I'm not comfortable with introducing more <sys/queue.h> APIs.  So
> perhaps we should just punt on the optimization and remove/insert all
> list items.  Removing the trap comments that pedro set up...

Since the removal macros poison pointers which should no longer be
dereferenced after the operation, I'm strongly in favour of sticking to
these operations, even if it costs a bit more, timewise.

> Index: uvm_aobj.c
> ===================================================================
> RCS file: /cvs/src/sys/uvm/uvm_aobj.c,v
> retrieving revision 1.61
> diff -u -p -r1.61 uvm_aobj.c
> --- uvm_aobj.c        13 Apr 2014 23:14:15 -0000      1.61
> +++ uvm_aobj.c        30 Apr 2014 14:52:33 -0000
> @@ -431,6 +431,7 @@ uao_shrink_hash(struct uvm_object *uobj,
>  {
>       struct uvm_aobj *aobj = (struct uvm_aobj *)uobj;
>       struct uao_swhash *new_swhash;
> +     struct uao_swhash_elt *elt;
>       unsigned long new_hashmask;
>       int i;
>  
> @@ -456,8 +457,13 @@ uao_shrink_hash(struct uvm_object *uobj,
>        * Even though the hash table size is changing, the hash of the buckets
>        * we are interested in copying should not change.
>        */
> -     for (i = 0; i < UAO_SWHASH_BUCKETS(aobj->u_pages); i++)
> -             LIST_FIRST(&new_swhash[i]) = LIST_FIRST(&aobj->u_swhash[i]);
> +     for (i = 0; i < UAO_SWHASH_BUCKETS(aobj->u_pages); i++) {
> +             while (LIST_EMPTY(&aobj->u_swhash[i]) == 0) {
> +                     elt = LIST_FIRST(&aobj->u_swhash[i]);
> +                     LIST_REMOVE(elt, list);
> +                     LIST_INSERT_HEAD(&new_swhash[i], elt, list);
> +             }
> +     }
>  
>       free(aobj->u_swhash, M_UVMAOBJ);
>  
> @@ -609,7 +615,6 @@ uao_grow_hash(struct uvm_object *uobj, i
>               return ENOMEM;
>  
>       for (i = 0; i < UAO_SWHASH_BUCKETS(aobj->u_pages); i++) {
> -             /* XXX pedro: shouldn't copying the list pointers be enough? */
>               while (LIST_EMPTY(&aobj->u_swhash[i]) == 0) {
>                       elt = LIST_FIRST(&aobj->u_swhash[i]);
>                       LIST_REMOVE(elt, list);
> 
> 
> 

Reply via email to