netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Herbert <tom@herbertland.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: <kernel-team@fb.com>
Subject: [PATCH v2 net-next 04/13] net: Add MSG_BATCH flag
Date: Mon, 7 Mar 2016 14:11:03 -0800	[thread overview]
Message-ID: <1457388672-2600559-5-git-send-email-tom@herbertland.com> (raw)
In-Reply-To: <1457388672-2600559-1-git-send-email-tom@herbertland.com>

Add a new msg flag called MSG_BATCH. This flag is used in sendmsg to
indicate that more messages will follow (i.e. a batch of messages is
being sent). This is similar to MSG_MORE except that the following
messages are not merged into one packet, they are sent individually.
sendmmsg is updated so that each contained message except for the
last one is marked as MSG_BATCH.

MSG_BATCH is a performance optimization in cases where a socket
implementation can benefit by transmitting packets in a batch.

Signed-off-by: Tom Herbert <tom@herbertland.com>
---
 include/linux/socket.h | 1 +
 net/socket.c           | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/include/linux/socket.h b/include/linux/socket.h
index 5bf59c8..d834af2 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -274,6 +274,7 @@ struct ucred {
 #define MSG_MORE	0x8000	/* Sender will send more */
 #define MSG_WAITFORONE	0x10000	/* recvmmsg(): block until 1+ packets avail */
 #define MSG_SENDPAGE_NOTLAST 0x20000 /* sendpage() internal : not the last page */
+#define MSG_BATCH	0x40000 /* sendmmsg(): more messages coming */
 #define MSG_EOF         MSG_FIN
 
 #define MSG_FASTOPEN	0x20000000	/* Send data in TCP SYN */
diff --git a/net/socket.c b/net/socket.c
index 0dd4dd8..886649c 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2008,6 +2008,7 @@ int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
 	struct compat_mmsghdr __user *compat_entry;
 	struct msghdr msg_sys;
 	struct used_address used_address;
+	unsigned int oflags = flags;
 
 	if (vlen > UIO_MAXIOV)
 		vlen = UIO_MAXIOV;
@@ -2022,8 +2023,12 @@ int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
 	entry = mmsg;
 	compat_entry = (struct compat_mmsghdr __user *)mmsg;
 	err = 0;
+	flags |= MSG_BATCH;
 
 	while (datagrams < vlen) {
+		if (datagrams == vlen - 1)
+			flags = oflags;
+
 		if (MSG_CMSG_COMPAT & flags) {
 			err = ___sys_sendmsg(sock, (struct user_msghdr __user *)compat_entry,
 					     &msg_sys, flags, &used_address, MSG_EOR);
-- 
2.6.5

  parent reply	other threads:[~2016-03-07 22:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-07 22:10 [PATCH v2 net-next 00/13] kcm: Kernel Connection Multiplexor (KCM) Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 01/13] rcu: Add list_next_or_null_rcu Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 02/13] net: Make sock_alloc exportable Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 03/13] net: Allow MSG_EOR in each msghdr of sendmmsg Tom Herbert
2018-04-07  8:40   ` Andreas Schwab
2016-03-07 22:11 ` Tom Herbert [this message]
2016-03-07 22:11 ` [PATCH v2 net-next 05/13] net: Walk fragments in __skb_splice_bits Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 06/13] tcp: Add tcp_inq to get available receive bytes on socket Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 07/13] kcm: Kernel Connection Multiplexor module Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 08/13] kcm: Add statistics and proc interfaces Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 09/13] kcm: Splice support Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 10/13] kcm: Sendpage support Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 11/13] kcm: Add memory limit for receive message construction Tom Herbert
2016-03-08  1:28   ` Sowmini Varadhan
2016-03-07 22:11 ` [PATCH v2 net-next 12/13] kcm: Add receive message timeout Tom Herbert
2016-03-07 22:11 ` [PATCH v2 net-next 13/13] kcm: Add description in Documentation Tom Herbert
2016-03-09 21:38 ` [PATCH v2 net-next 00/13] kcm: Kernel Connection Multiplexor (KCM) David Miller

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=1457388672-2600559-5-git-send-email-tom@herbertland.com \
    --to=tom@herbertland.com \
    --cc=davem@davemloft.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).