linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf: python: Reference Py_None before returning it
@ 2018-03-21 23:57 Petr Machata
  2018-03-22  9:14 ` Jiri Olsa
  2018-03-25 22:25 ` [tip:perf/core] perf " tip-bot for Petr Machata
  0 siblings, 2 replies; 4+ messages in thread
From: Petr Machata @ 2018-03-21 23:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, Petr Machata

Python None objects are handled just like all the other objects with
respect to their reference counting. Before returning Py_None, its
reference count thus needs to be bumped.

Signed-off-by: Petr Machata <petrm@mellanox.com>
---
 tools/perf/util/python.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index b1e999b..762d429 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -967,8 +967,10 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
 			return PyErr_NoMemory();
 
 		evsel = perf_evlist__event2evsel(evlist, event);
-		if (!evsel)
+		if (!evsel) {
+			Py_INCREF(Py_None);
 			return Py_None;
+		}
 
 		pevent->evsel = evsel;
 
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf: python: Reference Py_None before returning it
  2018-03-21 23:57 [PATCH] perf: python: Reference Py_None before returning it Petr Machata
@ 2018-03-22  9:14 ` Jiri Olsa
  2018-03-22  9:35   ` Arnaldo Carvalho de Melo
  2018-03-25 22:25 ` [tip:perf/core] perf " tip-bot for Petr Machata
  1 sibling, 1 reply; 4+ messages in thread
From: Jiri Olsa @ 2018-03-22  9:14 UTC (permalink / raw)
  To: Petr Machata
  Cc: linux-kernel, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Alexander Shishkin, Namhyung Kim

On Thu, Mar 22, 2018 at 12:57:32AM +0100, Petr Machata wrote:
> Python None objects are handled just like all the other objects with
> respect to their reference counting. Before returning Py_None, its
> reference count thus needs to be bumped.
> 
> Signed-off-by: Petr Machata <petrm@mellanox.com>

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

> ---
>  tools/perf/util/python.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
> index b1e999b..762d429 100644
> --- a/tools/perf/util/python.c
> +++ b/tools/perf/util/python.c
> @@ -967,8 +967,10 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
>  			return PyErr_NoMemory();
>  
>  		evsel = perf_evlist__event2evsel(evlist, event);
> -		if (!evsel)
> +		if (!evsel) {
> +			Py_INCREF(Py_None);
>  			return Py_None;
> +		}
>  
>  		pevent->evsel = evsel;
>  
> -- 
> 2.4.3
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf: python: Reference Py_None before returning it
  2018-03-22  9:14 ` Jiri Olsa
@ 2018-03-22  9:35   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-03-22  9:35 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Petr Machata, linux-kernel, Peter Zijlstra, Ingo Molnar,
	Alexander Shishkin, Namhyung Kim

Em Thu, Mar 22, 2018 at 10:14:48AM +0100, Jiri Olsa escreveu:
> On Thu, Mar 22, 2018 at 12:57:32AM +0100, Petr Machata wrote:
> > Python None objects are handled just like all the other objects with
> > respect to their reference counting. Before returning Py_None, its
> > reference count thus needs to be bumped.
> > 
> > Signed-off-by: Petr Machata <petrm@mellanox.com>
> 
> Acked-by: Jiri Olsa <jolsa@kernel.org>

Thanks, applied.

- Arnaldo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:perf/core] perf python: Reference Py_None before returning it
  2018-03-21 23:57 [PATCH] perf: python: Reference Py_None before returning it Petr Machata
  2018-03-22  9:14 ` Jiri Olsa
@ 2018-03-25 22:25 ` tip-bot for Petr Machata
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Petr Machata @ 2018-03-25 22:25 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, tglx, mingo, alexander.shishkin, acme, namhyung, petrm,
	hpa, linux-kernel, jolsa

Commit-ID:  83428f2fad48e16fddff0cb445cb4fedf5afe4ab
Gitweb:     https://git.kernel.org/tip/83428f2fad48e16fddff0cb445cb4fedf5afe4ab
Author:     Petr Machata <petrm@mellanox.com>
AuthorDate: Thu, 22 Mar 2018 00:57:32 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 23 Mar 2018 16:45:20 -0300

perf python: Reference Py_None before returning it

Python None objects are handled just like all the other objects with
respect to their reference counting. Before returning Py_None, its
reference count thus needs to be bumped.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Petr Machata <petrm@mellanox.com>
Link: http://lkml.kernel.org/r/b1e565ecccf68064d8d54f37db5d028dda8fa522.1521675563.git.petrm@mellanox.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/python.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index b956868fd445..863b61478edd 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -1004,8 +1004,10 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
 			return PyErr_NoMemory();
 
 		evsel = perf_evlist__event2evsel(evlist, event);
-		if (!evsel)
+		if (!evsel) {
+			Py_INCREF(Py_None);
 			return Py_None;
+		}
 
 		pevent->evsel = evsel;
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-25 22:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-21 23:57 [PATCH] perf: python: Reference Py_None before returning it Petr Machata
2018-03-22  9:14 ` Jiri Olsa
2018-03-22  9:35   ` Arnaldo Carvalho de Melo
2018-03-25 22:25 ` [tip:perf/core] perf " tip-bot for Petr Machata

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).