thank you for looking at this.

ive committed it with tweaks based on your suggestions.

> On 24 Oct 2016, at 22:15, Alexander Bluhm <alexander.bl...@gmx.net> wrote:
> 
> On Mon, Oct 24, 2016 at 02:48:03PM +1000, David Gwynne wrote:
>> cos its not resizing the allocation, its allocating them for new cpus.
> 
> realloc is not a good name, so yes to renaming.
> 
>> the same goes for counters_realloc being named counters_alloc_ncpus.
> 
> Does the n mean new?  This is never mentioned, I initially thought
> it means number.  What about ..._newcpus or ..._allcpus?
> 
>> +.Fn COUNTERS_BOOT_INITIALIZER
>> +is used to initialise a cpumem pointer with the memory that was previously
>> +allocated using
>> +.Fn COUNTERS_BOOT_MEMORY
>> +and identified by
>> +.Fa NAME .
> 
> The boot counters are zero initially.
> 
>> +The
>> +.Fa type
>> +argument specifies the type of memory that the counters will be
>> +allocated as via
>> +.Xr malloc 9 .
>> +The memory will be zeroed on allocation by passing
>> +.Fn M_ZERO
> 
> Is the M_ZERO an implementation detail for counters that should not
> be mentionend in the man page?
> 
>> +to
>> +.Xr malloc 9 .
> 
> The counters on the boot cpu are preserved.
> 
>> +.Fn CPUMEM_BOOT_INITIALIZER
>> +is used to initialise a cpumem pointer with the memory that was previously
>> +allocated using
>> +.Fn CPUMEM_BOOT_MEMORY
>> +and identified by
>> +.Fa NAME .
> 
> The boot cpu uses static memory that is initially zero.
> 
>> +.Fn cpumem_malloc_ncpus
>> +allocates
>> +.Fa sz
>> +bytes of
>> +.Fa type
>> +memory for each additional CPU using
>> +.Xr malloc 9 .
>> +The memory will be zeroed on allocation by passing
>> +.Fn M_ZERO
>> +to
>> +.Xr malloc 9 .
> 
> The the memory of the boot cpu is preserved.
> 
>> ===================================================================
>> RCS file: /cvs/src/sys/kern/subr_percpu.c,v
>> retrieving revision 1.3
>> diff -u -p -r1.3 subr_percpu.c
>> --- sys/kern/subr_percpu.c   24 Oct 2016 03:15:38 -0000      1.3
>> +++ sys/kern/subr_percpu.c   24 Oct 2016 04:43:34 -0000
>> @@ -76,7 +76,7 @@ cpumem_malloc(size_t sz, int type)
>> }
>> 
>> struct cpumem *
>> -cpumem_realloc(struct cpumem *bootcm, size_t sz, int type)
>> +cpumem_alloc_ncpus(struct cpumem *bootcm, size_t sz, int type)
> 
> This should be cpumem_malloc_ncpus.
> 
>> {
>>      struct cpumem *cm;
>>      unsigned int cpu;
>> @@ -146,10 +146,10 @@ counters_alloc(unsigned int n, int type)
>> }
>> 
>> struct cpumem *
>> -counters_realloc(struct cpumem *cm, unsigned int n, int type)
>> +counters_alloc_ncpus(struct cpumem *cm, unsigned int n, int type)
>> {
>>      n++; /* the generation number */
>> -    return (cpumem_realloc(cm, n * sizeof(uint64_t), type));
>> +    return (cpumem_alloc_ncpus(cm, n * sizeof(uint64_t), type));
> 
> This should be cpumem_malloc_ncpus.
> 
>> }
>> 
>> void
>> @@ -259,7 +259,7 @@ cpumem_malloc(size_t sz, int type)
>> }
>> 
>> struct cpumem *
>> -cpumem_realloc(struct cpumem *cm, size_t sz, int type)
>> +cpumem_allod_ncpus(struct cpumem *cm, size_t sz, int type)
> 
> This should be cpumem_malloc_ncpus.
> 
>> {
>>      return (cm);
>> }
>> @@ -291,10 +291,10 @@ counters_alloc(unsigned int n, int type)
>> }
>> 
>> struct cpumem *
>> -counters_realloc(struct cpumem *cm, unsigned int n, int type)
>> +counters_alloc_ncpus(struct cpumem *cm, unsigned int n, int type)
>> {
>>      /* this is unecessary, but symmetrical */
>> -    return (cpumem_realloc(cm, n * sizeof(uint64_t), type));
>> +    return (cpumem_alloc_ncpus(cm, n * sizeof(uint64_t), type));
> 
> This should be cpumem_malloc_ncpus.
> 
>> }
>> 
>> void
>> Index: sys/sys/percpu.h
>> ===================================================================
>> RCS file: /cvs/src/sys/sys/percpu.h,v
>> retrieving revision 1.2
>> diff -u -p -r1.2 percpu.h
>> --- sys/sys/percpu.h 24 Oct 2016 03:15:35 -0000      1.2
>> +++ sys/sys/percpu.h 24 Oct 2016 04:43:34 -0000
>> @@ -54,7 +54,7 @@ struct cpumem      *cpumem_get(struct pool *)
>> void          cpumem_put(struct pool *, struct cpumem *);
>> 
>> struct cpumem        *cpumem_malloc(size_t, int);
>> -struct cpumem       *cpumem_realloc(struct cpumem *, size_t, int);
>> +struct cpumem       *cpumem_malloc_ncpus(struct cpumem *, size_t, int);
> 
> I wonder how this compiled as you use cpumem_malloc_ncpus correctly
> here.
> 
>> void          cpumem_free(struct cpumem *, int, size_t);
>> 
>> void         *cpumem_first(struct cpumem_iter *, struct cpumem *);
>> @@ -111,7 +111,7 @@ static struct {                                          
>>                 \
>>  */
>> 
>> struct cpumem        *counters_alloc(unsigned int, int);
>> -struct cpumem       *counters_realloc(struct cpumem *, unsigned int, int);
>> +struct cpumem       *counters_alloc_ncpus(struct cpumem *, unsigned int, 
>> int);
>> void          counters_free(struct cpumem *, int, unsigned int);
>> void          counters_read(struct cpumem *, uint64_t *, unsigned int);
>> void          counters_zero(struct cpumem *, unsigned int);

Reply via email to