linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roman Gushchin <guro@fb.com>
To: Pratik Sampat <psampat@linux.ibm.com>
Cc: Dennis Zhou <dennis@kernel.org>, Tejun Heo <tj@kernel.org>,
	Christoph Lameter <cl@linux.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>, <linux-mm@kvack.org>,
	<linux-kernel@vger.kernel.org>, <pratik.r.sampat@gmail.com>
Subject: Re: [PATCH v3 0/6] percpu: partial chunk depopulation
Date: Fri, 16 Apr 2021 10:13:20 -0700	[thread overview]
Message-ID: <YHnFsL2G2bpOH8ML@carbon.dhcp.thefacebook.com> (raw)
In-Reply-To: <7a001bf6-5708-fb04-4970-367d9845ccb9@linux.ibm.com>

On Fri, Apr 16, 2021 at 08:58:33PM +0530, Pratik Sampat wrote:
> Hello Dennis,
> 
> I apologize for the clutter of logs before, I'm pasting the logs of before and
> after the percpu test in the case of the patchset being applied on 5.12-rc6 and
> the vanilla kernel 5.12-rc6.
> 
> On 16/04/21 7:48 pm, Dennis Zhou wrote:
> > Hello,
> > 
> > On Fri, Apr 16, 2021 at 06:26:15PM +0530, Pratik Sampat wrote:
> > > Hello Roman,
> > > 
> > > I've tried the v3 patch series on a POWER9 and an x86 KVM setup.
> > > 
> > > My results of the percpu_test are as follows:
> > > Intel KVM 4CPU:4G
> > > Vanilla 5.12-rc6
> > > # ./percpu_test.sh
> > > Percpu:             1952 kB
> > > Percpu:           219648 kB
> > > Percpu:           219648 kB
> > > 
> > > 5.12-rc6 + with patchset applied
> > > # ./percpu_test.sh
> > > Percpu:             2080 kB
> > > Percpu:           219712 kB
> > > Percpu:            72672 kB
> > > 
> > > I'm able to see improvement comparable to that of what you're see too.
> > > 
> > > However, on POWERPC I'm unable to reproduce these improvements with the patchset in the same configuration
> > > 
> > > POWER9 KVM 4CPU:4G
> > > Vanilla 5.12-rc6
> > > # ./percpu_test.sh
> > > Percpu:             5888 kB
> > > Percpu:           118272 kB
> > > Percpu:           118272 kB
> > > 
> > > 5.12-rc6 + with patchset applied
> > > # ./percpu_test.sh
> > > Percpu:             6144 kB
> > > Percpu:           119040 kB
> > > Percpu:           119040 kB
> > > 
> > > I'm wondering if there's any architectural specific code that needs plumbing
> > > here?
> > > 
> > There shouldn't be. Can you send me the percpu_stats debug output before
> > and after?
> 
> I'll paste the whole debug stats before and after here.
> 5.12-rc6 + patchset
> -----BEFORE-----
> Percpu Memory Statistics
> Allocation Info:


Hm, this looks highly suspicious. Here is your stats in a more compact form:

Vanilla

nr_alloc            :         9038         nr_alloc            :        97046
nr_dealloc          :         6992	   nr_dealloc          :        94237
nr_cur_alloc        :         2046	   nr_cur_alloc        :         2809
nr_max_alloc        :         2178	   nr_max_alloc        :        90054
nr_chunks           :            3	   nr_chunks           :           11
nr_max_chunks       :            3	   nr_max_chunks       :           47
min_alloc_size      :            4	   min_alloc_size      :            4
max_alloc_size      :         1072	   max_alloc_size      :         1072
empty_pop_pages     :            5	   empty_pop_pages     :           29


Patched

nr_alloc            :         9040         nr_alloc            :        97048
nr_dealloc          :         6994	   nr_dealloc          :        95002
nr_cur_alloc        :         2046	   nr_cur_alloc        :         2046
nr_max_alloc        :         2208	   nr_max_alloc        :        90054
nr_chunks           :            3	   nr_chunks           :           48
nr_max_chunks       :            3	   nr_max_chunks       :           48
min_alloc_size      :            4	   min_alloc_size      :            4
max_alloc_size      :         1072	   max_alloc_size      :         1072
empty_pop_pages     :           12	   empty_pop_pages     :           61


So it looks like the number of chunks got bigger, as well as the number of
empty_pop_pages? This contradicts to what you wrote, so can you, please, make
sure that the data is correct and we're not messing two cases?

So it looks like for some reason sidelined (depopulated) chunks are not getting
freed completely. But I struggle to explain why the initial empty_pop_pages is
bigger with the same amount of chunks.

So, can you, please, apply the following patch and provide an updated statistics?

--

From d0d2bfdb891afec6bd63790b3492b852db490640 Mon Sep 17 00:00:00 2001
From: Roman Gushchin <guro@fb.com>
Date: Fri, 16 Apr 2021 09:54:38 -0700
Subject: [PATCH] percpu: include sidelined and depopulating chunks into debug
 output

Information about sidelined chunks and chunks in the depopulate queue
could be extremely valuable for debugging different problems.

