All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <Bart.VanAssche@wdc.com>
To: "corbet@lwn.net" <corbet@lwn.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-ide@vger.kernel.org" <linux-ide@vger.kernel.org>,
	"keescook@chromium.org" <keescook@chromium.org>,
	"msuchanek@suse.de" <msuchanek@suse.de>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
	"axboe@kernel.dk" <axboe@kernel.dk>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"kstewart@linuxfoundation.org" <kstewart@linuxfoundation.org>,
	"pombredanne@nexb.com" <pombredanne@nexb.com>,
	"bp@alien8.de" <bp@alien8.de>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"jejb@linux.vnet.ibm.com" <jejb@linux.vnet.ibm.com>,
	"christophe.jaillet@wanadoo.fr" <christophe.jaillet@wanadoo.fr>,
	davem@davemlof
Subject: Re: [PATCH resend 1/6] delay: add poll_event_interruptible
Date: Mon, 29 Jan 2018 17:00:14 +0000	[thread overview]
Message-ID: <1517245212.2687.13.camel@wdc.com> (raw)
In-Reply-To: <a26ef20e6ff686573a0af16435f20aba186746af.1516985620.git.msuchanek@suse.de>

On Fri, 2018-01-26 at 17:58 +0100, Michal Suchanek wrote:
> Add convenience macro for polling an event that does not have a
> waitqueue.
> 
> Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> ---
>  include/linux/delay.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/include/linux/delay.h b/include/linux/delay.h
> index b78bab4395d8..3ae9fa395628 100644
> --- a/include/linux/delay.h
> +++ b/include/linux/delay.h
> @@ -64,4 +64,16 @@ static inline void ssleep(unsigned int seconds)
>  	msleep(seconds * 1000);
>  }
>  
> +#define poll_event_interruptible(event, interval) ({ \
> +	int ret = 0; \
> +	while (!(event)) { \
> +		if (signal_pending(current)) { \
> +			ret = -ERESTARTSYS; \
> +			break; \
> +		} \
> +		msleep_interruptible(interval); \
> +	} \
> +	ret; \
> +})
> +
>  #endif /* defined(_LINUX_DELAY_H) */

Sorry but I'm not sure we should encourage other kernel developers to use
busy-waiting by adding the poll_event_interruptible() macro to a system-wide
header file. Can that macro be moved into a CDROM-specific .c or .h file?

Thanks,

Bart.

WARNING: multiple messages have this Message-ID (diff)
From: Bart Van Assche <Bart.VanAssche@wdc.com>
To: "corbet@lwn.net" <corbet@lwn.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-ide@vger.kernel.org" <linux-ide@vger.kernel.org>,
	"keescook@chromium.org" <keescook@chromium.org>,
	"msuchanek@suse.de" <msuchanek@suse.de>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
	"axboe@kernel.dk" <axboe@kernel.dk>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"kstewart@linuxfoundation.org" <kstewart@linuxfoundation.org>,
	"pombredanne@nexb.com" <pombredanne@nexb.com>,
	"bp@alien8.de" <bp@alien8.de>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"jejb@linux.vnet.ibm.com" <jejb@linux.vnet.ibm.com>,
	"christophe.jaillet@wanadoo.fr" <christophe.jaillet@wanadoo.fr>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"tim@cyberelk.net" <tim@cyberelk.net>
Subject: Re: [PATCH resend 1/6] delay: add poll_event_interruptible
Date: Mon, 29 Jan 2018 17:00:14 +0000	[thread overview]
Message-ID: <1517245212.2687.13.camel@wdc.com> (raw)
In-Reply-To: <a26ef20e6ff686573a0af16435f20aba186746af.1516985620.git.msuchanek@suse.de>

