From: Hugo Lefeuvre <hle@owl.eu.com>
To: Joel Fernandes <joel@joelfernandes.org>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Greg Hartman" <ghartman@google.com>,
"Alistair Strachan" <strachan@google.com>,
"Arve Hjønnevåg" <arve@android.com>,
"Todd Kjos" <tkjos@android.com>,
"Martijn Coenen" <maco@android.com>,
"Christian Brauner" <christian@brauner.io>,
"Ingo Molnar" <mingo@redhat.com>,
"Peter Zijlstra" <peterz@infradead.org>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/wait: introduce wait_event_freezable_hrtimeout
Date: Fri, 18 Jan 2019 18:08:01 +0100 [thread overview]
Message-ID: <20190118170801.GA4537@hle-laptop.local> (raw)
In-Reply-To: <20190118151941.GB187589@google.com>
[-- Attachment #1: Type: text/plain, Size: 2893 bytes --]
Hi Joel,
Thanks for your review.
> I believe these should be 2 patches. In the first patch you introduce the
> new API, in the second one you would simplify the VSOC driver.
>
> In fact, in one part of the patch you are using wait_event_freezable which
> already exists so that's unrelated to the new API you are adding.
Agree, I will split the patch for the v2.
> > +/*
> > + * like wait_event_hrtimeout() -- except it uses TASK_INTERRUPTIBLE to avoid
> > + * increasing load and is freezable.
> > + */
> > +#define wait_event_freezable_hrtimeout(wq_head, condition, timeout) \
>
> You should document the variable names in the header comments.
Agree. This comment was copy/pasted from wait_event_freezable_timeout,
should I fix it there as well?
> Also, this new API appears to conflict with definition of 'freezable' in
> wait_event_freezable I think,
>
> wait_event_freezable - sleep or freeze until condition is true.
>
> wait_event_freezable_hrtimeout - sleep but make sure freezer is not blocked.
> (your API)
>
> It seems to me these are 2 different definitions of 'freezing' (or I could be
> completely confused). But in the first case it calls try_to_freeze after
> schedule(). In the second case (your new API), it calls freezable_schedule().
>
> So I am wondering why is there this difference in the 'meaning of freezable'.
> In the very least, any such subtle differences should be documented in the
> header comments IMO.
It appears that freezable_schedule() and schedule(); try_to_freeze() are
almost identical:
static inline void freezable_schedule(void)
{
freezer_do_not_count();
schedule();
freezer_count();
}
and
static inline void freezer_do_not_count(void)
{
current->flags |= PF_FREEZER_SKIP;
}
static inline void freezer_count(void)
{
current->flags &= ~PF_FREEZER_SKIP;
/*
* If freezing is in progress, the following paired with smp_mb()
* in freezer_should_skip() ensures that either we see %true
* freezing() or freezer_should_skip() sees !PF_FREEZER_SKIP.
*/
smp_mb();
try_to_freeze();
}
as far as I understand this code, freezable_schedule() avoids blocking the
freezer during the schedule() call, but in the end try_to_freeze() is still
called so the result is the same, right?
I wonder why wait_event_freezable is not calling freezable_schedule().
That being said, I am not sure that the try_to_freeze() call does anything
in the vsoc case because there is no call to set_freezable() so the thread
still has PF_NOFREEZE...
regards,
Hugo
--
Hugo Lefeuvre (hle) | www.owl.eu.com
RSA4096_ 360B 03B3 BF27 4F4D 7A3F D5E8 14AA 1EB8 A247 3DFD
ed25519_ 37B2 6D38 0B25 B8A2 6B9F 3A65 A36F 5357 5F2D DC4C
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-01-18 17:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-17 22:41 [PATCH] sched/wait: introduce wait_event_freezable_hrtimeout Hugo Lefeuvre
2019-01-18 7:17 ` Greg Kroah-Hartman
2019-01-18 7:48 ` Hugo Lefeuvre
2019-01-18 15:19 ` Joel Fernandes
2019-01-18 16:04 ` Peter Zijlstra
2019-01-21 12:01 ` Rafael J. Wysocki
2019-01-18 17:08 ` Hugo Lefeuvre [this message]
2019-01-19 1:53 ` Joel Fernandes
2019-01-19 10:29 ` Hugo Lefeuvre
2019-01-22 22:20 ` Joel Fernandes
2019-02-01 5:43 ` Hugo Lefeuvre
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=20190118170801.GA4537@hle-laptop.local \
--to=hle@owl.eu.com \
--cc=arve@android.com \
--cc=christian@brauner.io \
--cc=devel@driverdev.osuosl.org \
--cc=ghartman@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maco@android.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=strachan@google.com \
--cc=tkjos@android.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;
as well as URLs for NNTP newsgroup(s).