* + gcov-simplify-buffer-allocation.patch added to -mm tree
@ 2021-03-15 23:03 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2021-03-15 23:03 UTC (permalink / raw)
To: johannes.berg, mm-commits, oberpar
The patch titled
Subject: gcov: simplify buffer allocation
has been added to the -mm tree. Its filename is
gcov-simplify-buffer-allocation.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/gcov-simplify-buffer-allocation.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/gcov-simplify-buffer-allocation.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Johannes Berg <johannes.berg@intel.com>
Subject: gcov: simplify buffer allocation
Use just a single vmalloc() with struct_size() instead of a separate
kmalloc() for the iter struct.
Link: https://lkml.kernel.org/r/20210315235453.b6de4a92096e.Iac40a5166589cefbff8449e466bd1b38ea7a17af@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
kernel/gcov/fs.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
--- a/kernel/gcov/fs.c~gcov-simplify-buffer-allocation
+++ a/kernel/gcov/fs.c
@@ -97,9 +97,9 @@ __setup("gcov_persist=", gcov_persist_se
*/
struct gcov_iterator {
struct gcov_info *info;
- void *buffer;
size_t size;
loff_t pos;
+ char buffer[];
};
/**
@@ -111,25 +111,20 @@ struct gcov_iterator {
static struct gcov_iterator *gcov_iter_new(struct gcov_info *info)
{
struct gcov_iterator *iter;
+ size_t size;
+
+ /* Dry-run to get the actual buffer size. */
+ size = convert_to_gcda(NULL, info);
- iter = kzalloc(sizeof(struct gcov_iterator), GFP_KERNEL);
+ iter = vmalloc(struct_size(iter, buffer, size));
if (!iter)
- goto err_free;
+ return NULL;
iter->info = info;
- /* Dry-run to get the actual buffer size. */
- iter->size = convert_to_gcda(NULL, info);
- iter->buffer = vmalloc(iter->size);
- if (!iter->buffer)
- goto err_free;
-
+ iter->size = size;
convert_to_gcda(iter->buffer, info);
return iter;
-
-err_free:
- kfree(iter);
- return NULL;
}
@@ -139,8 +134,7 @@ err_free:
*/
static void gcov_iter_free(struct gcov_iterator *iter)
{
- vfree(iter->buffer);
- kfree(iter);
+ vfree(iter);
}
/**
_
Patches currently in -mm which might be from johannes.berg@intel.com are
gcov-combine-common-code.patch
gcov-simplify-buffer-allocation.patch
gcov-use-kvmalloc.patch
gdb-lx-symbols-store-the-abspath.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-03-15 23:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15 23:03 + gcov-simplify-buffer-allocation.patch added to -mm tree akpm
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.