mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
net: move sysctl_max_skb_frags to net_hotdata
sysctl_max_skb_frags is used in TCP and MPTCP fast paths, move it to net_hodata for better cache locality. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: David Ahern <dsahern@kernel.org> Link: https://lore.kernel.org/r/20240429134025.1233626-2-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
05d6d49209
commit
a86a0661b8
7 changed files with 8 additions and 9 deletions
|
@ -353,8 +353,6 @@ struct sk_buff;
|
||||||
|
|
||||||
#define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
|
#define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
|
||||||
|
|
||||||
extern int sysctl_max_skb_frags;
|
|
||||||
|
|
||||||
/* Set skb_shinfo(skb)->gso_size to this in case you want skb_segment to
|
/* Set skb_shinfo(skb)->gso_size to this in case you want skb_segment to
|
||||||
* segment using its current segmentation instead.
|
* segment using its current segmentation instead.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -38,6 +38,7 @@ struct net_hotdata {
|
||||||
int max_backlog;
|
int max_backlog;
|
||||||
int dev_tx_weight;
|
int dev_tx_weight;
|
||||||
int dev_rx_weight;
|
int dev_rx_weight;
|
||||||
|
int sysctl_max_skb_frags;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define inet_ehash_secret net_hotdata.tcp_protocol.secret
|
#define inet_ehash_secret net_hotdata.tcp_protocol.secret
|
||||||
|
|
|
@ -18,5 +18,6 @@ struct net_hotdata net_hotdata __cacheline_aligned = {
|
||||||
.max_backlog = 1000,
|
.max_backlog = 1000,
|
||||||
.dev_tx_weight = 64,
|
.dev_tx_weight = 64,
|
||||||
.dev_rx_weight = 64,
|
.dev_rx_weight = 64,
|
||||||
|
.sysctl_max_skb_frags = MAX_SKB_FRAGS,
|
||||||
};
|
};
|
||||||
EXPORT_SYMBOL(net_hotdata);
|
EXPORT_SYMBOL(net_hotdata);
|
||||||
|
|
|
@ -109,9 +109,6 @@ static struct kmem_cache *skbuff_ext_cache __ro_after_init;
|
||||||
#define SKB_SMALL_HEAD_HEADROOM \
|
#define SKB_SMALL_HEAD_HEADROOM \
|
||||||
SKB_WITH_OVERHEAD(SKB_SMALL_HEAD_CACHE_SIZE)
|
SKB_WITH_OVERHEAD(SKB_SMALL_HEAD_CACHE_SIZE)
|
||||||
|
|
||||||
int sysctl_max_skb_frags __read_mostly = MAX_SKB_FRAGS;
|
|
||||||
EXPORT_SYMBOL(sysctl_max_skb_frags);
|
|
||||||
|
|
||||||
/* kcm_write_msgs() relies on casting paged frags to bio_vec to use
|
/* kcm_write_msgs() relies on casting paged frags to bio_vec to use
|
||||||
* iov_iter_bvec(). These static asserts ensure the cast is valid is long as the
|
* iov_iter_bvec(). These static asserts ensure the cast is valid is long as the
|
||||||
* netmem is a page.
|
* netmem is a page.
|
||||||
|
@ -7040,7 +7037,7 @@ static void skb_splice_csum_page(struct sk_buff *skb, struct page *page,
|
||||||
ssize_t skb_splice_from_iter(struct sk_buff *skb, struct iov_iter *iter,
|
ssize_t skb_splice_from_iter(struct sk_buff *skb, struct iov_iter *iter,
|
||||||
ssize_t maxsize, gfp_t gfp)
|
ssize_t maxsize, gfp_t gfp)
|
||||||
{
|
{
|
||||||
size_t frag_limit = READ_ONCE(sysctl_max_skb_frags);
|
size_t frag_limit = READ_ONCE(net_hotdata.sysctl_max_skb_frags);
|
||||||
struct page *pages[8], **ppages = pages;
|
struct page *pages[8], **ppages = pages;
|
||||||
ssize_t spliced = 0, ret = 0;
|
ssize_t spliced = 0, ret = 0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
|
@ -595,7 +595,7 @@ static struct ctl_table net_core_table[] = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.procname = "max_skb_frags",
|
.procname = "max_skb_frags",
|
||||||
.data = &sysctl_max_skb_frags,
|
.data = &net_hotdata.sysctl_max_skb_frags,
|
||||||
.maxlen = sizeof(int),
|
.maxlen = sizeof(int),
|
||||||
.mode = 0644,
|
.mode = 0644,
|
||||||
.proc_handler = proc_dointvec_minmax,
|
.proc_handler = proc_dointvec_minmax,
|
||||||
|
|
|
@ -280,6 +280,7 @@
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <asm/ioctls.h>
|
#include <asm/ioctls.h>
|
||||||
#include <net/busy_poll.h>
|
#include <net/busy_poll.h>
|
||||||
|
#include <net/hotdata.h>
|
||||||
#include <net/rps.h>
|
#include <net/rps.h>
|
||||||
|
|
||||||
/* Track pending CMSGs. */
|
/* Track pending CMSGs. */
|
||||||
|
@ -1188,7 +1189,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
|
||||||
|
|
||||||
if (!skb_can_coalesce(skb, i, pfrag->page,
|
if (!skb_can_coalesce(skb, i, pfrag->page,
|
||||||
pfrag->offset)) {
|
pfrag->offset)) {
|
||||||
if (i >= READ_ONCE(sysctl_max_skb_frags)) {
|
if (i >= READ_ONCE(net_hotdata.sysctl_max_skb_frags)) {
|
||||||
tcp_mark_push(tp, skb);
|
tcp_mark_push(tp, skb);
|
||||||
goto new_segment;
|
goto new_segment;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <net/transp_v6.h>
|
#include <net/transp_v6.h>
|
||||||
#endif
|
#endif
|
||||||
#include <net/mptcp.h>
|
#include <net/mptcp.h>
|
||||||
|
#include <net/hotdata.h>
|
||||||
#include <net/xfrm.h>
|
#include <net/xfrm.h>
|
||||||
#include <asm/ioctls.h>
|
#include <asm/ioctls.h>
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
|
@ -1272,7 +1273,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
|
||||||
|
|
||||||
i = skb_shinfo(skb)->nr_frags;
|
i = skb_shinfo(skb)->nr_frags;
|
||||||
can_coalesce = skb_can_coalesce(skb, i, dfrag->page, offset);
|
can_coalesce = skb_can_coalesce(skb, i, dfrag->page, offset);
|
||||||
if (!can_coalesce && i >= READ_ONCE(sysctl_max_skb_frags)) {
|
if (!can_coalesce && i >= READ_ONCE(net_hotdata.sysctl_max_skb_frags)) {
|
||||||
tcp_mark_push(tcp_sk(ssk), skb);
|
tcp_mark_push(tcp_sk(ssk), skb);
|
||||||
goto alloc_skb;
|
goto alloc_skb;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue