All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <syrjala@sci.fi>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	DRI <dri-devel@lists.sourceforge.net>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][RFC] time: add wait_interruptible_timeout macro to sleep (w. timeout) until wake_up
Date: Fri, 26 Feb 2010 21:01:00 +0200	[thread overview]
Message-ID: <20100226190100.GQ10145@sci.fi> (raw)
In-Reply-To: <b170af451002260933i6a7a5e1el619f8e71c3ae0bc8@mail.gmail.com>

On Fri, Feb 26, 2010 at 06:33:57PM +0100, Rafał Miłecki wrote:
> W dniu 26 lutego 2010 17:14 użytkownik Andrew Morton
> <akpm@linux-foundation.org> napisał:
> > On Fri, 26 Feb 2010 11:38:59 +0100 Rafa Miecki <zajec5@gmail.com> wrote:
> >
> >> +#define wait_interruptible_timeout(wq, timeout)
> >>     \
> >> +({                                   \
> >> +    long ret = timeout;                      \
> >> +                                    \
> >> +    DEFINE_WAIT(wait);                      \
> >> +    prepare_to_wait(&wq, &wait, TASK_INTERRUPTIBLE);       \
> >> +    if (!signal_pending(current))                  \
> >> +        ret = schedule_timeout(ret);            \
> >> +    finish_wait(&wq, &wait);                   \
> >> +                                    \
> >> +    ret;                             \
> >> +})
> >
> > It's often a mistake to use signals in-kernel.  Signals are more a
> > userspace thing and it's better to use the lower-level kernel-specific
> > messaging tools in-kernel.  Bear in mind that userspace can
> > independently and asynchronously send, accept and block signals.
> 
> Can you point me to something kernel-level please?
> 
> 
> > Can KMS use wait_event_interruptible_timeout()?
> 
> No. Please check definition of this:
> 
> #define wait_event_interruptible_timeout(wq, condition, timeout)	\
> ({									\
> 	long __ret = timeout;						\
> 	if (!(condition))						\
> 		__wait_event_interruptible_timeout(wq, condition, __ret); \
> 	__ret;								\
> })
> 
> It uses condition there, but that's not a big issue. We just need to
> pass 0 (false) there and it will work so far.

Disabling the condition check doesn't make sense.

You could use a completion.

init_completion(vbl_irq);
enable_vbl_irq();
wait_for_completion(vbl_irq);
disable_vbl_irq();
and call complete(vbl_irq) in the interrupt handler.

The same would of course work with just some flag or counter
and a wait queue. Isn't there already a vbl counter that you could
compare in the condition?

-- 
Ville Syrjälä
syrjala@sci.fi
http://www.sci.fi/~syrjala/

WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <syrjala@sci.fi>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	DRI <dri-devel@lists.sourceforge.net>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH][RFC] time: add wait_interruptible_timeout macro to sleep (w. timeout) until wake_up
Date: Fri, 26 Feb 2010 21:01:00 +0200	[thread overview]
Message-ID: <20100226190100.GQ10145@sci.fi> (raw)
In-Reply-To: <b170af451002260933i6a7a5e1el619f8e71c3ae0bc8@mail.gmail.com>

On Fri, Feb 26, 2010 at 06:33:57PM +0100, Rafał Miłecki wrote:
> W dniu 26 lutego 2010 17:14 użytkownik Andrew Morton
> <akpm@linux-foundation.org> napisał:
> > On Fri, 26 Feb 2010 11:38:59 +0100 Rafa Miecki <zajec5@gmail.com> wrote:
> >
> >> +#define wait_interruptible_timeout(wq, timeout)
> >>     \
> >> +({                                   \
> >> +    long ret = timeout;                      \
> >> +                                    \
> >> +    DEFINE_WAIT(wait);                      \
> >> +    prepare_to_wait(&wq, &wait, TASK_INTERRUPTIBLE);       \
> >> +    if (!signal_pending(current))                  \
> >> +        ret = schedule_timeout(ret);            \
> >> +    finish_wait(&wq, &wait);                   \
> >> +                                    \
> >> +    ret;                             \
> >> +})
> >
> > It's often a mistake to use signals in-kernel.  Signals are more a
> > userspace thing and it's better to use the lower-level kernel-specific
> > messaging tools in-kernel.  Bear in mind that userspace can
> > independently and asynchronously send, accept and block signals.
> 
> Can you point me to something kernel-level please?
> 
> 
> > Can KMS use wait_event_interruptible_timeout()?
> 
> No. Please check definition of this:
> 
> #define wait_event_interruptible_timeout(wq, condition, timeout)	\
> ({									\
> 	long __ret = timeout;						\
> 	if (!(condition))						\
> 		__wait_event_interruptible_timeout(wq, condition, __ret); \
> 	__ret;								\
> })
> 
> It uses condition there, but that's not a big issue. We just need to
> pass 0 (false) there and it will work so far.

Disabling the condition check doesn't make sense.

You could use a completion.

init_completion(vbl_irq);
enable_vbl_irq();
wait_for_completion(vbl_irq);
disable_vbl_irq();
and call complete(vbl_irq) in the interrupt handler.

The same would of course work with just some flag or counter
and a wait queue. Isn't there already a vbl counter that you could
compare in the condition?

-- 
Ville Syrjälä
syrjala@sci.fi
http://www.sci.fi/~syrjala/

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

  reply	other threads:[~2010-02-26 19:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-21 14:10 [PATCH][RFC] time: add wait_interruptible_timeout macro to sleep (w. timeout) until wake_up Rafał Miłecki
2010-02-21 15:01 ` Thomas Hellstrom
2010-02-21 15:50   ` Rafał Miłecki
2010-02-24 22:33     ` Rafał Miłecki
2010-02-24 22:33       ` Rafał Miłecki
2010-02-26 10:38 ` Rafał Miłecki
2010-02-26 10:38   ` Rafał Miłecki
2010-02-26 11:55   ` Thomas Gleixner
2010-02-26 12:16     ` Rafał Miłecki
2010-02-26 12:16       ` Rafał Miłecki
2010-02-26 16:14   ` Andrew Morton
2010-02-26 17:33     ` Rafał Miłecki
2010-02-26 17:33       ` Rafał Miłecki
2010-02-26 19:01       ` Ville Syrjälä [this message]
2010-02-26 19:01         ` Ville Syrjälä
2010-02-27  9:33         ` Rafał Miłecki
2010-02-27  9:33           ` Rafał Miłecki
2010-03-01 16:37           ` Michel Dänzer
2010-03-01 16:37             ` Michel Dänzer
2010-03-02 20:32             ` Rafał Miłecki
2010-03-02 20:32               ` Rafał Miłecki
2010-02-27  1:04   ` Linus Torvalds

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=20100226190100.GQ10145@sci.fi \
    --to=syrjala@sci.fi \
    --cc=akpm@linux-foundation.org \
    --cc=dri-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=zajec5@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.