From: Baoquan He <bhe@redhat.com>
To: Dennis Zhou <dennis@kernel.org>
Cc: linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>,
Christoph Lameter <cl@linux.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org
Subject: Re: [PATCH 4/8] mm/percpu: add comment to state the empty populated pages accounting
Date: Tue, 25 Oct 2022 11:47:51 +0800 [thread overview]
Message-ID: <Y1dcZ2ESiv6usZFn@MiWiFi-R3L-srv> (raw)
In-Reply-To: <Y1bDtmfCee+V32Ml@fedora>
On 10/24/22 at 09:56am, Dennis Zhou wrote:
> On Mon, Oct 24, 2022 at 04:14:31PM +0800, Baoquan He wrote:
> > When allocating an area from a chunk, pcpu_block_update_hint_alloc()
> > is called to update chunk metadata, including chunk's and global
> > nr_empty_pop_pages. However, if the allocation is not atomic, some
> > blocks may not be populated with pages yet, while we still account it
> > here. The number of pages will be subtracted with pcpu_chunk_populated()
> > when populating pages.
> >
> > Adding code comment to make that more understandable.
> >
> > Signed-off-by: Baoquan He <bhe@redhat.com>
> > ---
> > mm/percpu.c | 14 +++++++++++---
> > 1 file changed, 11 insertions(+), 3 deletions(-)
> >
> > diff --git a/mm/percpu.c b/mm/percpu.c
> > index a8121302a79c..09e407338573 100644
> > --- a/mm/percpu.c
> > +++ b/mm/percpu.c
> > @@ -831,13 +831,15 @@ static void pcpu_block_update_hint_alloc(struct pcpu_chunk *chunk, int bit_off,
> >
> > /*
> > * Update s_block.
> > - * block->first_free must be updated if the allocation takes its place.
> > - * If the allocation breaks the contig_hint, a scan is required to
> > - * restore this hint.
> > */
> > if (s_block->contig_hint == PCPU_BITMAP_BLOCK_BITS)
> > nr_empty_pages++;
> >
> > + /*
> > + * block->first_free must be updated if the allocation takes its place.
> > + * If the allocation breaks the contig_hint, a scan is required to
> > + * restore this hint.
> > + */
> > if (s_off == s_block->first_free)
> > s_block->first_free = find_next_zero_bit(
> > pcpu_index_alloc_map(chunk, s_index),
> > @@ -912,6 +914,12 @@ static void pcpu_block_update_hint_alloc(struct pcpu_chunk *chunk, int bit_off,
> > }
> > }
> >
> > + /*
> > + * If the allocation is not atomic, some blocks may not
> > + * be populated with pages, while we account it here.
> > + * The number of pages will be subtracted with
> > + * pcpu_chunk_populated() when populating pages.
> > + */
> > if (nr_empty_pages)
> > pcpu_update_empty_pages(chunk, -nr_empty_pages);
> >
> > --
> > 2.34.1
> >
>
> Heh, that's a little more subtle than I remember it being.
>
> Acked-by: Dennis Zhou <dennis@kernel.org>
Thanks for reviewing, Dennis.
When I rechecked the code comment, I realized I had said the opposite in
v1 about the newly added code comment. It subtracts the nr_empty_pop_pages
in pcpu_block_update_hint_alloc() whether it's atomic allocation or not.
If non atomic case, the number will be added back in pcpu_chunk_populated()
when populating pages.
I have updated and resent v2, sorry for the mistake.
Thanks
Baoquan
next prev parent reply other threads:[~2022-10-25 3:48 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-24 8:14 [PATCH 0/8] Cleanup and optimization patches for percpu Baoquan He
2022-10-24 8:14 ` [PATCH 1/8] mm/percpu: remove unused pcpu_map_extend_chunks Baoquan He
2022-10-24 16:51 ` Dennis Zhou
2022-10-24 8:14 ` [PATCH 2/8] mm/percpu: use list_first_entry_or_null in pcpu_reclaim_populated() Baoquan He
2022-10-24 10:17 ` kernel test robot
2022-10-24 16:52 ` Dennis Zhou
2022-10-25 3:11 ` [PATCH v2 " Baoquan He
2022-10-24 8:14 ` [PATCH 3/8] mm/percpu: Update the code comment when creating new chunk Baoquan He
2022-10-24 16:54 ` Dennis Zhou
2022-10-24 8:14 ` [PATCH 4/8] mm/percpu: add comment to state the empty populated pages accounting Baoquan He
2022-10-24 16:56 ` Dennis Zhou
2022-10-25 3:47 ` Baoquan He [this message]
2022-10-25 3:45 ` [PATCH v2 " Baoquan He
2022-10-24 8:14 ` [PATCH 5/8] mm/percpu: replace the goto with break Baoquan He
2022-10-24 17:00 ` Dennis Zhou
2022-10-24 8:14 ` [PATCH 6/8] mm/percpu.c: remove the lcm code since block size is fixed at page size Baoquan He
2022-10-24 17:00 ` Dennis Zhou
2022-10-24 8:14 ` [PATCH 7/8] mm/percpu: remove unused PERCPU_DYNAMIC_EARLY_SLOTS Baoquan He
2022-10-24 17:03 ` Dennis Zhou
2022-10-24 8:14 ` [PATCH 8/8] mm/slub, percpu: correct the calculation of early percpu allocation size Baoquan He
2022-10-24 13:52 ` Hyeonggon Yoo
2022-10-24 17:03 ` Dennis Zhou
2022-11-06 20:56 ` Vlastimil Babka
2022-11-07 4:35 ` Baoquan He
2022-11-07 7:20 ` Dennis Zhou
2022-11-07 8:23 ` Baoquan He
2022-10-24 17:09 ` [PATCH 0/8] Cleanup and optimization patches for percpu Dennis Zhou
2022-11-08 7:05 ` Dennis Zhou
2022-11-08 9:14 ` Baoquan He
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y1dcZ2ESiv6usZFn@MiWiFi-R3L-srv \
--to=bhe@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=dennis@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).