Jeff,

On Sun, Jan 05, 2020 at 10:54:26PM +0000, Jeff Roberson wrote:
J> Author: jeff
J> Date: Sun Jan  5 22:54:25 2020
J> New Revision: 356389
J> URL: https://svnweb.freebsd.org/changeset/base/356389
J> 
J> Log:
J>   The fix in r356353 was insufficient.  Not every architecture returns 0 for
J>   EARLY_COUNTER.  Only amd64 seems to.
J>   
J>   Suggested by:      markj
J>   Reported by:       lwhsu
J>   Reviewed by:       markj
J>   PR:                243117
J> 
J> Modified:
J>   head/sys/vm/uma_core.c
J> 
J> Modified: head/sys/vm/uma_core.c
J> 
==============================================================================
J> --- head/sys/vm/uma_core.c   Sun Jan  5 21:35:02 2020        (r356388)
J> +++ head/sys/vm/uma_core.c   Sun Jan  5 22:54:25 2020        (r356389)
J> @@ -4153,8 +4153,10 @@ uma_zone_get_cur(uma_zone_t zone)
J>      int64_t nitems;
J>      u_int i;
J>  
J> -    nitems = counter_u64_fetch(zone->uz_allocs) -
J> -        counter_u64_fetch(zone->uz_frees);
J> +    nitems = 0;
J> +    if (zone->uz_allocs != EARLY_COUNTER && zone->uz_frees != EARLY_COUNTER)
J> +            nitems = counter_u64_fetch(zone->uz_allocs) -
J> +                counter_u64_fetch(zone->uz_frees);
J>      CPU_FOREACH(i)
J>              nitems += atomic_load_64(&zone->uz_cpu[i].uc_allocs) -
J>                  atomic_load_64(&zone->uz_cpu[i].uc_frees);
J> @@ -4168,7 +4170,9 @@ uma_zone_get_allocs(uma_zone_t zone)
J>      uint64_t nitems;
J>      u_int i;
J>  
J> -    nitems = counter_u64_fetch(zone->uz_allocs);
J> +    nitems = 0;
J> +    if (zone->uz_allocs != EARLY_COUNTER)
J> +            nitems = counter_u64_fetch(zone->uz_allocs);
J>      CPU_FOREACH(i)
J>              nitems += atomic_load_64(&zone->uz_cpu[i].uc_allocs);
J>  
J> @@ -4181,7 +4185,9 @@ uma_zone_get_frees(uma_zone_t zone)
J>      uint64_t nitems;
J>      u_int i;
J>  
J> -    nitems = counter_u64_fetch(zone->uz_frees);
J> +    nitems = 0;
J> +    if (zone->uz_frees != EARLY_COUNTER)
J> +            nitems = counter_u64_fetch(zone->uz_frees);
J>      CPU_FOREACH(i)
J>              nitems += atomic_load_64(&zone->uz_cpu[i].uc_frees);

IMHO, tidier code would be not to check the pointers, but check UMA booted 
status:

        if (__predict_true(booted == BOOT_RUNNING))
                nitems = counter_u64_fetch(zone->uz_frees);

-- 
Gleb Smirnoff
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to