[lkml]   [2019]   [Feb]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 4.19 223/313] perf python: Do not force closing original perf descriptor in evlist.get_pollfd()
4.19-stable review patch.  If anyone has any objections, please let me know.


[ Upstream commit a389aece97938966616ce0336466b98b0351ef10 ]

Ondřej reported that when compiled with python3, the python extension
regresses in evlist.get_pollfd function behaviour.

The evlist.get_pollfd function creates file objects from evlist's fds
and returns them in a list. The python3 version also sets them to 'close
the original descriptor' when the object dies (is closed), by passing
True via the 'closefd' arg in the PyFile_FromFd call.

The python's closefd doc says:

If closefd is False, the underlying file descriptor will be kept open
when the file is closed.

That's why the following line in python3 closes all evlist fds:


the returned list is immediately destroyed and that takes down the
original events fds.

Passing closefd as False to PyFile_FromFd to fix this.

Reported-by: Ondřej Lysoněk <>
Signed-off-by: Jiri Olsa <>
Cc: Alexander Shishkin <>
Cc: Jaroslav Škarvada <>
Cc: Namhyung Kim <>
Cc: Peter Zijlstra <>
Fixes: 66dfdff03d19 ("perf tools: Add Python 3 support")
Signed-off-by: Arnaldo Carvalho de Melo <>
Signed-off-by: Sasha Levin <>
tools/perf/util/python.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index ce501ba14b08..69f5f6142dcf 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -939,7 +939,8 @@ static PyObject *pyrf_evlist__get_pollfd(struct pyrf_evlist *pevlist,

file = PyFile_FromFile(fp, "perf", "r", NULL);
- file = PyFile_FromFd(evlist->pollfd.entries[i].fd, "perf", "r", -1, NULL, NULL, NULL, 1);
+ file = PyFile_FromFd(evlist->pollfd.entries[i].fd, "perf", "r", -1,
if (file == NULL)
goto free_list;

 \ /
  Last update: 2019-02-11 15:51    [W:0.724 / U:23.396 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site