From: tip-bot for Oleg Nesterov <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
peterz@infradead.org, oleg@redhat.com, tglx@linutronix.de
Subject: [tip:perf/core] perf: Do not waste PAGE_SIZE bytes for ALIGN(8) in perf_event_mmap_event()
Date: Tue, 29 Oct 2013 07:08:16 -0700 [thread overview]
Message-ID: <tip-3ea2f2b96f9e636f49eb10962e96db3e19cab157@git.kernel.org> (raw)
In-Reply-To: <20131016201004.GC23214@redhat.com>
Commit-ID: 3ea2f2b96f9e636f49eb10962e96db3e19cab157
Gitweb: http://git.kernel.org/tip/3ea2f2b96f9e636f49eb10962e96db3e19cab157
Author: Oleg Nesterov <oleg@redhat.com>
AuthorDate: Wed, 16 Oct 2013 22:10:04 +0200
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 29 Oct 2013 12:02:52 +0100
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>
---
kernel/events/core.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 3ea5605..b409e75 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)
if (file) {
struct inode *inode;
dev_t dev;
- /*
- * d_path works from the end of the rb backwards, so we
- * need to add enough zero bytes after the string to handle
- * the 64bit alignment we do later.
- */
- buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
+
+ buf = kzalloc(PATH_MAX, GFP_KERNEL);
if (!buf) {
name = strncpy(tmp, "//enomem", sizeof(tmp));
goto got_name;
}
- name = d_path(&file->f_path, buf, PATH_MAX);
+ /*
+ * d_path() works from the end of the rb backwards, so we
+ * need to add enough zero bytes after the string to handle
+ * the 64bit alignment we do later.
+ */
+ name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
if (IS_ERR(name)) {
name = strncpy(tmp, "//toolong", sizeof(tmp));
goto got_name;
next prev parent reply other threads:[~2013-10-29 14:08 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-12 19:22 perf_event_mmap(vma) && !vma->vm_mm Oleg Nesterov
2013-10-14 10:24 ` Peter Zijlstra
2013-10-16 20:09 ` [PATCH 0/2] (Was: perf_event_mmap(vma) && !vma->vm_mm) Oleg Nesterov
2013-10-16 20:09 ` [PATCH 1/2] perf: Kill the dead !vma->vm_mm code in perf_event_mmap_event() Oleg Nesterov
2013-10-29 14:08 ` [tip:perf/core] perf: Kill the dead !vma-> vm_mm " tip-bot for Oleg Nesterov
2013-10-16 20:10 ` [PATCH 2/2] perf: Do not waste PAGE_SIZE bytes for ALIGN(8) " Oleg Nesterov
2013-10-29 14:08 ` tip-bot for Oleg Nesterov [this message]
2013-10-16 20:28 ` [PATCH 0/2] (Was: perf_event_mmap(vma) && !vma->vm_mm) Peter Zijlstra
2013-10-16 20:43 ` Oleg Nesterov
2013-10-16 20:55 ` Peter Zijlstra
2013-10-16 20:55 ` Oleg Nesterov
2013-10-16 20:58 ` Peter Zijlstra
2013-10-16 20:58 ` Oleg Nesterov
2013-10-16 21:16 ` Peter Zijlstra
2013-10-17 15:20 ` Oleg Nesterov
2013-10-17 15:27 ` Oleg Nesterov
2013-10-17 16:47 ` Peter Zijlstra
2013-10-17 18:24 ` Oleg Nesterov
2013-10-17 21:32 ` Peter Zijlstra
2013-11-06 13:19 ` [tip:perf/core] perf: Factor out strncpy() in perf_event_mmap_event() tip-bot for Oleg Nesterov
2013-10-17 16:38 ` [PATCH 0/2] (Was: perf_event_mmap(vma) && !vma->vm_mm) Peter Zijlstra
2013-10-17 15:22 ` [PATCH 3/2] perf: Optimize the fill/align code in perf_event_mmap_event() Oleg Nesterov
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=tip-3ea2f2b96f9e636f49eb10962e96db3e19cab157@git.kernel.org \
--to=tipbot@zytor.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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