Dump information about these chunks on pair with regular chunks
in percpu slots via percpu stats interface.

Signed-off-by: Roman Gushchin <guro@fb.com>
---
 mm/percpu-internal.h |  2 ++
 mm/percpu-stats.c    | 10 ++++++++++
 mm/percpu.c          |  4 ++--
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/mm/percpu-internal.h b/mm/percpu-internal.h
index 8e432663c41e..c11f115ced5c 100644
--- a/mm/percpu-internal.h
+++ b/mm/percpu-internal.h
@@ -90,6 +90,8 @@ extern spinlock_t pcpu_lock;
 extern struct list_head *pcpu_chunk_lists;
 extern int pcpu_nr_slots;
 extern int pcpu_nr_empty_pop_pages[];
+extern struct list_head pcpu_depopulate_list[];
+extern struct list_head pcpu_sideline_list[];
 
 extern struct pcpu_chunk *pcpu_first_chunk;
 extern struct pcpu_chunk *pcpu_reserved_chunk;
diff --git a/mm/percpu-stats.c b/mm/percpu-stats.c
index f6026dbcdf6b..af09ed1ea5f8 100644
--- a/mm/percpu-stats.c
+++ b/mm/percpu-stats.c
@@ -228,6 +228,16 @@ static int percpu_stats_show(struct seq_file *m, void *v)
 				}
 			}
 		}
+
+		list_for_each_entry(chunk, &pcpu_sideline_list[type], list) {
+			seq_puts(m, "Chunk (sidelined):\n");
+			chunk_map_stats(m, chunk, buffer);
+		}
+
+		list_for_each_entry(chunk, &pcpu_depopulate_list[type], list) {
+			seq_puts(m, "Chunk (to depopulate):\n");
+			chunk_map_stats(m, chunk, buffer);
+		}
 	}
 
 	spin_unlock_irq(&pcpu_lock);
diff --git a/mm/percpu.c b/mm/percpu.c
index 5bb294e394b3..ded3a7541cb2 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -185,13 +185,13 @@ int pcpu_nr_empty_pop_pages[PCPU_NR_CHUNK_TYPES];
  * List of chunks with a lot of free pages.  Used to depopulate them
  * asynchronously.
  */
-static struct list_head pcpu_depopulate_list[PCPU_NR_CHUNK_TYPES];
+struct list_head pcpu_depopulate_list[PCPU_NR_CHUNK_TYPES];
 
 /*
  * List of previously depopulated chunks.  They are not usually used for new
  * allocations, but can be returned back to service if a need arises.
  */
-static struct list_head pcpu_sideline_list[PCPU_NR_CHUNK_TYPES];
+struct list_head pcpu_sideline_list[PCPU_NR_CHUNK_TYPES];
 
 
 /*
-- 
2.30.2


  reply	other threads:[~2021-04-16 17:13 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-08  3:57 Roman Gushchin
2021-04-08  3:57 ` [PATCH v3 1/6] percpu: fix a comment about the chunks ordering Roman Gushchin
2021-04-16 21:06   ` Dennis Zhou
2021-04-08  3:57 ` [PATCH v3 2/6] percpu: split __pcpu_balance_workfn() Roman Gushchin
2021-04-16 21:06   ` Dennis Zhou
2021-04-08  3:57 ` [PATCH v3 3/6] percpu: make pcpu_nr_empty_pop_pages per chunk type Roman Gushchin
2021-04-16 21:08   ` Dennis Zhou
2021-04-08  3:57 ` [PATCH v3 4/6] percpu: generalize pcpu_balance_populated() Roman Gushchin
2021-04-16 21:09   ` Dennis Zhou
2021-04-08  3:57 ` [PATCH v3 5/6] percpu: factor out pcpu_check_chunk_hint() Roman Gushchin
2021-04-16 21:15   ` Dennis Zhou
2021-04-08  3:57 ` [PATCH v3 6/6] percpu: implement partial chunk depopulation Roman Gushchin
2021-04-16 12:56 ` [PATCH v3 0/6] percpu: " Pratik Sampat
2021-04-16 14:18   ` Dennis Zhou
2021-04-16 15:28     ` Pratik Sampat
2021-04-16 17:13       ` Roman Gushchin [this message]
2021-04-16 18:27         ` Pratik Sampat
2021-04-16 18:34           ` Roman Gushchin
2021-04-16 18:41             ` Pratik Sampat
2021-04-16 19:09               ` Roman Gushchin
2021-04-16 19:44                 ` Pratik Sampat
2021-04-16 20:03                   ` Roman Gushchin
2021-04-17  7:08                     ` Pratik Sampat
2021-04-16 21:47                   ` Dennis Zhou
2021-04-17  7:14                     ` Pratik Sampat
2021-04-16 16:21     ` Roman Gushchin

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=YHnFsL2G2bpOH8ML@carbon.dhcp.thefacebook.com \
    --to=guro@fb.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=pratik.r.sampat@gmail.com \
    --cc=psampat@linux.ibm.com \
    --cc=tj@kernel.org \
    --cc=vbabka@suse.cz \
    --subject='Re: [PATCH v3 0/6] percpu: partial chunk depopulation' \
    /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

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).