From: Stanislaw Gruszka <sgruszka@redhat.com>
To: Dong Zhu <bluezhudong@gmail.com>
Cc: John Stultz <john.stultz@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Oleg Nesterov <oleg@redhat.com>, Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] posix_cpu_timers: fix timer never expires when executes clock_nanosleep
Date: Thu, 1 Aug 2013 13:30:50 +0200 [thread overview]
Message-ID: <20130801113049.GB7334@redhat.com> (raw)
In-Reply-To: <20130801101018.GJ6721@zhudong.nay.redhat.com>
Hi Dong Zhu
On Thu, Aug 01, 2013 at 06:10:19PM +0800, Dong Zhu wrote:
> diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
> index c7f31aa..cc03290 100644
> --- a/kernel/posix-cpu-timers.c
> +++ b/kernel/posix-cpu-timers.c
> @@ -1413,9 +1413,9 @@ static int posix_cpu_nsleep(const clockid_t which_clock, int flags,
> /*
> * Diagnose required errors first.
> */
> - if (CPUCLOCK_PERTHREAD(which_clock) &&
> - (CPUCLOCK_PID(which_clock) == 0 ||
> - CPUCLOCK_PID(which_clock) == current->pid))
> + if (CPUCLOCK_PID(which_clock) == current->pid ||
> + (CPUCLOCK_PERTHREAD(which_clock) &&
> + CPUCLOCK_PID(which_clock) == 0))
> return -EINVAL;
Nope, this is wrong. We have to allow own pid process clock, because it
can be used correctly on multi-threaded processes. Own tid thread clock
has no sense and we correctly return -EINVAL in such case.
We could possibly add check for own pid together with check if process
consist of one thread, but that is too complicated IMHO especially
taking into account that threads on the process can be destroyed and
created dynamically.
Stanislaw
next prev parent reply other threads:[~2013-08-01 11:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-01 10:10 [PATCH] posix_cpu_timers: fix timer never expires when executes clock_nanosleep Dong Zhu
2013-08-01 11:30 ` Stanislaw Gruszka [this message]
2013-08-01 13:11 ` Dong Zhu
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=20130801113049.GB7334@redhat.com \
--to=sgruszka@redhat.com \
--cc=bluezhudong@gmail.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@redhat.com \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).