[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180913125450.21342-32-jolsa@kernel.org>
Date: Thu, 13 Sep 2018 14:54:33 +0200
From: Jiri Olsa <jolsa@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: lkml <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Andi Kleen <andi@...stfloor.org>,
Alexey Budankov <alexey.budankov@...ux.intel.com>
Subject: [PATCH 31/48] tools lib fd array: Introduce fdarray__add_clone function
Adding fdarray__add_clone to be able to copy/clone
a specific entry from fdarray struct.
It will be useful when separating event maps for
specific threads.
Link: http://lkml.kernel.org/n/tip-0r9rtn1bii1iaggumlgkyxqk@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
tools/lib/api/fd/array.c | 17 +++++++++++++++++
tools/lib/api/fd/array.h | 1 +
2 files changed, 18 insertions(+)
diff --git a/tools/lib/api/fd/array.c b/tools/lib/api/fd/array.c
index b0a035fc87b3..cd458b46f61b 100644
--- a/tools/lib/api/fd/array.c
+++ b/tools/lib/api/fd/array.c
@@ -84,6 +84,23 @@ int fdarray__add(struct fdarray *fda, int fd, short revents)
return pos;
}
+int fdarray__add_clone(struct fdarray *fda, int pos, struct fdarray *base)
+{
+ struct pollfd *entry;
+ int npos;
+
+ if (pos >= base->nr)
+ return -EINVAL;
+
+ entry = &base->entries[pos];
+
+ npos = fdarray__add(fda, entry->fd, entry->events);
+ if (npos >= 0)
+ fda->priv[npos] = base->priv[pos];
+
+ return npos;
+}
+
int fdarray__filter(struct fdarray *fda, short revents,
void (*entry_destructor)(struct fdarray *fda, int fd, void *arg),
void *arg)
diff --git a/tools/lib/api/fd/array.h b/tools/lib/api/fd/array.h
index b39557d1a88f..06e89d099b1e 100644
--- a/tools/lib/api/fd/array.h
+++ b/tools/lib/api/fd/array.h
@@ -34,6 +34,7 @@ struct fdarray *fdarray__new(int nr_alloc, int nr_autogrow);
void fdarray__delete(struct fdarray *fda);
int fdarray__add(struct fdarray *fda, int fd, short revents);
+int fdarray__add_clone(struct fdarray *fda, int pos, struct fdarray *base);
int fdarray__poll(struct fdarray *fda, int timeout);
int fdarray__filter(struct fdarray *fda, short revents,
void (*entry_destructor)(struct fdarray *fda, int fd, void *arg),
--
2.17.1
Powered by blists - more mailing lists