linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add MSG_WAITFORONE flag to recvmmsg
@ 2010-03-26 22:35 Brandon L Black
  2010-03-26 22:44 ` Eric Dumazet
  0 siblings, 1 reply; 10+ messages in thread
From: Brandon L Black @ 2010-03-26 22:35 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Arnaldo Carvalho de Melo, Ulrich Drepper, linux-kernel


From: Brandon L Black <blblack@gmail.com>

Add new flag MSG_WAITFORONE for the recvmmsg() syscall.
When this flag is specified for a blocking socket, recvmmsg()
will only block until at least 1 packet is available.  The
default behavior is to block until all vlen packets are
available.  This flag has no effect on non-blocking sockets
or when used in combination with MSG_DONTWAIT.

Signed-off-by: Brandon L Black <blblack@gmail.com>

---
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 7b3aae2..354cc56 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -255,6 +255,7 @@ struct ucred {
 #define MSG_ERRQUEUE	0x2000	/* Fetch message from error queue */
 #define MSG_NOSIGNAL	0x4000	/* Do not generate SIGPIPE */
 #define MSG_MORE	0x8000	/* Sender will send more */
+#define MSG_WAITFORONE	0x10000	/* recvmmsg(): block until 1+ packets avail */
 
 #define MSG_EOF         MSG_FIN
 
diff --git a/net/socket.c b/net/socket.c
index 769c386..33304d1 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2133,7 +2133,10 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
 
 		if (err)
 			break;
-		++datagrams;
+
+		/* MSG_WAITFORONE turns on MSG_DONTWAIT after one packet */
+		if (!datagrams++ && (flags & MSG_WAITFORONE))
+			flags |= MSG_DONTWAIT;
 
 		if (timeout) {
 			ktime_get_ts(timeout);

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] Add MSG_WAITFORONE flag to recvmmsg
  2010-03-26 22:35 [PATCH] Add MSG_WAITFORONE flag to recvmmsg Brandon L Black
@ 2010-03-26 22:44 ` Eric Dumazet
  2010-03-26 22:55   ` Brandon Black
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Dumazet @ 2010-03-26 22:44 UTC (permalink / raw)
  To: Brandon L Black
  Cc: netdev, David S. Miller, Arnaldo Carvalho de Melo,
	Ulrich Drepper, linux-kernel

Le vendredi 26 mars 2010 à 17:35 -0500, Brandon L Black a écrit :
> From: Brandon L Black <blblack@gmail.com>
> 
> Add new flag MSG_WAITFORONE for the recvmmsg() syscall.
> When this flag is specified for a blocking socket, recvmmsg()
> will only block until at least 1 packet is available.  The
> default behavior is to block until all vlen packets are
> available.  This flag has no effect on non-blocking sockets
> or when used in combination with MSG_DONTWAIT.
> 
> Signed-off-by: Brandon L Black <blblack@gmail.com>


> 
> ---
> diff --git a/include/linux/socket.h b/include/linux/socket.h
> index 7b3aae2..354cc56 100644
> --- a/include/linux/socket.h
> +++ b/include/linux/socket.h
> @@ -255,6 +255,7 @@ struct ucred {
>  #define MSG_ERRQUEUE	0x2000	/* Fetch message from error queue */
>  #define MSG_NOSIGNAL	0x4000	/* Do not generate SIGPIPE */
>  #define MSG_MORE	0x8000	/* Sender will send more */
> +#define MSG_WAITFORONE	0x10000	/* recvmmsg(): block until 1+ packets avail */
>  
>  #define MSG_EOF         MSG_FIN
>  
> diff --git a/net/socket.c b/net/socket.c
> index 769c386..33304d1 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -2133,7 +2133,10 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
>  
>  		if (err)
>  			break;
> -		++datagrams;
> +
> +		/* MSG_WAITFORONE turns on MSG_DONTWAIT after one packet */
> +		if (!datagrams++ && (flags & MSG_WAITFORONE))
> +			flags |= MSG_DONTWAIT;


Hmmm, no need to test !datagram, just do :

	++datagrams;

	if (flags & MSG_WAITFORONE)
		flags |= MSG_DONTWAIT;




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Add MSG_WAITFORONE flag to recvmmsg
  2010-03-26 22:44 ` Eric Dumazet