On Fri, 2018-01-26 at 17:58 +0100, Michal Suchanek wrote:
> Add convenience macro for polling an event that does not have a
> waitqueue.
> 
> Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> ---
>  include/linux/delay.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/include/linux/delay.h b/include/linux/delay.h
> index b78bab4395d8..3ae9fa395628 100644
> --- a/include/linux/delay.h
> +++ b/include/linux/delay.h
> @@ -64,4 +64,16 @@ static inline void ssleep(unsigned int seconds)
>  	msleep(seconds * 1000);
>  }
>  
> +#define poll_event_interruptible(event, interval) ({ \
> +	int ret = 0; \
> +	while (!(event)) { \
> +		if (signal_pending(current)) { \
> +			ret = -ERESTARTSYS; \
> +			break; \
> +		} \
> +		msleep_interruptible(interval); \
> +	} \
> +	ret; \
> +})
> +
>  #endif /* defined(_LINUX_DELAY_H) */

Sorry but I'm not sure we should encourage other kernel developers to use
busy-waiting by adding the poll_event_interruptible() macro to a system-wide
header file. Can that macro be moved into a CDROM-specific .c or .h file?

Thanks,

Bart.

  reply	other threads:[~2018-01-29 17:00 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-14 15:13 [PATCH 0/6] Fix cdrom autoclose Michal Suchanek
2017-12-14 15:13 ` [PATCH 1/6] delay: add poll_event_interruptible Michal Suchanek
2017-12-14 15:13 ` [PATCH 2/6] cdrom: factor out common open_for_* code Michal Suchanek
2017-12-14 15:13 ` [PATCH 3/6] cdrom: wait for tray to close Michal Suchanek
2017-12-15 17:20   ` Michal Suchánek
2017-12-14 15:13 ` [PATCH 4/6] cdrom: introduce CDS_DRIVE_ERROR Michal Suchanek
2017-12-14 15:13 ` [PATCH 5/6] Documentetion: " Michal Suchanek
2017-12-14 15:13 ` [PATCH 6/6] cdrom: wait for drive to become ready Michal Suchanek
2018-01-26 16:58 ` [PATCH resend 0/6] Fix cdrom autoclose Michal Suchanek
2018-01-26 16:58   ` [PATCH resend 1/6] delay: add poll_event_interruptible Michal Suchanek
2018-01-29 17:00     ` Bart Van Assche [this message]
2018-01-29 17:00       ` Bart Van Assche
2018-01-26 16:58   ` [PATCH resend 2/6] cdrom: factor out common open_for_* code Michal Suchanek
2018-01-29 17:02     ` Bart Van Assche
2018-01-29 17:02       ` Bart Van Assche
2018-01-26 16:58   ` [PATCH resend 3/6] cdrom: wait for tray to close Michal Suchanek
2018-01-29 17:05     ` Bart Van Assche
2018-01-29 17:05       ` Bart Van Assche
2018-01-31 18:20       ` Michal Suchánek
2018-01-31 18:20         ` Michal Suchánek
2019-10-23 12:19       ` Michal Suchánek
2018-01-26 16:58   ` [PATCH resend 4/6] cdrom: introduce CDS_DRIVE_ERROR Michal Suchanek
2018-01-26 16:58   ` [PATCH resend 5/6] Documentetion: " Michal Suchanek
2018-01-26 16:58   ` [PATCH resend 6/6] cdrom: wait for drive to become ready Michal Suchanek
2018-01-29 17:11     ` Bart Van Assche
2018-01-29 17:11       ` Bart Van Assche
2018-01-26 20:04   ` [PATCH resend 0/6] Fix cdrom autoclose James Bottomley
2018-01-27 22:53     ` Michal Suchánek

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=1517245212.2687.13.camel@wdc.com \
    --to=bart.vanassche@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=bp@alien8.de \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=corbet@lwn.net \
    --cc=davem@davemlof \
    --cc=gregkh@linuxfoundation.org \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=keescook@chromium.org \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=msuchanek@suse.de \
    --cc=pombredanne@nexb.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 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.