aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/events
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2013-10-17 14:24:17 -0400
committerIngo Molnar <mingo@kernel.org>2013-11-06 06:34:28 -0500
commitc7e548b45ce85f765f6262149dd60d9956a31d60 (patch)
tree2bdd4a20378e4881e88ba6af24724d68168c2915 /kernel/events
parenta94d342b9cb09edfe888ea972af0883b6a8d992b (diff)
perf: Factor out strncpy() in perf_event_mmap_event()
While this is really minor, but strncpy() does the unnecessary zero-padding till the end of tmp[16] and it is called every time we are going to use the string literal. Turn these strncpy()'s into the single strlcpy() under the new label, saves 72 bytes. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20131017182417.GA17753@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/events')
-rw-r--r--kernel/events/core.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 17b3c6cf1606..4dc078d18929 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5144,8 +5144,8 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
5144 5144
5145 buf = kmalloc(PATH_MAX, GFP_KERNEL); 5145 buf = kmalloc(PATH_MAX, GFP_KERNEL);
5146 if (!buf) { 5146 if (!buf) {
5147 name = strncpy(tmp, "//enomem", sizeof(tmp)); 5147 name = "//enomem";
5148 goto got_name; 5148 goto cpy_name;
5149 } 5149 }
5150 /* 5150 /*
5151 * d_path() works from the end of the rb backwards, so we 5151 * d_path() works from the end of the rb backwards, so we
@@ -5154,8 +5154,8 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
5154 */ 5154 */
5155 name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64)); 5155 name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
5156 if (IS_ERR(name)) { 5156 if (IS_ERR(name)) {
5157 name = strncpy(tmp, "//toolong", sizeof(tmp)); 5157 name = "//toolong";
5158 goto got_name; 5158 goto cpy_name;
5159 } 5159 }
5160 inode = file_inode(vma->vm_file); 5160 inode = file_inode(vma->vm_file);
5161 dev = inode->i_sb->s_dev; 5161 dev = inode->i_sb->s_dev;
@@ -5163,30 +5163,30 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
5163 gen = inode->i_generation; 5163 gen = inode->i_generation;
5164 maj = MAJOR(dev); 5164 maj = MAJOR(dev);
5165 min = MINOR(dev); 5165 min = MINOR(dev);
5166 5166 goto got_name;
5167 } else { 5167 } else {
5168 name = (char *)arch_vma_name(vma); 5168 name = (char *)arch_vma_name(vma);
5169 if (name) { 5169 if (name)
5170 name = strncpy(tmp, name, sizeof(tmp) - 1); 5170 goto cpy_name;
5171 tmp[sizeof(tmp) - 1] = '\0';
5172 goto got_name;
5173 }
5174 5171
5175 if (vma->vm_start <= vma->vm_mm->start_brk && 5172 if (vma->vm_start <= vma->vm_mm->start_brk &&
5176 vma->vm_end >= vma->vm_mm->brk) { 5173 vma->vm_end >= vma->vm_mm->brk) {
5177 name = strncpy(tmp, "[heap]", sizeof(tmp)); 5174 name = "[heap]";
5178 goto got_name; 5175 goto cpy_name;
5179 } 5176 }
5180 if (vma->vm_start <= vma->vm_mm->start_stack && 5177 if (vma->vm_start <= vma->vm_mm->start_stack &&
5181 vma->vm_end >= vma->vm_mm->start_stack) { 5178 vma->vm_end >= vma->vm_mm->start_stack) {
5182 name = strncpy(tmp, "[stack]", sizeof(tmp)); 5179 name = "[stack]";
5183 goto got_name; 5180 goto cpy_name;
5184 } 5181 }
5185 5182
5186 name = strncpy(tmp, "//anon", sizeof(tmp)); 5183 name = "//anon";
5187 goto got_name; 5184 goto cpy_name;
5188 } 5185 }
5189 5186
5187cpy_name:
5188 strlcpy(tmp, name, sizeof(tmp));
5189 name = tmp;
5190got_name: 5190got_name:
5191 /* 5191 /*
5192 * Since our buffer works in 8 byte units we need to align our string 5192 * Since our buffer works in 8 byte units we need to align our string