Skip to content

Commit

Permalink
skbuff: rename sock_zerocopy_* to msg_zerocopy_*
Browse files Browse the repository at this point in the history
At Willem's suggestion, rename the sock_zerocopy_* functions
so that they match the MSG_ZEROCOPY flag, which makes it clear
they are specific to this zerocopy implementation.

Signed-off-by: Jonathan Lemon <[email protected]>
Acked-by: Willem de Bruijn <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
jlemon authored and kuba-moo committed Jan 8, 2021
1 parent 70c4316 commit 8c79382
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
18 changes: 9 additions & 9 deletions include/linux/skbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,14 +488,14 @@ struct ubuf_info {
int mm_account_pinned_pages(struct mmpin *mmp, size_t size);
void mm_unaccount_pinned_pages(struct mmpin *mmp);

struct ubuf_info *sock_zerocopy_alloc(struct sock *sk, size_t size);
struct ubuf_info *sock_zerocopy_realloc(struct sock *sk, size_t size,
struct ubuf_info *uarg);
struct ubuf_info *msg_zerocopy_alloc(struct sock *sk, size_t size);
struct ubuf_info *msg_zerocopy_realloc(struct sock *sk, size_t size,
struct ubuf_info *uarg);

void sock_zerocopy_put_abort(struct ubuf_info *uarg, bool have_uref);
void msg_zerocopy_put_abort(struct ubuf_info *uarg, bool have_uref);

void sock_zerocopy_callback(struct sk_buff *skb, struct ubuf_info *uarg,
bool success);
void msg_zerocopy_callback(struct sk_buff *skb, struct ubuf_info *uarg,
bool success);

int skb_zerocopy_iter_dgram(struct sk_buff *skb, struct msghdr *msg, int len);
int skb_zerocopy_iter_stream(struct sock *sk, struct sk_buff *skb,
Expand Down Expand Up @@ -1481,8 +1481,8 @@ static inline void skb_zcopy_put(struct ubuf_info *uarg)
static inline void skb_zcopy_put_abort(struct ubuf_info *uarg, bool have_uref)
{
if (uarg) {
if (uarg->callback == sock_zerocopy_callback)
sock_zerocopy_put_abort(uarg, have_uref);
if (uarg->callback == msg_zerocopy_callback)
msg_zerocopy_put_abort(uarg, have_uref);
else if (have_uref)
skb_zcopy_put(uarg);
}
Expand Down Expand Up @@ -2776,7 +2776,7 @@ static inline int skb_orphan_frags(struct sk_buff *skb, gfp_t gfp_mask)
if (likely(!skb_zcopy(skb)))
return 0;
if (!skb_zcopy_is_nouarg(skb) &&
skb_uarg(skb)->callback == sock_zerocopy_callback)
skb_uarg(skb)->callback == msg_zerocopy_callback)
return 0;
return skb_copy_ubufs(skb, gfp_mask);
}
Expand Down
30 changes: 15 additions & 15 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ void mm_unaccount_pinned_pages(struct mmpin *mmp)
}
EXPORT_SYMBOL_GPL(mm_unaccount_pinned_pages);

struct ubuf_info *sock_zerocopy_alloc(struct sock *sk, size_t size)
struct ubuf_info *msg_zerocopy_alloc(struct sock *sk, size_t size)
{
struct ubuf_info *uarg;
struct sk_buff *skb;
Expand All @@ -1114,7 +1114,7 @@ struct ubuf_info *sock_zerocopy_alloc(struct sock *sk, size_t size)
return NULL;
}

uarg->callback = sock_zerocopy_callback;
uarg->callback = msg_zerocopy_callback;
uarg->id = ((u32)atomic_inc_return(&sk->sk_zckey)) - 1;
uarg->len = 1;
uarg->bytelen = size;
Expand All @@ -1124,15 +1124,15 @@ struct ubuf_info *sock_zerocopy_alloc(struct sock *sk, size_t size)

return uarg;
}
EXPORT_SYMBOL_GPL(sock_zerocopy_alloc);
EXPORT_SYMBOL_GPL(msg_zerocopy_alloc);

static inline struct sk_buff *skb_from_uarg(struct ubuf_info *uarg)
{
return container_of((void *)uarg, struct sk_buff, cb);
}

