public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Jiri Slaby <jirislaby@gmail.com>
Cc: Paul Gortmaker <p_gortmaker@yahoo.com>,
	LKML <linux-kernel@vger.kernel.org>, Andi Kleen <ak@suse.de>,
	Alexey Dobriyan <adobriyan@gmail.com>
Subject: Re: [PATCH] driver: ip27-rtc - convert ioctl to unlocked_ioctl
Date: Mon, 14 Jan 2008 19:07:45 +0300	[thread overview]
Message-ID: <20080114160745.GB6639@cvg> (raw)
In-Reply-To: <478B86DA.1010902@gmail.com>

[Jiri Slaby - Mon, Jan 14, 2008 at 04:59:22PM +0100]
> On 01/14/2008 04:38 PM, Cyrill Gorcunov wrote:
>> Jiri, I mean rtc_open() is protected by spinlock+status from being
>> opened simultaneously by a few processes. *But* lets imagine the
>> following situation - this fd (file descriptor) is opened by one
>> multithreaded application so all threads have an access to this
>> fd. Then one thread reads rtc periodically thru unlocked_ioctl
>> and another thread set new time from time to time. So the question
>> I have - is it possible to get second thread stopped at attemption to
>> get rtc spinlock while another thread is setting the new time? Or
>> this situation never-ever could be? i'm not really familiar with
>> process management in Linux and as result could be wrong.
>
> Access to global variable 'rtc' (the rtc itself) is serialized through the 
> spinlock, I see no problem there. If you call read-read-write-read from 4 
> tasks in userspace, it might be _still_ (no change) reordered to e.g. 
> write-read-read-read by the scheduler.
>
> In fact, the reading process is stopped while the another one is writing 
> the time (due to spinlock).
>

Yes, process would be stopped, and not *just* stopped but could spend
all his cpu time-slice in attempt to get spinlock (espec if set time is
much longer than read), but if we use mutex here the process could just
sleep instead of trying to get spinlock granted. Am I wrong? Or this is
not worth to do it?

		- Cyrill -

  reply	other threads:[~2008-01-14 16:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-13 20:32 [PATCH] driver: ip27-rtc - convert ioctl to unlocked_ioctl Cyrill Gorcunov
2008-01-13 21:07 ` Alexey Dobriyan
2008-01-13 21:25   ` Cyrill Gorcunov
2008-01-13 21:22 ` Jiri Slaby
2008-01-13 21:29   ` Jiri Slaby
2008-01-13 21:32     ` Cyrill Gorcunov
2008-01-14  6:38       ` Cyrill Gorcunov
2008-01-14 15:14         ` Jiri Slaby
2008-01-14 15:38           ` Cyrill Gorcunov
2008-01-14 15:59             ` Jiri Slaby
2008-01-14 16:07               ` Cyrill Gorcunov [this message]
2008-01-14 16:27                 ` Jiri Slaby
2008-01-14 16:28                   ` Cyrill Gorcunov
2008-01-13 23:08 ` Andi Kleen

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=20080114160745.GB6639@cvg \
    --to=gorcunov@gmail.com \
    --cc=adobriyan@gmail.com \
    --cc=ak@suse.de \
    --cc=jirislaby@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p_gortmaker@yahoo.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