Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3636774imu; Mon, 28 Jan 2019 08:12:58 -0800 (PST) X-Google-Smtp-Source: ALg8bN51pQT+kyZdyy35srHerAT0+YMjfMu5cHkuf7ADvvfrm4HfP0CsSJ83SKYVh1efYt2sTfav X-Received: by 2002:a62:da5a:: with SMTP id w26mr22481337pfl.106.1548691977937; Mon, 28 Jan 2019 08:12:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691977; cv=none; d=google.com; s=arc-20160816; b=iRrtw2DcKuaQvpmfMPdTlHmGvLCdNgzf4SqlM5qcLBZzoRRJ93vfqsEAyeDB6u9Hso IQZdVbENzjnohKxIQxV2PkMjf2DVXvhCQWJuKJkC1RQK2s7mX02RYlFhLoXcCCQTFMyq NYn29+dCdy42gXMqc0ZPtKZDL4muhBhK/qoPU+5yrAYCueCgGLxZusfUuw/2/N2Tqdpc Y/lDqqCvEkkp/eIzdoTAGs3mh3zDNg4TvXbxunPmWLWsR6GcQTpNbOv+oebgDzge0sHV ZiqdfqtL5mHz/cPAvuIgD1aVk6iHzANxGFtg+7ACiAZy91rve2VAzQBcEqhEYzz6zx5D Revg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=m90Tu9EbdyfeVxaZZEfpCehCsUm9TMra+f/0Ag63bm0=; b=WTeNmZ9zwRYYb4UR4TKAcJlwkBLBnOdlQYCy/IpqPDMuhXOrhrktvcBat92sdKPozc RFUSR4pZdAHFl8Jc7VQFa+di16xq3yvnrg4XiWYI31WkT6zXmMby3bY8pGWNsO5HVfwC qNEZjruIAuHb/4B99Wf7cD+JmXlMOwZpMdgryPhKLPruHO/b65IbaQ6uggjV2L+z64cz UV0MJ1Wg/tUTT7OiwdoUExIEfQ//9OBOR4UG3AzJJfWEBlPNSuWqZTubTlk2++zpnEUP kM1xidgz0p+Kmo5710ezfohr+FYZEoIlba8GyFNqXGqChMxVn2lKprt+04KxNptxMalI Ex4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r2m4b8sx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d8si8068917pgh.505.2019.01.28.08.12.42; Mon, 28 Jan 2019 08:12:57 -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=r2m4b8sx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732827AbfA1QKe (ORCPT + 99 others); Mon, 28 Jan 2019 11:10:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:36612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732345AbfA1QKd (ORCPT ); Mon, 28 Jan 2019 11:10:33 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C48E92147A; Mon, 28 Jan 2019 16:10:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691833; bh=vi6LDZxk4e5mqzUo2RY6x9M5pG5g/PHTtpN2MvDMdlY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r2m4b8sxh1xBJjYo7kVNK+VZxLT8bn0dBLBrw9kueA2hzxvf6aDRbnD2dLOkRE4Zw Guoi07lH0MsivRifOjKjvCWkU6dk+JyuUNFRLwg5dA2mhWFy4xFZxAljdwgnxeqYCM hntNjP4VVZSUfo+x4klWfC/Sxoj8NbtBbmmNt204= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jiri Olsa , Alexander Shishkin , =?UTF-8?q?Jaroslav=20=C5=A0karvada?= , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH AUTOSEL 4.19 232/258] perf python: Do not force closing original perf descriptor in evlist.get_pollfd() Date: Mon, 28 Jan 2019 10:58:58 -0500 Message-Id: <20190128155924.51521-232-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa [ 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 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); #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