Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3797521imu; Fri, 18 Jan 2019 18:07:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN5mWy7Q+rl4Ij52US709SvoJ5+upYFkdUpougHyZ1J6arQ7XPHvHpPW1s7ApsEU+4+i2DkZ X-Received: by 2002:a17:902:7e4f:: with SMTP id a15mr20962997pln.149.1547863674027; Fri, 18 Jan 2019 18:07:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547863673; cv=none; d=google.com; s=arc-20160816; b=WNJi1hwtD9eI774+u/b5UiqtMG2YLRtZ+c/klH7sX06gmC+7ES7csE/YPWjZ9fJ3I7 QxWl3RixL0USiM0SoF7LjpDZVSau8i9hJmTyd5OMDH4Xm49EIYUAGq0e7ErkCAZi7q5f JCq/OvJPShU5tZb/2BETaXkv+PzdFMdbBDkChWktp/JK8avmfRdP5WAIUIvvxPyntE1G NLwL5Yucw+FosJCOyu8Rv1hFik04LHPFoK0RfGIrB3e4KDFuXXuCcD+IoG3djdzubAfn 4s60ar/p03FbHww6SgO5znlbhvfbjUrl3jxmira6yaMlYSLCMpF+W1oS4iZBAkXP6KGB wXoA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:references:cc:to:from:subject; bh=ScvaGbGa/8O2birrXOjP/gL/kHa7w0FDpMlZI0d11Ik=; b=STuwamFycd0ppI3SsxqPoKXS8Cna6lqeq4LfETIJmx/dNYmYCtCF/KkHvq1czqYlHa y/OGuHzGttz/z/ifzllRpqiuOcWPxOcY0gn9Y/UCbpM0NXVewg1kwpFY0ttfR+QYkYx1 cAMZly+99r9vZ6+lUb1QC9DY+JJxw+WT58gEGUlsx1J5qYGuwiVglmTN8eih87zsuJFA oJLDh0fLz1gUjpugWkPpmdg7C5Lf6qinW+JQ+pf4lYYXV7If1X53m+XXkAd+WiP3lSis bzoXKjbcaSkmA1Z4EQgseJZMCbf1OGv+U01gUUCka9o4DBbESf3QIPLRMW+WbveajRzH 5R+Q== ARC-Authentication-Results: i=1; mx.google.com; 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 f34si6137551pgm.318.2019.01.18.18.07.32; Fri, 18 Jan 2019 18:07:53 -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; 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 S1729624AbfASCFw (ORCPT + 99 others); Fri, 18 Jan 2019 21:05:52 -0500 Received: from mx2.suse.de ([195.135.220.15]:41788 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728494AbfASCFv (ORCPT ); Fri, 18 Jan 2019 21:05:51 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id AE6F7ACBC; Sat, 19 Jan 2019 02:05:49 +0000 (UTC) Subject: Re: [PATCH v2] perf scripts python: Add Python 3 support to check-perf-trace.py From: Tony Jones To: Jiri Olsa , Seeteena Thoufeek Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, Ravi Bangoria References: <1547718344-27382-1-git-send-email-s1seetee@linux.vnet.ibm.com> <20190117123202.GC16366@krava> <0d8a6ddc-9755-2b50-4023-26f6c84a33d1@suse.de> Openpgp: preference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fwEw5lNmQGdoV9csg7JP7saDicSFO2KcZvMbvDMqtPFipdF5UWo fZKZ3wADBQf/b5cVNyb5i8QI0G7BPGBNn4VlQX5n66TsPBnrRNOi3MhTTVEBCp8s+jqUjJjX EjjA+O4hIm7Qqdsozurw7GlcQ0A06dIzO/1RUglZZMoC0JL43ZQmJ+3+yFrLjWgGH6ev6AOb YLH7ZujgAB5n0Hy2ZIChzsKLKbHptFtBvpDKB8updq+GunsY4oN3wGa67h9sHqDvjyp64Czg n8G5uGLwx3f/edbECKz5kPUSzChEk3suK742SEP01v4ra5WX88Hn81NjGByQMz9acJLdC7Ff LzXvbNa0KgvDaSllYfsJIoGCz3eKVOuTWXOiaEIKuy833+3mr2PulLCyLKysAEddKohJBBgR AgAJBQJJEJm8AhsMAAoJELFYWyEf4koXhgQAn1EGATLZPS53At9t+p3S8BkNI9yRAJ9A0OmL liv+rwEesYGlGeGNaKHTJw== Message-ID: <7d5e8be1-b2dc-7654-744b-5ddbe2faf5b2@suse.de> Date: Fri, 18 Jan 2019 18:05:45 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <0d8a6ddc-9755-2b50-4023-26f6c84a33d1@suse.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/18/19 4:29 PM, Tony Jones wrote: > I'd been simultaneously working on a patch set to fix up Python3. > > It's actually already in our Factory and SLE15-SP1 releases as we had a deadline to kill Python2 usage for internal rpms. > > I was going to post once I'd fixed the last remaining issue ('import perf' is still failing [test #18]). > > I guess "you snooze you lose" :-) > > https://build.opensuse.org/package/view_file/devel:tools/perf/perf.changes?expand=1 Seeteena, I'm than happy to forward my patches via email. Alternatively, as I said in another post, the full series is in SLE15-SP1/beta2 (should apply to tip) which IBM has access to and they've been backported to v4.19 (Factory) at https://build.opensuse.org/package/show/openSUSE:Factory/perf. Everything has been tested against python2 and python3. Also, in this series there are patches to: - port tests/attr.py to Python3 - remove shebangs from the .py scripts and change to mode 644 as IMO it makes no sense to explicitly have #!/usr/bin/python since per pep-0394 this refers to version2 and the system may only have python3 installed - remove the shebang from setup.py since it's explicitly invoked via call to ${PYTHON_WORD} Also I found in testing that the following fix is also needed. I'm not 100% sure on it and was going to revisit before posting but _PyUnicode_FromStringAndSize() is definitely unsafe to use on attr. ---- Fixes: 66dfdff03d196e51322c6a85c0d8db8bb2bdd655 With Python3. PyUnicode_FromStringAndSize is unsafe to call on attr and will return NULL. Use _PyBytes_FromStringAndSize (as with raw_buf). $ perf script -s perf-script.py -i perf.data in trace_begin Segmentation fault (core dumped) --- tools/perf/util/scripting-engines/trace-event-python.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -733,8 +733,7 @@ static PyObject *get_perf_sample_dict(st Py_FatalError("couldn't create Python dictionary"); pydict_set_item_string_decref(dict, "ev_name", _PyUnicode_FromString(perf_evsel__name(evsel))); - pydict_set_item_string_decref(dict, "attr", _PyUnicode_FromStringAndSize( - (const char *)&evsel->attr, sizeof(evsel->attr))); + pydict_set_item_string_decref(dict, "attr", _PyBytes_FromStringAndSize((const char *)&evsel->attr, sizeof(evsel->attr))); pydict_set_item_string_decref(dict_sample, "pid", _PyLong_FromLong(sample->pid));