mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Damato <jdamato@fastly.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>, linux-kernel@vger.kernel.org
Cc: Joe Damato <jdamato@fastly.com>
Subject: [RFC,iov_iter v2 2/8] iov_iter: Introduce iter_copy_type
Date: Sun, 12 Jun 2022 01:57:51 -0700	[thread overview]
Message-ID: <1655024280-23827-3-git-send-email-jdamato@fastly.com> (raw)
In-Reply-To: <1655024280-23827-1-git-send-email-jdamato@fastly.com>

struct iov_iter has a new member: iter_copy_type. This field holds a value
designating which type of copy to use: a regular temporal copy (ITER_COPY)
or a non-temporal copy (ITER_NOCACHE_COPY).

iov_iter initializers have been updated to set the default ITER_COPY
type.

Signed-off-by: Joe Damato <jdamato@fastly.com>
---
 include/linux/uio.h | 17 +++++++++++++++++
 lib/iov_iter.c      |  6 ++++++
 2 files changed, 23 insertions(+)

diff --git a/include/linux/uio.h b/include/linux/uio.h
index 739285f..59573ee 100644
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -28,6 +28,12 @@ enum iter_type {
 	ITER_DISCARD,
 };
 
+enum iter_copy_type {
+	/* iter copy types */
+	ITER_COPY,
+	ITER_NOCACHE_COPY,
+};
+
 struct iov_iter_state {
 	size_t iov_offset;
 	size_t count;
@@ -35,6 +41,7 @@ struct iov_iter_state {
 };
 
 struct iov_iter {
+	u8 iter_copy_type;
 	u8 iter_type;
 	bool nofault;
 	bool data_source;
@@ -62,6 +69,11 @@ static inline enum iter_type iov_iter_type(const struct iov_iter *i)
 	return i->iter_type;
 }
 
+static inline enum iter_copy_type iov_iter_copy_type(const struct iov_iter *i)
+{
+	return i->iter_copy_type;
+}
+
 static inline void iov_iter_save_state(struct iov_iter *iter,
 				       struct iov_iter_state *state)
 {
@@ -95,6 +107,11 @@ static inline bool iov_iter_is_discard(const struct iov_iter *i)
 	return iov_iter_type(i) == ITER_DISCARD;
 }
 
+static inline bool iov_iter_copy_is_nt(const struct iov_iter *i)
+{
+	return iov_iter_copy_type(i) == ITER_NOCACHE_COPY;
+}
+
 static inline bool iov_iter_is_xarray(const struct iov_iter *i)
 {
 	return iov_iter_type(i) == ITER_XARRAY;
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 6dd5330..d32d7e5 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -511,6 +511,7 @@ void iov_iter_init(struct iov_iter *i, unsigned int direction,
 {
 	WARN_ON(direction & ~(READ | WRITE));
 	*i = (struct iov_iter) {
+		.iter_copy_type = ITER_COPY,
 		.iter_type = ITER_IOVEC,
 		.nofault = false,
 		.data_source = direction,
@@ -1175,6 +1176,7 @@ void iov_iter_kvec(struct iov_iter *i, unsigned int direction,
 {
 	WARN_ON(direction & ~(READ | WRITE));
 	*i = (struct iov_iter){
+		.iter_copy_type = ITER_COPY,
 		.iter_type = ITER_KVEC,
 		.data_source = direction,
 		.kvec = kvec,
@@ -1191,6 +1193,7 @@ void iov_iter_bvec(struct iov_iter *i, unsigned int direction,
 {
 	WARN_ON(direction & ~(READ | WRITE));
 	*i = (struct iov_iter){
+		.iter_copy_type = ITER_COPY,
 		.iter_type = ITER_BVEC,
 		.data_source = direction,
 		.bvec = bvec,
@@ -1208,6 +1211,7 @@ void iov_iter_pipe(struct iov_iter *i, unsigned int direction,
 	BUG_ON(direction != READ);
 	WARN_ON(pipe_full(pipe->head, pipe->tail, pipe->ring_size));
 	*i = (struct iov_iter){
+		.iter_copy_type = ITER_COPY,
 		.iter_type = ITER_PIPE,
 		.data_source = false,
 		.pipe = pipe,
@@ -1237,6 +1241,7 @@ void iov_iter_xarray(struct iov_iter *i, unsigned int direction,
 {
 	BUG_ON(direction & ~1);
 	*i = (struct iov_iter) {
+		.iter_copy_type = ITER_COPY,
 		.iter_type = ITER_XARRAY,
 		.data_source = direction,
 		.xarray = xarray,
@@ -1260,6 +1265,7 @@ void iov_iter_discard(struct iov_iter *i, unsigned int direction, size_t count)
 {
 	BUG_ON(direction != READ);
 	*i = (struct iov_iter){
+		.iter_copy_type = ITER_COPY,
 		.iter_type = ITER_DISCARD,
 		.data_source = false,
 		.count = count,
-- 
2.7.4


  parent reply	other threads:[~2022-06-12  9:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-12  8:57 [RFC,net-next,x86 v2 0/8] Nontemporal copies in sendmsg path Joe Damato
2022-06-12  8:57 ` [RFC,x86 v2 1/8] arch, x86, uaccess: Add nontemporal copy functions Joe Damato
2022-06-12  8:57 ` Joe Damato [this message]
2022-06-12  8:57 ` [RFC,iov_iter v2 3/8] iov_iter: add copyin_iovec helper Joe Damato
2022-06-13  4:25   ` Al Viro
2022-06-13  6:32     ` Joe Damato
2022-06-13  7:53   ` David Laight
2022-06-13 14:42     ` Joe Damato
2022-06-13 15:31       ` David Laight
2022-06-12  8:57 ` [RFC,net-next v2 4/8] net: Add MSG_NTCOPY sendmsg flag Joe Damato
2022-06-12  8:57 ` [RFC,net-next v2 5/8] net: unix: Support MSG_NTCOPY Joe Damato
2022-06-12  8:57 ` [RFC,net-next v2 6/8] net: ip: " Joe Damato
2022-06-12  8:57 ` [RFC,net-next v2 7/8] net: udplite: " Joe Damato
2022-06-12  8:57 ` [RFC,net-next v2 8/8] net: tcp: " Joe Damato

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=1655024280-23827-3-git-send-email-jdamato@fastly.com \
    --to=jdamato@fastly.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®