Hi
Here are patches for 2 minor improvements for perf inject:
1. Keep some features sections from input file
2. Keep a copy of kcore_dir
Adrian Hunter (5):
perf header: Add ability to keep feature sections
libperf: Add preadn()
perf inject: Keep some features sections from input file
perf data: Add has_kcore_dir()
perf inject: Keep a copy of kcore_dir
tools/lib/perf/include/internal/lib.h | 2 +
tools/lib/perf/lib.c | 20 +++++
tools/perf/builtin-inject.c | 162 +++++++++++++++++++++++++++++++++-
tools/perf/util/data.c | 14 +++
tools/perf/util/data.h | 1 +
tools/perf/util/header.c | 62 +++++++++++--
tools/perf/util/header.h | 15 ++++
7 files changed, 264 insertions(+), 12 deletions(-)
Regards
Adrian
Add a helper function has_kcore_dir(), so that perf inject can determine if
it needs to keep the kcore_dir.
Signed-off-by: Adrian Hunter <[email protected]>
---
tools/perf/util/data.c | 14 ++++++++++++++
tools/perf/util/data.h | 1 +
2 files changed, 15 insertions(+)
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index a5ace2bbc28d..caabeac24c69 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -479,6 +479,20 @@ int perf_data__make_kcore_dir(struct perf_data *data, char *buf, size_t buf_sz)
return mkdir(buf, S_IRWXU);
}
+bool has_kcore_dir(const char *path)
+{
+ char *kcore_dir;
+ int ret;
+
+ if (asprintf(&kcore_dir, "%s/kcore_dir", path) < 0)
+ return false;
+
+ ret = access(kcore_dir, F_OK);
+
+ free(kcore_dir);
+ return !ret;
+}
+
char *perf_data__kallsyms_name(struct perf_data *data)
{
char *kallsyms_name;
diff --git a/tools/perf/util/data.h b/tools/perf/util/data.h
index 1402d9657ef2..7de53d6e2d7f 100644
--- a/tools/perf/util/data.h
+++ b/tools/perf/util/data.h
@@ -99,6 +99,7 @@ void perf_data__close_dir(struct perf_data *data);
int perf_data__update_dir(struct perf_data *data);
unsigned long perf_data__size(struct perf_data *data);
int perf_data__make_kcore_dir(struct perf_data *data, char *buf, size_t buf_sz);
+bool has_kcore_dir(const char *path);
char *perf_data__kallsyms_name(struct perf_data *data);
bool is_perf_data(const char *path);
#endif /* __PERF_DATA_H */
--
2.25.1
On Fri, May 20, 2022 at 04:23:59PM +0300, Adrian Hunter wrote:
> Hi
>
> Here are patches for 2 minor improvements for perf inject:
> 1. Keep some features sections from input file
> 2. Keep a copy of kcore_dir
>
>
> Adrian Hunter (5):
> perf header: Add ability to keep feature sections
> libperf: Add preadn()
> perf inject: Keep some features sections from input file
> perf data: Add has_kcore_dir()
> perf inject: Keep a copy of kcore_dir
LGTM
Acked-by: Jiri Olsa <[email protected]>
thanks,
jirka
>
> tools/lib/perf/include/internal/lib.h | 2 +
> tools/lib/perf/lib.c | 20 +++++
> tools/perf/builtin-inject.c | 162 +++++++++++++++++++++++++++++++++-
> tools/perf/util/data.c | 14 +++
> tools/perf/util/data.h | 1 +
> tools/perf/util/header.c | 62 +++++++++++--
> tools/perf/util/header.h | 15 ++++
> 7 files changed, 264 insertions(+), 12 deletions(-)
>
>
> Regards
> Adrian
Em Mon, May 23, 2022 at 10:16:56AM +0200, Jiri Olsa escreveu:
> On Fri, May 20, 2022 at 04:23:59PM +0300, Adrian Hunter wrote:
> > Hi
> >
> > Here are patches for 2 minor improvements for perf inject:
> > 1. Keep some features sections from input file
> > 2. Keep a copy of kcore_dir
> >
> >
> > Adrian Hunter (5):
> > perf header: Add ability to keep feature sections
> > libperf: Add preadn()
> > perf inject: Keep some features sections from input file
> > perf data: Add has_kcore_dir()
> > perf inject: Keep a copy of kcore_dir
>
> LGTM
>
> Acked-by: Jiri Olsa <[email protected]>
Thanks, applied.
- Arnaldo
> thanks,
> jirka
>
> >
> > tools/lib/perf/include/internal/lib.h | 2 +
> > tools/lib/perf/lib.c | 20 +++++
> > tools/perf/builtin-inject.c | 162 +++++++++++++++++++++++++++++++++-
> > tools/perf/util/data.c | 14 +++
> > tools/perf/util/data.h | 1 +
> > tools/perf/util/header.c | 62 +++++++++++--
> > tools/perf/util/header.h | 15 ++++
> > 7 files changed, 264 insertions(+), 12 deletions(-)
> >
> >
> > Regards
> > Adrian
--
- Arnaldo