From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9B7DC169C4 for ; Mon, 11 Feb 2019 14:33:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9ACF121B18 for ; Mon, 11 Feb 2019 14:33:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895616; bh=4TtHAAqS5U/iW1q2Oi1rkRgKpBFtUrAylmeFOX6JLlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=k0R5XmsIEk+AqGMkbINAIUQcPdXHFF61SZSfbQKGSH7jxlSYjyMq/myeoqcc3zE5M 36OAGCkFnNze38zQo75YTIuCxxEY2TiXxZR320SGkkeQIJL4n1MA/iWtTsbx01vmXD InrlmFvJlVfAxT4HcbvrnpTo8UpFY/LVrneb2ptU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730660AbfBKOdf (ORCPT ); Mon, 11 Feb 2019 09:33:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:41348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727431AbfBKOdd (ORCPT ); Mon, 11 Feb 2019 09:33:33 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C054D21855; Mon, 11 Feb 2019 14:33:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895613; bh=4TtHAAqS5U/iW1q2Oi1rkRgKpBFtUrAylmeFOX6JLlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KP3ilF1XnQGKdjsMOtWd5MZQbFz9JhlacWWItuq2ef6jGmVeuaXNK37NcN16DhDTY APk/yjNLuOrYDBf3zDhxwMaMDcZnUhqJJauEk94/o81qUhcHu79YHqnchlv8MeIIi7 o4/xTa/HTCSeGGUxCc6Cq8sKd1bK4gYm9r5f6CWo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= , Jiri Olsa , Alexander Shishkin , =?UTF-8?q?Jaroslav=20=C5=A0karvada?= , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.20 263/352] perf python: Do not force closing original perf descriptor in evlist.get_pollfd() Date: Mon, 11 Feb 2019 15:18:10 +0100 Message-Id: <20190211141903.785072247@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-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: evlist.get_pollfd() 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") Link: http://lkml.kernel.org/r/20181226112121.5285-1-jolsa@kernel.org 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 50150dfc0cdf..4dd8fd05a260 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); #else - 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, + NULL, NULL, NULL, 0); #endif if (file == NULL) goto free_list; -- 2.19.1