@@ -318,6 +318,7 @@ struct ucred {
* plain text and require encryption
*/
+#define MSG_NTCOPY 0x2000000 /* Use a non-temporal copy */
#define MSG_ZEROCOPY 0x4000000 /* Use user data in kernel path */
#define MSG_FASTOPEN 0x20000000 /* Send data in TCP SYN */
#define MSG_CMSG_CLOEXEC 0x40000000 /* Set close_on_exec for file
@@ -1907,7 +1907,11 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
skb_put(skb, len - data_len);
skb->data_len = data_len;
skb->len = len;
- err = skb_copy_datagram_from_iter(skb, 0, &msg->msg_iter, len);
+ if (msg->msg_flags & MSG_NTCOPY)
+ err = skb_copy_datagram_from_iter_nocache(skb, 0, &msg->msg_iter, len);
+ else
+ err = skb_copy_datagram_from_iter(skb, 0, &msg->msg_iter, len);
+
if (err)
goto out_free;
@@ -2167,7 +2171,12 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg,
skb_put(skb, size - data_len);
skb->data_len = data_len;
skb->len = size;
- err = skb_copy_datagram_from_iter(skb, 0, &msg->msg_iter, size);
+
+ if (msg->msg_flags & MSG_NTCOPY)
+ err = skb_copy_datagram_from_iter_nocache(skb, 0, &msg->msg_iter, size);
+ else
+ err = skb_copy_datagram_from_iter(skb, 0, &msg->msg_iter, size);
+
if (err) {
kfree_skb(skb);
goto out_err;
Add a new sendmsg flag, MSG_NTCOPY, which user programs can use to signal to the kernel that data copied into the kernel during sendmsg should be done so using nontemporal copies, if it is supported by the architecture. Signed-off-by: Joe Damato <jdamato@fastly.com> --- include/linux/socket.h | 1 + net/unix/af_unix.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-)