Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1670024 > unrolled thread
| Started by | Dennis Zhou <dennisz@fb.com> |
|---|---|
| First post | 2017-06-20 01:30 +0200 |
| Last post | 2017-06-20 21:40 +0200 |
| Articles | 6 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 0/4] percpu: add basic stats and tracepoints to percpu allocator Dennis Zhou <dennisz@fb.com> - 2017-06-20 01:30 +0200
[PATCH 1/4] percpu: add missing lockdep_assert_held to func pcpu_free_area Dennis Zhou <dennisz@fb.com> - 2017-06-20 01:30 +0200
[PATCH 2/4] percpu: migrate percpu data structures to internal header Dennis Zhou <dennisz@fb.com> - 2017-06-20 01:30 +0200
Re: [PATCH 0/4] percpu: add basic stats and tracepoints to percpu allocator Tejun Heo <tj@kernel.org> - 2017-06-20 19:50 +0200
Re: [PATCH 0/4] percpu: add basic stats and tracepoints to percpu allocator Dennis Zhou <dennisz@fb.com> - 2017-06-20 21:20 +0200
Re: [PATCH 0/4] percpu: add basic stats and tracepoints to percpu allocator Tejun Heo <tj@kernel.org> - 2017-06-20 21:40 +0200
| From | Dennis Zhou <dennisz@fb.com> |
|---|---|
| Date | 2017-06-20 01:30 +0200 |
| Subject | [PATCH 0/4] percpu: add basic stats and tracepoints to percpu allocator |
| Message-ID | <tUehj-Na-11@gated-at.bofh.it> |
There is limited visibility into the percpu memory allocator making it hard to understand usage patterns. Without these concrete numbers, we are left to conjecture about the correctness of percpu memory patterns and usage. Additionally, there is no mechanism to review the correctness/efficiency of the current implementation. This patchset address the following: - Adds basic statistics to reason about the number of allocations over the lifetime, allocation sizes, and fragmentation. - Adds tracepoints to enable better debug capabilities as well as the ability to review allocation requests and corresponding decisions. This patchiest contains the following four patches: 0001-percpu-add-missing-lockdep_assert_held-to-func-pcpu_.patch 0002-percpu-migrate-percpu-data-structures-to-internal-he.patch 0003-percpu-expose-statistics-about-percpu-memory-via-deb.patch 0004-percpu-add-tracepoint-support-for-percpu-memory.patch 0001 adds a missing lockdep_assert_held for pcpu_lock to improve consistency and safety. 0002 prepares for the following patches by moving the definition of data structures and exposes previously static variables. 0003 adds percpu statistics via debugfs. 0004 adds tracepoints to key percpu events: chunk creation/deletion and area allocation/free/failure. This patchset is on top of linus#master 1132d5e. diffstats below: percpu: add missing lockdep_assert_held to func pcpu_free_area percpu: migrate percpu data structures to internal header percpu: expose statistics about percpu memory via debugfs percpu: add tracepoint support for percpu memory include/trace/events/percpu.h | 125 ++++++++++++++++++++++++ mm/Kconfig | 8 ++ mm/Makefile | 1 + mm/percpu-internal.h | 164 +++++++++++++++++++++++++++++++ mm/percpu-km.c | 6 ++ mm/percpu-stats.c | 222 ++++++++++++++++++++++++++++++++++++++++++ mm/percpu-vm.c | 7 ++ mm/percpu.c | 53 +++++----- 8 files changed, 563 insertions(+), 23 deletions(-) create mode 100644 include/trace/events/percpu.h create mode 100644 mm/percpu-internal.h create mode 100644 mm/percpu-stats.c Thanks, Dennis
[toc] | [next] | [standalone]
| From | Dennis Zhou <dennisz@fb.com> |
|---|---|
| Date | 2017-06-20 01:30 +0200 |
| Subject | [PATCH 1/4] percpu: add missing lockdep_assert_held to func pcpu_free_area |
| Message-ID | <tUehk-Na-19@gated-at.bofh.it> |
| In reply to | #1670024 |
Add a missing lockdep_assert_held for pcpu_lock to improve consistency and safety throughout mm/percpu.c. Signed-off-by: Dennis Zhou <dennisz@fb.com> --- mm/percpu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/percpu.c b/mm/percpu.c index e0aa8ae..f94a5eb 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -672,6 +672,8 @@ static void pcpu_free_area(struct pcpu_chunk *chunk, int freeme, int to_free = 0; int *p; + lockdep_assert_held(&pcpu_lock); + freeme |= 1; /* we are searching for <given offset, in use> pair */ i = 0; -- 2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Dennis Zhou <dennisz@fb.com> |
|---|---|
| Date | 2017-06-20 01:30 +0200 |
| Subject | [PATCH 2/4] percpu: migrate percpu data structures to internal header |
| Message-ID | <tUehk-Na-17@gated-at.bofh.it> |
| In reply to | #1670024 |
Migrates pcpu_chunk definition and a few percpu static variables to an
internal header file from mm/percpu.c. These will be used with debugfs
to expose statistics about percpu memory improving visibility regarding
allocations and fragmentation.
Signed-off-by: Dennis Zhou <dennisz@fb.com>
---
mm/percpu-internal.h | 33 +++++++++++++++++++++++++++++++++
mm/percpu.c | 30 +++++++-----------------------
2 files changed, 40 insertions(+), 23 deletions(-)
create mode 100644 mm/percpu-internal.h
diff --git a/mm/percpu-internal.h b/mm/percpu-internal.h
new file mode 100644
index 0000000..8b6cb2a
--- /dev/null
+++ b/mm/percpu-internal.h
@@ -0,0 +1,33 @@
+#ifndef _MM_PERCPU_INTERNAL_H
+#define _MM_PERCPU_INTERNAL_H
+
+#include <linux/types.h>
+#include <linux/percpu.h>
+
+struct pcpu_chunk {
+ struct list_head list; /* linked to pcpu_slot lists */
+ int free_size; /* free bytes in the chunk */
+ int contig_hint; /* max contiguous size hint */
+ void *base_addr; /* base address of this chunk */
+
+ int map_used; /* # of map entries used before the sentry */
+ int map_alloc; /* # of map entries allocated */
+ int *map; /* allocation map */
+ struct list_head map_extend_list;/* on pcpu_map_extend_chunks */
+
+ void *data; /* chunk data */
+ int first_free; /* no free below this */
+ bool immutable; /* no [de]population allowed */
+ int nr_populated; /* # of populated pages */
+ unsigned long populated[]; /* populated bitmap */
+};
+
+extern spinlock_t pcpu_lock;
+
+extern struct list_head *pcpu_slot __read_mostly;
+extern int pcpu_nr_slots __read_mostly;
+
+extern struct pcpu_chunk *pcpu_first_chunk;
+extern struct pcpu_chunk *pcpu_reserved_chunk;
+
+#endif
diff --git a/mm/percpu.c b/mm/percpu.c
index f94a5eb..5cf7d73 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -76,6 +76,8 @@
#include <asm/tlbflush.h>
#include <asm/io.h>
+#include "percpu-internal.h"
+
#define PCPU_SLOT_BASE_SHIFT 5 /* 1-31 shares the same slot */
#define PCPU_DFL_MAP_ALLOC 16 /* start a map with 16 ents */
#define PCPU_ATOMIC_MAP_MARGIN_LOW 32
@@ -103,29 +105,11 @@
#define __pcpu_ptr_to_addr(ptr) (void __force *)(ptr)
#endif /* CONFIG_SMP */
-struct pcpu_chunk {
- struct list_head list; /* linked to pcpu_slot lists */
- int free_size; /* free bytes in the chunk */
- int contig_hint; /* max contiguous size hint */
- void *base_addr; /* base address of this chunk */
-
- int map_used; /* # of map entries used before the sentry */
- int map_alloc; /* # of map entries allocated */
- int *map; /* allocation map */
- struct list_head map_extend_list;/* on pcpu_map_extend_chunks */
-
- void *data; /* chunk data */
- int first_free; /* no free below this */
- bool immutable; /* no [de]population allowed */
- int nr_populated; /* # of populated pages */
- unsigned long populated[]; /* populated bitmap */
-};
-
static int pcpu_unit_pages __read_mostly;
static int pcpu_unit_size __read_mostly;
static int pcpu_nr_units __read_mostly;
static int pcpu_atom_size __read_mostly;
-static int pcpu_nr_slots __read_mostly;
+int pcpu_nr_slots __read_mostly;
static size_t pcpu_chunk_struct_size __read_mostly;
/* cpus with the lowest and highest unit addresses */
@@ -149,7 +133,7 @@ static const size_t *pcpu_group_sizes __read_mostly;
* chunks, this one can be allocated and mapped in several different
* ways and thus often doesn't live in the vmalloc area.
*/
-static struct pcpu_chunk *pcpu_first_chunk;
+struct pcpu_chunk *pcpu_first_chunk;
/*
* Optional reserved chunk. This chunk reserves part of the first
@@ -158,13 +142,13 @@ static struct pcpu_chunk *pcpu_first_chunk;
* area doesn't exist, the following variables contain NULL and 0
* respectively.
*/
-static struct pcpu_chunk *pcpu_reserved_chunk;
+struct pcpu_chunk *pcpu_reserved_chunk;
static int pcpu_reserved_chunk_limit;
-static DEFINE_SPINLOCK(pcpu_lock); /* all internal data structures */
+DEFINE_SPINLOCK(pcpu_lock); /* all internal data structures */
static DEFINE_MUTEX(pcpu_alloc_mutex); /* chunk create/destroy, [de]pop, map ext */
-static struct list_head *pcpu_slot __read_mostly; /* chunk list slots */
+struct list_head *pcpu_slot __read_mostly; /* chunk list slots */
/* chunks which need their map areas extended, protected by pcpu_lock */
static LIST_HEAD(pcpu_map_extend_chunks);
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Tejun Heo <tj@kernel.org> |
|---|---|
| Date | 2017-06-20 19:50 +0200 |
| Subject | Re: [PATCH 0/4] percpu: add basic stats and tracepoints to percpu allocator |
| Message-ID | <tUvrQ-3dH-19@gated-at.bofh.it> |
| In reply to | #1670024 |
On Mon, Jun 19, 2017 at 07:28:28PM -0400, Dennis Zhou wrote: > There is limited visibility into the percpu memory allocator making it hard to > understand usage patterns. Without these concrete numbers, we are left to > conjecture about the correctness of percpu memory patterns and usage. > Additionally, there is no mechanism to review the correctness/efficiency of the > current implementation. > > This patchset address the following: > - Adds basic statistics to reason about the number of allocations over the > lifetime, allocation sizes, and fragmentation. > - Adds tracepoints to enable better debug capabilities as well as the ability > to review allocation requests and corresponding decisions. > > This patchiest contains the following four patches: > 0001-percpu-add-missing-lockdep_assert_held-to-func-pcpu_.patch > 0002-percpu-migrate-percpu-data-structures-to-internal-he.patch > 0003-percpu-expose-statistics-about-percpu-memory-via-deb.patch > 0004-percpu-add-tracepoint-support-for-percpu-memory.patch Applied to percpu/for-4.13. I had to update 0002 because of the recent __ro_after_init changes. Can you please see whether I made any mistakes while updating it? git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu.git for-4.13 Thanks. -- tejun
[toc] | [prev] | [next] | [standalone]
| From | Dennis Zhou <dennisz@fb.com> |
|---|---|
| Date | 2017-06-20 21:20 +0200 |
| Subject | Re: [PATCH 0/4] percpu: add basic stats and tracepoints to percpu allocator |
| Message-ID | <tUwQW-4dQ-7@gated-at.bofh.it> |
| In reply to | #1670997 |
On 6/20/17, 1:45 PM, "Tejun Heo" <htejun@gmail.com on behalf of tj@kernel.org> wrote: > Applied to percpu/for-4.13. I had to update 0002 because of the > recent __ro_after_init changes. Can you please see whether I made any > mistakes while updating it? There is a tagging mismatch in 0002. Can you please change or remove the __read_mostly annotation in mm/percpu-internal.h? Thanks, Dennis
[toc] | [prev] | [next] | [standalone]
| From | Tejun Heo <tj@kernel.org> |
|---|---|
| Date | 2017-06-20 21:40 +0200 |
| Subject | Re: [PATCH 0/4] percpu: add basic stats and tracepoints to percpu allocator |
| Message-ID | <tUxah-4kt-5@gated-at.bofh.it> |
| In reply to | #1671029 |
On Tue, Jun 20, 2017 at 07:12:49PM +0000, Dennis Zhou wrote: > On 6/20/17, 1:45 PM, "Tejun Heo" <htejun@gmail.com on behalf of tj@kernel.org> wrote: > > Applied to percpu/for-4.13. I had to update 0002 because of the > > recent __ro_after_init changes. Can you please see whether I made any > > mistakes while updating it? > > There is a tagging mismatch in 0002. Can you please change or remove the __read_mostly annotation in mm/percpu-internal.h? Fixed. Thanks. -- tejun
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web