struct ubuf_info *sock_zerocopy_realloc(struct sock *sk, size_t size,
struct ubuf_info *uarg)
struct ubuf_info *msg_zerocopy_realloc(struct sock *sk, size_t size,
struct ubuf_info *uarg)
{
if (uarg) {
const u32 byte_limit = 1 << 19; /* limit to a few TSO */
Expand Down Expand Up @@ -1171,9 +1171,9 @@ struct ubuf_info *sock_zerocopy_realloc(struct sock *sk, size_t size,
}

new_alloc:
return sock_zerocopy_alloc(sk, size);
return msg_zerocopy_alloc(sk, size);
}
EXPORT_SYMBOL_GPL(sock_zerocopy_realloc);
EXPORT_SYMBOL_GPL(msg_zerocopy_realloc);

static bool skb_zerocopy_notify_extend(struct sk_buff *skb, u32 lo, u16 len)
{
Expand All @@ -1195,7 +1195,7 @@ static bool skb_zerocopy_notify_extend(struct sk_buff *skb, u32 lo, u16 len)
return true;
}

static void __sock_zerocopy_callback(struct ubuf_info *uarg)
static void __msg_zerocopy_callback(struct ubuf_info *uarg)
{
struct sk_buff *tail, *skb = skb_from_uarg(uarg);
struct sock_exterr_skb *serr;
Expand Down Expand Up @@ -1243,27 +1243,27 @@ static void __sock_zerocopy_callback(struct ubuf_info *uarg)
sock_put(sk);
}

void sock_zerocopy_callback(struct sk_buff *skb, struct ubuf_info *uarg,
bool success)
void msg_zerocopy_callback(struct sk_buff *skb, struct ubuf_info *uarg,
bool success)
{
uarg->zerocopy = uarg->zerocopy & success;

if (refcount_dec_and_test(&uarg->refcnt))
__sock_zerocopy_callback(uarg);
__msg_zerocopy_callback(uarg);
}
EXPORT_SYMBOL_GPL(sock_zerocopy_callback);
EXPORT_SYMBOL_GPL(msg_zerocopy_callback);

void sock_zerocopy_put_abort(struct ubuf_info *uarg, bool have_uref)
void msg_zerocopy_put_abort(struct ubuf_info *uarg, bool have_uref)
{
struct sock *sk = skb_from_uarg(uarg)->sk;

atomic_dec(&sk->sk_zckey);
uarg->len--;

if (have_uref)
sock_zerocopy_callback(NULL, uarg, true);
msg_zerocopy_callback(NULL, uarg, true);
}
EXPORT_SYMBOL_GPL(sock_zerocopy_put_abort);
EXPORT_SYMBOL_GPL(msg_zerocopy_put_abort);

int skb_zerocopy_iter_dgram(struct sk_buff *skb, struct msghdr *msg, int len)
{
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/ip_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ static int __ip_append_data(struct sock *sk,
csummode = CHECKSUM_PARTIAL;

if (flags & MSG_ZEROCOPY && length && sock_flag(sk, SOCK_ZEROCOPY)) {
uarg = sock_zerocopy_realloc(sk, length, skb_zcopy(skb));
uarg = msg_zerocopy_realloc(sk, length, skb_zcopy(skb));
if (!uarg)
return -ENOBUFS;
extra_uref = !skb_zcopy(skb); /* only ref on new uarg */
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)

if (flags & MSG_ZEROCOPY && size && sock_flag(sk, SOCK_ZEROCOPY)) {
skb = tcp_write_queue_tail(sk);
uarg = sock_zerocopy_realloc(sk, size, skb_zcopy(skb));
uarg = msg_zerocopy_realloc(sk, size, skb_zcopy(skb));
if (!uarg) {
err = -ENOBUFS;
goto out_err;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/ip6_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ static int __ip6_append_data(struct sock *sk,
csummode = CHECKSUM_PARTIAL;

if (flags & MSG_ZEROCOPY && length && sock_flag(sk, SOCK_ZEROCOPY)) {
uarg = sock_zerocopy_realloc(sk, length, skb_zcopy(skb));
uarg = msg_zerocopy_realloc(sk, length, skb_zcopy(skb));
if (!uarg)
return -ENOBUFS;
extra_uref = !skb_zcopy(skb); /* only ref on new uarg */
Expand Down

0 comments on commit 8c79382

Please sign in to comment.