Skip to content

Commit

Permalink
tcp_bpf, smc, tls, espintcp, siw: Reduce MSG_SENDPAGE_NOTLAST usage
Browse files Browse the repository at this point in the history
As MSG_SENDPAGE_NOTLAST is being phased out along with sendpage(), don't
use it further in than the sendpage methods, but rather translate it to
MSG_MORE and use that instead.

Signed-off-by: David Howells <[email protected]>
cc: Willem de Bruijn <[email protected]>
cc: Bernard Metzler <[email protected]>
cc: Jason Gunthorpe <[email protected]>
cc: Leon Romanovsky <[email protected]>
cc: John Fastabend <[email protected]>
cc: Jakub Sitnicki <[email protected]>
cc: David Ahern <[email protected]>
cc: Karsten Graul <[email protected]>
cc: Wenjia Zhang <[email protected]>
cc: Jan Karcher <[email protected]>
cc: "D. Wythe" <[email protected]>
cc: Tony Lu <[email protected]>
cc: Wen Gu <[email protected]>
cc: Boris Pismenny <[email protected]>
cc: Steffen Klassert <[email protected]>
cc: Herbert Xu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
dhowells authored and kuba-moo committed Jun 24, 2023
1 parent b545a13 commit f8dd95b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
5 changes: 2 additions & 3 deletions drivers/infiniband/sw/siw/siw_qp_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,7 @@ static int siw_tcp_sendpages(struct socket *s, struct page **page, int offset,
{
struct bio_vec bvec;
struct msghdr msg = {
.msg_flags = (MSG_MORE | MSG_DONTWAIT | MSG_SENDPAGE_NOTLAST |
MSG_SPLICE_PAGES),
.msg_flags = (MSG_MORE | MSG_DONTWAIT | MSG_SPLICE_PAGES),
};
struct sock *sk = s->sk;
int i = 0, rv = 0, sent = 0;
Expand All @@ -335,7 +334,7 @@ static int siw_tcp_sendpages(struct socket *s, struct page **page, int offset,
size_t bytes = min_t(size_t, PAGE_SIZE - offset, size);

if (size + offset <= PAGE_SIZE)
msg.msg_flags &= ~MSG_SENDPAGE_NOTLAST;
msg.msg_flags &= ~MSG_MORE;

tcp_rate_check_app_limited(sk);
bvec_set_page(&bvec, page[i], bytes, offset);
Expand Down
5 changes: 3 additions & 2 deletions net/ipv4/tcp_bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ static int bpf_tcp_ingress(struct sock *sk, struct sk_psock *psock,
static int tcp_bpf_push(struct sock *sk, struct sk_msg *msg, u32 apply_bytes,
int flags, bool uncharge)
{
struct msghdr msghdr = {};
bool apply = apply_bytes;
struct scatterlist *sge;
struct msghdr msghdr = { .msg_flags = flags | MSG_SPLICE_PAGES, };
struct page *page;
int size, ret = 0;
u32 off;
Expand All @@ -107,11 +107,12 @@ static int tcp_bpf_push(struct sock *sk, struct sk_msg *msg, u32 apply_bytes,

tcp_rate_check_app_limited(sk);
retry:
msghdr.msg_flags = flags | MSG_SPLICE_PAGES;
has_tx_ulp = tls_sw_has_ctx_tx(sk);
if (has_tx_ulp)
msghdr.msg_flags |= MSG_SENDPAGE_NOPOLICY;

if (flags & MSG_SENDPAGE_NOTLAST)
if (size < sge->length && msg->sg.start != msg->sg.end)
msghdr.msg_flags |= MSG_MORE;

bvec_set_page(&bvec, page, size, off);
Expand Down
6 changes: 4 additions & 2 deletions net/smc/smc_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ static bool smc_tx_should_cork(struct smc_sock *smc, struct msghdr *msg)
* should known how/when to uncork it.
*/
if ((msg->msg_flags & MSG_MORE ||
smc_tx_is_corked(smc) ||
msg->msg_flags & MSG_SENDPAGE_NOTLAST) &&
smc_tx_is_corked(smc)) &&
atomic_read(&conn->sndbuf_space))
return true;

Expand Down Expand Up @@ -306,6 +305,9 @@ int smc_tx_sendpage(struct smc_sock *smc, struct page *page, int offset,
struct kvec iov;
int rc;

if (flags & MSG_SENDPAGE_NOTLAST)
msg.msg_flags |= MSG_MORE;

iov.iov_base = kaddr + offset;
iov.iov_len = size;
iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, &iov, 1, size);
Expand Down
4 changes: 2 additions & 2 deletions net/tls/tls_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ static int tls_push_data(struct sock *sk,
return -sk->sk_err;

flags |= MSG_SENDPAGE_DECRYPTED;
tls_push_record_flags = flags | MSG_SENDPAGE_NOTLAST;
tls_push_record_flags = flags | MSG_MORE;

timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);
if (tls_is_partially_sent_record(tls_ctx)) {
Expand Down Expand Up @@ -532,7 +532,7 @@ static int tls_push_data(struct sock *sk,
if (!size) {
last_record:
tls_push_record_flags = flags;
if (flags & (MSG_SENDPAGE_NOTLAST | MSG_MORE)) {
if (flags & MSG_MORE) {
more = true;
break;
}
Expand Down
10 changes: 6 additions & 4 deletions net/xfrm/espintcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,15 @@ static int espintcp_sendskb_locked(struct sock *sk, struct espintcp_msg *emsg,
static int espintcp_sendskmsg_locked(struct sock *sk,
struct espintcp_msg *emsg, int flags)
{
struct msghdr msghdr = { .msg_flags = flags | MSG_SPLICE_PAGES, };
struct msghdr msghdr = {
.msg_flags = flags | MSG_SPLICE_PAGES | MSG_MORE,
};
struct sk_msg *skmsg = &emsg->skmsg;
bool more = flags & MSG_MORE;
struct scatterlist *sg;
int done = 0;
int ret;

msghdr.msg_flags |= MSG_SENDPAGE_NOTLAST;
sg = &skmsg->sg.data[skmsg->sg.start];
do {
struct bio_vec bvec;
Expand All @@ -221,8 +223,8 @@ static int espintcp_sendskmsg_locked(struct sock *sk,

emsg->offset = 0;

if (sg_is_last(sg))
msghdr.msg_flags &= ~MSG_SENDPAGE_NOTLAST;
if (sg_is_last(sg) && !more)
msghdr.msg_flags &= ~MSG_MORE;

p = sg_page(sg);
retry:
Expand Down

0 comments on commit f8dd95b

Please sign in to comment.