Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2752011imj; Mon, 11 Feb 2019 07:58:51 -0800 (PST) X-Google-Smtp-Source: AHgI3IYDs/AWejs7OuQzOxxxKQL1eZQy2gi+UcjtyK3MQTunQ/NvsJA5kXpqO6pymKAWlsSaKvg0 X-Received: by 2002:a17:902:925:: with SMTP id 34mr36982758plm.14.1549900731178; Mon, 11 Feb 2019 07:58:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549900731; cv=none; d=google.com; s=arc-20160816; b=F6awiqBH7/y2rJMoQwJwc9vmFIpRzGWUZ3xP6Pod4+Z+E/aadTLbJ2PNdyNR19M8f0 CXWsOwHEqtm7dk5TQE7vpl/TnPX0UYJyUnyq2HSNIMoY9v2GAOTdYXGndb3z4f/SM7VA VS3evml6ugT57bnCcIuMGTS1izLZs+eETCKDbPb6UQP8wC69lNiO0jPD+eYbLxci3kIs mNPBWVwcbzVr+roF9/hK9UW04ixylzaQFG2UBCH5BztEqGUkQGCTzh5W2/9mv2KFH+vM g8dOwUnYzIQFo155DX2a51UzxZMlnqXPpjN/W3Ts4JFsWg83OLpCdkdOE0exiHk1+6MH CfAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aTpw7Zvt1NkxVmuCjd5Klrg8/q176NajkCMjTCLCrlw=; b=sEjc3WqkObsfVfTntv9i020LJqKI88SplOpS2pu+lq5PXwhZw3khTnjS8lVROC7urX Qj2D6IkZ+P6j457t1XwIBqboGc8w6jf1Sgaew9L6WPXUU9GcU152+mchWAD3TPznryPq 5oFMIwulCz7n1gtItkM+B7LbNjhSgFN8t25kjD11Z6U+Fhby4ZZiFBWOf3lA2zM0yYdT ZVNNJhREq8HEScxNzRZE/XgqC6vdG+dhYe64UqcSMyIIgZveh3HInXRd3EngYdJ99o7j jNZ45MDKh0E3b5KKsocsD4Am5RiRyb2wlfm2LwqQLZs0Fl2/qYoYV7xRQ2BAISisle5i 4FNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KP3ilF1X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n19si1402405pgh.564.2019.02.11.07.58.34; Mon, 11 Feb 2019 07:58:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KP3ilF1X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730656AbfBKOdf (ORCPT + 99 others); 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