@ 2010-03-26 22:55   ` Brandon Black
  2010-03-27  2:07     ` Ulrich Drepper
  0 siblings, 1 reply; 10+ messages in thread
From: Brandon Black @ 2010-03-26 22:55 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: netdev, David S. Miller, Arnaldo Carvalho de Melo,
	Ulrich Drepper, linux-kernel

On Fri, Mar 26, 2010 at 5:44 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> Hmmm, no need to test !datagram, just do :
>
>        ++datagrams;
>
>        if (flags & MSG_WAITFORONE)
>                flags |= MSG_DONTWAIT;
>

Ok.  I've never been through this process before.  Do I resubmit a new
subject/thread with the changed patch and [PATCH v2] at this point?
Any other nits about how the patch was sent before I do?

Thanks,
-- Brandon

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Add MSG_WAITFORONE flag to recvmmsg
  2010-03-26 22:55   ` Brandon Black
@ 2010-03-27  2:07     ` Ulrich Drepper
  2010-03-27  2:18       ` [PATCH v2] " Brandon L Black
  0 siblings, 1 reply; 10+ messages in thread
From: Ulrich Drepper @ 2010-03-27  2:07 UTC (permalink / raw)
  To: Brandon Black
  Cc: Eric Dumazet, netdev, David S. Miller, Arnaldo Carvalho de Melo,
	linux-kernel

On Fri, Mar 26, 2010 at 15:55, Brandon Black <blblack@gmail.com> wrote:
> Ok.  I've never been through this process before.  Do I resubmit a new
> subject/thread with the changed patch and [PATCH v2] at this point?

The patch is small enough for this to be OK.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2] Add MSG_WAITFORONE flag to recvmmsg
  2010-03-27  2:07     ` Ulrich Drepper
@ 2010-03-27  2:18       ` Brandon L Black
  2010-03-27  3:54         ` David Miller
                           ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Brandon L Black @ 2010-03-27  2:18 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Arnaldo Carvalho de Melo, Ulrich Drepper, linux-kernel


From: Brandon L Black <blblack@gmail.com>

Add new flag MSG_WAITFORONE for the recvmmsg() syscall.
When this flag is specified for a blocking socket, recvmmsg()
will only block until at least 1 packet is available.  The
default behavior is to block until all vlen packets are
available.  This flag has no effect on non-blocking sockets
or when used in combination with MSG_DONTWAIT.

Signed-off-by: Brandon L Black <blblack@gmail.com>

