From: Jiri Slaby <jirislaby@gmail.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Pavel Machek <pavel@ucw.cz>,
linux-pm@lists.linux-foundation.org,
linux-kernel@vger.kernel.org,
Nigel Cunningham <ncunningham@crca.org.au>
Subject: Re: [RFC 09/15] PM / Hibernate: user, implement user_ops writer
Date: Fri, 26 Mar 2010 10:34:59 +0100 [thread overview]
Message-ID: <4BAC7FC3.50405@gmail.com> (raw)
In-Reply-To: <201003252314.33256.rjw@sisk.pl>
On 03/25/2010 11:14 PM, Rafael J. Wysocki wrote:
> On Wednesday 24 March 2010, Jiri Slaby wrote:
>> On 03/24/2010 09:42 PM, Pavel Machek wrote:
>>>> + if (test_bit(TODO_CLOSED, to_do_flags))
>>>> + return -EIO;
>>>> +
>>>> + to_do_buf = buf;
>>>> + wmb();
>>>> + set_bit(TODO_WORK, to_do_flags);
>>>> + wake_up_interruptible(&to_do_wait);
>>>
>>> Uhuh, open-coded barriers... these need to be commented, and I guess
>>> you just should not play this kind of trickery.
>>
>> It's just to ensure the to_do_buf store is not reordered with the
>> set_bit. I wanted to avoid locks as too heavy tools here.
>
> No, please use them, at least in a prototype version.
>
> We can always optimize things out later, but doing optimizations upfront
> doesn't really work well from my experience.
>
> So, if you'd use a lock somewhere, please use it, or maybe use a completion if
> that fits the design better.
That's it, I don't think a lock is appropriate here (I didn't even think
of that) -- I don't know what to lock (OK, I see it, but it's not that
clear). There is no potential for race per se, I only need to disable
reordering (which locks do as a side-effect). I need the steps to be
done in the A-B order where there is a barrier appropriate. Here, A is
store to to_do_buf, B is set_bit. It's I set to_do_buf, flag that it may
be used, the consumer will see the flag and use to_do_buf, in this order.
Above that if I introduce locks the wait_event on the other side will
grow into an unreadable mess. I would need to hold a lock when checking
the condition and hold it until I reach to_do_buf use, but also unlock
it on all paths that do not reach that point. Yeah, it's indeed doable,
but I don't think, it will improve things.
I also don't think completion is appropriate here, as I have a condition
to check for and it differs over wake_up sites.
thanks,
--
js
next prev parent reply other threads:[~2010-03-26 9:35 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-23 16:17 [RFC 01/15] FS: libfs, implement simple_write_to_buffer Jiri Slaby
2010-03-23 16:17 ` [RFC 02/15] PM / Hibernate: snapshot cleanup Jiri Slaby
2010-03-24 20:29 ` Pavel Machek
2010-03-24 22:35 ` Rafael J. Wysocki
2010-03-25 5:29 ` Pavel Machek
2010-03-23 16:17 ` [RFC 03/15] PM / Hibernate: separate block_io Jiri Slaby
2010-03-24 20:30 ` Pavel Machek
2010-03-24 21:22 ` Jiri Slaby
2010-03-24 22:58 ` Nigel Cunningham
2010-03-25 2:35 ` [linux-pm] " Nigel Cunningham
2010-03-25 20:12 ` Rafael J. Wysocki
2010-03-25 20:13 ` Nigel Cunningham
2010-03-25 20:33 ` Rafael J. Wysocki
2010-03-25 20:36 ` Nigel Cunningham
2010-03-29 13:30 ` Pavel Machek
2010-03-25 14:29 ` Pavel Machek
2010-03-23 16:17 ` [RFC 04/15] PM / Hibernate: move the first_sector out of swsusp_write Jiri Slaby
2010-03-24 20:31 ` Pavel Machek
2010-03-25 21:26 ` Rafael J. Wysocki
2010-03-23 16:17 ` [RFC 05/15] PM / Hibernate: group swap ops Jiri Slaby
2010-03-25 21:28 ` Rafael J. Wysocki
2010-03-23 16:17 ` [RFC 06/15] PM / Hibernate: swap, remove swap_map_handle usages Jiri Slaby
2010-03-24 20:33 ` Pavel Machek
2010-03-24 21:29 ` Jiri Slaby
2010-03-25 21:35 ` Rafael J. Wysocki
2010-03-23 16:17 ` [RFC 07/15] PM / Hibernate: add sws_modules_ops Jiri Slaby
2010-03-24 20:36 ` Pavel Machek
2010-03-24 21:31 ` Jiri Slaby
2010-03-25 22:02 ` Rafael J. Wysocki
2010-03-23 16:17 ` [RFC 08/15] PM / Hibernate: add user module_ops Jiri Slaby
2010-03-25 22:07 ` Rafael J. Wysocki
2010-03-26 9:43 ` Jiri Slaby
2010-03-23 16:17 ` [RFC 09/15] PM / Hibernate: user, implement user_ops writer Jiri Slaby
2010-03-24 20:42 ` Pavel Machek
2010-03-24 21:40 ` Jiri Slaby
2010-03-25 21:36 ` Pavel Machek
2010-03-25 22:14 ` Rafael J. Wysocki
2010-03-26 9:34 ` Jiri Slaby [this message]
2010-03-26 22:04 ` Rafael J. Wysocki
2010-03-29 15:33 ` Jiri Slaby
2010-03-27 7:02 ` Pavel Machek
2010-03-23 16:17 ` [RFC 10/15] PM / Hibernate: user, implement user_ops reader Jiri Slaby
2010-03-25 5:30 ` what the patches do " Pavel Machek
2010-03-25 5:42 ` Nigel Cunningham
2010-03-25 6:12 ` [linux-pm] " Nigel Cunningham
2010-03-25 20:14 ` Rafael J. Wysocki
2010-03-25 20:21 ` Nigel Cunningham
2010-03-25 20:29 ` Rafael J. Wysocki
2010-03-25 20:35 ` Nigel Cunningham
2010-03-25 21:13 ` Rafael J. Wysocki
2010-03-25 21:26 ` Pavel Machek
2010-03-25 21:49 ` [linux-pm] " Nigel Cunningham
2010-04-02 6:36 ` Pavel Machek
2010-04-02 17:03 ` Rafael J. Wysocki
2010-03-25 22:21 ` Rafael J. Wysocki
2010-03-23 16:17 ` [RFC 11/15] PM / Hibernate: add chunk i/o support Jiri Slaby
2010-03-25 22:38 ` Rafael J. Wysocki
2010-03-26 9:09 ` Jiri Slaby
2010-03-26 10:02 ` Nigel Cunningham
2010-03-23 16:17 ` [RFC 12/15] PM / Hibernate: split snapshot_read_next Jiri Slaby
2010-03-25 22:44 ` Rafael J. Wysocki
2010-03-23 16:17 ` [RFC 13/15] PM / Hibernate: split snapshot_write_next Jiri Slaby
2010-03-25 22:46 ` Rafael J. Wysocki
2010-03-23 16:17 ` [RFC 14/15] PM / Hibernate: dealign swsusp_info Jiri Slaby
2010-03-25 22:46 ` Rafael J. Wysocki
2010-03-23 16:17 ` [RFC 15/15] PM / Hibernate: move non-swap code to snapshot.c Jiri Slaby
2010-03-25 22:50 ` Rafael J. Wysocki
2010-03-23 21:51 ` [RFC 01/15] FS: libfs, implement simple_write_to_buffer Rafael J. Wysocki
2010-03-23 22:09 ` [linux-pm] " Nigel Cunningham
2010-03-24 22:13 ` Rafael J. Wysocki
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=4BAC7FC3.50405@gmail.com \
--to=jirislaby@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=ncunningham@crca.org.au \
--cc=pavel@ucw.cz \
--cc=rjw@sisk.pl \
/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