Message ID | 20200528232508.1132382-2-guro@fb.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | mm: memcg accounting of percpu memory | expand |
On Thu, May 28, 2020 at 04:25:04PM -0700, Roman Gushchin wrote: > To implement accounting of percpu memory we need the information > about the size of freed object. Return it from pcpu_free_area(). > > Signed-off-by: Roman Gushchin <guro@fb.com> > --- > mm/percpu.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/mm/percpu.c b/mm/percpu.c > index 696367b18222..aa36b78d45a6 100644 > --- a/mm/percpu.c > +++ b/mm/percpu.c > @@ -1211,11 +1211,14 @@ static int pcpu_alloc_area(struct pcpu_chunk *chunk, int alloc_bits, > * > * This function determines the size of an allocation to free using > * the boundary bitmap and clears the allocation map. > + * > + * RETURNS: > + * Number of freed bytes. > */ > -static void pcpu_free_area(struct pcpu_chunk *chunk, int off) > +static int pcpu_free_area(struct pcpu_chunk *chunk, int off) > { > struct pcpu_block_md *chunk_md = &chunk->chunk_md; > - int bit_off, bits, end, oslot; > + int bit_off, bits, end, oslot, freed; > > lockdep_assert_held(&pcpu_lock); > pcpu_stats_area_dealloc(chunk); > @@ -1230,8 +1233,10 @@ static void pcpu_free_area(struct pcpu_chunk *chunk, int off) > bits = end - bit_off; > bitmap_clear(chunk->alloc_map, bit_off, bits); > > + freed = bits * PCPU_MIN_ALLOC_SIZE; > + > /* update metadata */ > - chunk->free_bytes += bits * PCPU_MIN_ALLOC_SIZE; > + chunk->free_bytes += freed; > > /* update first free bit */ > chunk_md->first_free = min(chunk_md->first_free, bit_off); > @@ -1239,6 +1244,8 @@ static void pcpu_free_area(struct pcpu_chunk *chunk, int off) > pcpu_block_update_hint_free(chunk, bit_off, bits); > > pcpu_chunk_relocate(chunk, oslot); > + > + return freed; > } > > static void pcpu_init_md_block(struct pcpu_block_md *block, int nr_bits) > -- > 2.25.4 > Sorry for the delay. Acked-by: Dennis Zhou <dennis@kernel.org> What's the status of the depending patches? It might be easiest to have Andrew pick these up once the depending patch series is settled. Thanks, Dennis
diff --git a/mm/percpu.c b/mm/percpu.c index 696367b18222..aa36b78d45a6 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -1211,11 +1211,14 @@ static int pcpu_alloc_area(struct pcpu_chunk *chunk, int alloc_bits, * * This function determines the size of an allocation to free using * the boundary bitmap and clears the allocation map. + * + * RETURNS: + * Number of freed bytes. */ -static void pcpu_free_area(struct pcpu_chunk *chunk, int off) +static int pcpu_free_area(struct pcpu_chunk *chunk, int off) { struct pcpu_block_md *chunk_md = &chunk->chunk_md; - int bit_off, bits, end, oslot; + int bit_off, bits, end, oslot, freed; lockdep_assert_held(&pcpu_lock); pcpu_stats_area_dealloc(chunk); @@ -1230,8 +1233,10 @@ static void pcpu_free_area(struct pcpu_chunk *chunk, int off) bits = end - bit_off; bitmap_clear(chunk->alloc_map, bit_off, bits); + freed = bits * PCPU_MIN_ALLOC_SIZE; + /* update metadata */ - chunk->free_bytes += bits * PCPU_MIN_ALLOC_SIZE; + chunk->free_bytes += freed; /* update first free bit */ chunk_md->first_free = min(chunk_md->first_free, bit_off); @@ -1239,6 +1244,8 @@ static void pcpu_free_area(struct pcpu_chunk *chunk, int off) pcpu_block_update_hint_free(chunk, bit_off, bits); pcpu_chunk_relocate(chunk, oslot); + + return freed; } static void pcpu_init_md_block(struct pcpu_block_md *block, int nr_bits)
To implement accounting of percpu memory we need the information about the size of freed object. Return it from pcpu_free_area(). Signed-off-by: Roman Gushchin <guro@fb.com> --- mm/percpu.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)