---
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 7b3aae2..354cc56 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -255,6 +255,7 @@ struct ucred {
 #define MSG_ERRQUEUE	0x2000	/* Fetch message from error queue */
 #define MSG_NOSIGNAL	0x4000	/* Do not generate SIGPIPE */
 #define MSG_MORE	0x8000	/* Sender will send more */
+#define MSG_WAITFORONE	0x10000	/* recvmmsg(): block until 1+ packets avail */
 
 #define MSG_EOF         MSG_FIN
 
diff --git a/net/socket.c b/net/socket.c
index 769c386..f55ffe9 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2135,6 +2135,10 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
 			break;
 		++datagrams;
 
+		/* MSG_WAITFORONE turns on MSG_DONTWAIT after one packet */
+		if (flags & MSG_WAITFORONE)
+			flags |= MSG_DONTWAIT;
+
 		if (timeout) {
 			ktime_get_ts(timeout);
 			*timeout = timespec_sub(end_time, *timeout);

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] Add MSG_WAITFORONE flag to recvmmsg
  2010-03-27  2:18       ` [PATCH v2] " Brandon L Black
@ 2010-03-27  3:54         ` David Miller
  2010-03-27 14:07           ` Arnaldo Carvalho de Melo
  2010-03-27  4:58         ` Ulrich Drepper
  2010-03-27  6:00         ` Eric Dumazet
  2 siblings, 1 reply; 10+ messages in thread
From: David Miller @ 2010-03-27  3:54 UTC (permalink / raw)
  To: blblack; +Cc: netdev, acme, drepper, linux-kernel

From: Brandon L Black <blblack@gmail.com>
Date: Fri, 26 Mar 2010 21:18:03 -0500

> 
> From: Brandon L Black <blblack@gmail.com>
> 
> Add new flag MSG_WAITFORONE for the recvmmsg() syscall.
> When this flag is specified for a blocking socket, recvmmsg()
> will only block until at least 1 packet is available.  The
> default behavior is to block until all vlen packets are
> available.  This flag has no effect on non-blocking sockets
> or when used in combination with MSG_DONTWAIT.
> 
> Signed-off-by: Brandon L Black <blblack@gmail.com>

Arnaldo, please review this, thanks.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] Add MSG_WAITFORONE flag to recvmmsg
  2010-03-27  2:18       ` [PATCH v2] " Brandon L Black
  2010-03-27  3:54         ` David Miller
@ 2010-03-27  4:58         ` Ulrich Drepper
  2010-03-27  6:00         ` Eric Dumazet
  2 siblings, 0 replies; 10+ messages in thread
From: Ulrich Drepper @ 2010-03-27  4:58 UTC (permalink / raw)
  To: Brandon L Black
  Cc: netdev, David S. Miller, Arnaldo Carvalho de Melo, linux-kernel

On Fri, Mar 26, 2010 at 19:18, Brandon L Black <blblack@gmail.com> wrote:
> Add new flag MSG_WAITFORONE for the recvmmsg() syscall.
> When this flag is specified for a blocking socket, recvmmsg()
> will only block until at least 1 packet is available.  The
> default behavior is to block until all vlen packets are
> available.  This flag has no effect on non-blocking sockets
> or when used in combination with MSG_DONTWAIT.
>
> Signed-off-by: Brandon L Black <blblack@gmail.com>

This is useful and looks OK to me.

Acked-by: Ulrich Drepper <drepper@redhat.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] Add MSG_WAITFORONE flag to recvmmsg
  2010-03-27  2:18       ` [PATCH v2] " Brandon L Black
  2010-03-27  3:54         ` David Miller
  2010-03-27  4:58         ` Ulrich Drepper
@ 2010-03-27  6:00         ` Eric Dumazet
  2 siblings, 0 replies; 10+ messages in thread
From: Eric Dumazet @ 2010-03-27  6:00 UTC (permalink / raw)
  To: Brandon L Black
  Cc: netdev, David S. Miller, Arnaldo Carvalho de Melo,
	Ulrich Drepper, linux-kernel

Le vendredi 26 mars 2010 à 21:18 -0500, Brandon L Black a écrit :
> From: Brandon L Black <blblack@gmail.com>
> 
> Add new flag MSG_WAITFORONE for the recvmmsg() syscall.
> When this flag is specified for a blocking socket, recvmmsg()
> will only block until at least 1 packet is available.  The
> default behavior is to block until all vlen packets are
> available.  This flag has no effect on non-blocking sockets
> or when used in combination with MSG_DONTWAIT.
> 
> Signed-off-by: Brandon L Black <blblack@gmail.com>
> 

Acked-by: Eric Dumazet <eric.dumazet@gmail.com>

> ---
> diff --git a/include/linux/socket.h b/include/linux/socket.h
> index 7b3aae2..354cc56 100644
> --- a/include/linux/socket.h
> +++ b/include/linux/socket.h
> @@ -255,6 +255,7 @@ struct ucred {
>  #define MSG_ERRQUEUE	0x2000	/* Fetch message from error queue */
>  #define MSG_NOSIGNAL	0x4000	/* Do not generate SIGPIPE */
>  #define MSG_MORE	0x8000	/* Sender will send more */
> +#define MSG_WAITFORONE	0x10000	/* recvmmsg(): block until 1+ packets avail */
>  
>  #define MSG_EOF         MSG_FIN
>  
> diff --git a/net/socket.c b/net/socket.c
> index 769c386..f55ffe9 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -2135,6 +2135,10 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
>  			break;
>  		++datagrams;
>  
> +		/* MSG_WAITFORONE turns on MSG_DONTWAIT after one packet */
> +		if (flags & MSG_WAITFORONE)
> +			flags |= MSG_DONTWAIT;
> +
>  		if (timeout) {
>  			ktime_get_ts(timeout);
>  			*timeout = timespec_sub(end_time, *timeout);
> --


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] Add MSG_WAITFORONE flag to recvmmsg
  2010-03-27  3:54         ` David Miller
@ 2010-03-27 14:07           ` Arnaldo Carvalho de Melo
  2010-03-27 15:29             ` David Miller
  0 siblings, 1 reply; 10+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-03-27 14:07 UTC (permalink / raw)
  To: David Miller; +Cc: blblack, netdev, drepper, linux-kernel

Em Fri, Mar 26, 2010 at 08:54:28PM -0700, David Miller escreveu:
> From: Brandon L Black <blblack@gmail.com>
> Date: Fri, 26 Mar 2010 21:18:03 -0500
> 
> > 
> > From: Brandon L Black <blblack@gmail.com>
> > 
> > Add new flag MSG_WAITFORONE for the recvmmsg() syscall.
> > When this flag is specified for a blocking socket, recvmmsg()
> > will only block until at least 1 packet is available.  The
> > default behavior is to block until all vlen packets are
> > available.  This flag has no effect on non-blocking sockets
> > or when used in combination with MSG_DONTWAIT.
> > 
> > Signed-off-by: Brandon L Black <blblack@gmail.com>
> 
> Arnaldo, please review this, thanks.

I'm ok with it.

Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>

- Arnaldo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] Add MSG_WAITFORONE flag to recvmmsg
  2010-03-27 14:07           ` Arnaldo Carvalho de Melo
@ 2010-03-27 15:29             ` David Miller
  0 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2010-03-27 15:29 UTC (permalink / raw)
  To: acme; +Cc: blblack, netdev, drepper, linux-kernel

From: Arnaldo Carvalho de Melo <acme@redhat.com>
Date: Sat, 27 Mar 2010 11:07:17 -0300

> Em Fri, Mar 26, 2010 at 08:54:28PM -0700, David Miller escreveu:
>> From: Brandon L Black <blblack@gmail.com>
>> Date: Fri, 26 Mar 2010 21:18:03 -0500
>> 
>> > 
>> > From: Brandon L Black <blblack@gmail.com>
>> > 
>> > Add new flag MSG_WAITFORONE for the recvmmsg() syscall.
>> > When this flag is specified for a blocking socket, recvmmsg()
>> > will only block until at least 1 packet is available.  The
>> > default behavior is to block until all vlen packets are
>> > available.  This flag has no effect on non-blocking sockets
>> > or when used in combination with MSG_DONTWAIT.
>> > 
>> > Signed-off-by: Brandon L Black <blblack@gmail.com>
>> 
>> Arnaldo, please review this, thanks.
> 
> I'm ok with it.
> 
> Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Applied, thanks everyone.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-03-27 15:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-26 22:35 [PATCH] Add MSG_WAITFORONE flag to recvmmsg Brandon L Black
2010-03-26 22:44 ` Eric Dumazet
2010-03-26 22:55   ` Brandon Black
2010-03-27  2:07     ` Ulrich Drepper
2010-03-27  2:18       ` [PATCH v2] " Brandon L Black
2010-03-27  3:54         ` David Miller
2010-03-27 14:07           ` Arnaldo Carvalho de Melo
2010-03-27 15:29             ` David Miller
2010-03-27  4:58         ` Ulrich Drepper
2010-03-27  6:00         ` Eric Dumazet

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).