diff options
author | Oleg Nesterov <oleg@redhat.com> | 2013-10-16 16:10:04 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2013-10-29 07:02:52 -0400 |
commit | 3ea2f2b96f9e636f49eb10962e96db3e19cab157 (patch) | |
tree | 47cbcc90d4daa2155c2a5f0ebd357a0499d78316 /kernel/events | |
parent | 32c5fb7e7d18b4fd37c5e29dea731151e9d66866 (diff) |
perf: Do not waste PAGE_SIZE bytes for ALIGN(8) in perf_event_mmap_event()
perf_event_mmap_event() does kzalloc(PATH_MAX + sizeof(u64)) to
ensure we can align the size later. However this means that we
actually allocate PAGE_SIZE * 2 buffer, seems too much.
Change this code to allocate PATH_MAX==PAGE_SIZE bytes, but tell
d_path() to not use the last sizeof(u64) bytes.
Note: it is not clear why do we need __GFP_ZERO, see the next patch.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20131016201004.GC23214@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/events')
-rw-r--r-- | kernel/events/core.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 3ea560551a2a..b409e757cadc 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -5113,17 +5113,18 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event) | |||
5113 | if (file) { | 5113 | if (file) { |
5114 | struct inode *inode; | 5114 | struct inode *inode; |
5115 | dev_t dev; | 5115 | dev_t dev; |
5116 | /* | 5116 | |
5117 | * d_path works from the end of the rb backwards, so we | 5117 | buf = kzalloc(PATH_MAX, GFP_KERNEL); |
5118 | * need to add enough zero bytes after the string to handle | ||
5119 | * the 64bit alignment we do later. | ||
5120 | */ | ||
5121 | buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL); | ||
5122 | if (!buf) { | 5118 | if (!buf) { |
5123 | name = strncpy(tmp, "//enomem", sizeof(tmp)); | 5119 | name = strncpy(tmp, "//enomem", sizeof(tmp)); |
5124 | goto got_name; | 5120 | goto got_name; |
5125 | } | 5121 | } |
5126 | name = d_path(&file->f_path, buf, PATH_MAX); | 5122 | /* |
5123 | * d_path() works from the end of the rb backwards, so we | ||
5124 | * need to add enough zero bytes after the string to handle | ||
5125 | * the 64bit alignment we do later. | ||
5126 | */ | ||
5127 | name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64)); | ||
5127 | if (IS_ERR(name)) { | 5128 | if (IS_ERR(name)) { |
5128 | name = strncpy(tmp, "//toolong", sizeof(tmp)); | 5129 | name = strncpy(tmp, "//toolong", sizeof(tmp)); |
5129 | goto got_name; | 5130 | goto got_name; |