From: Oleg Nesterov <oleg@redhat.com>
To: "Sylvain 'ythier' Hitier" <sylvain.hitier@gmail.com>
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] fork.c: copy_process(): fix cleanup WRT perf_event_free_task()
Date: Sat, 27 Sep 2014 20:07:25 +0200 [thread overview]
Message-ID: <20140927180725.GA15594@redhat.com> (raw)
In-Reply-To: <20140926210652.GA27199@erable>
On 09/26, Sylvain 'ythier' Hitier wrote:
>
> retval = sched_fork(clone_flags, p);
> if (retval)
> // // mustn't perf_event_free_task()
> goto bad_fork_cleanup_policy;
Agreed, this is wrong. Good catch.
but, unless I missed something,
> retval = perf_event_init_task(p);
> if (retval)
> // // mustn't perf_event_free_task()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
this is not right and thus the patch is not right too.
Suppose that perf_event_init_task() -> perf_event_init_context(ctxn => 0)
succeeds and then perf_event_init_context(ctxn => 1) fails, we need
perf_event_free_task() to cleanup ->perf_event_ctxp[0].
So if perf_event_init_task() fails, we still need "goto bad_fork_cleanup_perf".
No?
Or, probably better, we need to change perf_event_init_context() to call
perf_event_free_task() on failure.
Or. We can simply move memset(child->perf_event_ctxp, 0, ...) from
perf_event_init_context() up. This reminds that we really need to cleanup
copy_process(), in particular I think it asks for the new copy_xxx() helper
which should do misc simple initializations which can't fail.
What do you think?
Oleg.
next prev parent reply other threads:[~2014-09-27 18:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-26 21:06 [PATCH] fork.c: copy_process(): fix cleanup WRT perf_event_free_task() Sylvain 'ythier' Hitier
2014-09-27 18:07 ` Oleg Nesterov [this message]
2014-09-29 10:12 ` Peter Zijlstra
2014-09-29 12:07 ` Ingo Molnar
2014-09-29 14:00 ` Peter Zijlstra
2014-10-01 22:44 ` Andrew Morton
2014-09-29 22:28 ` Oleg Nesterov
2014-10-03 5:27 ` [tip:perf/urgent] perf: Fix perf bug in fork() tip-bot for Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140927180725.GA15594@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=sylvain.hitier@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox