mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-01 10:45:49 +00:00
net: move netdev_max_backlog to net_hotdata
netdev_max_backlog is used in rx fat path. Move it to net_hodata for better cache locality. Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Soheil Hassas Yeganeh <soheil@google.com> Reviewed-by: David Ahern <dsahern@kernel.org> Link: https://lore.kernel.org/r/20240306160031.874438-6-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
0b91fa4bfb
commit
edbc666cdc
@ -4793,7 +4793,6 @@ void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s,
|
|||||||
const struct pcpu_sw_netstats __percpu *netstats);
|
const struct pcpu_sw_netstats __percpu *netstats);
|
||||||
void dev_get_tstats64(struct net_device *dev, struct rtnl_link_stats64 *s);
|
void dev_get_tstats64(struct net_device *dev, struct rtnl_link_stats64 *s);
|
||||||
|
|
||||||
extern int netdev_max_backlog;
|
|
||||||
extern int dev_rx_weight;
|
extern int dev_rx_weight;
|
||||||
extern int dev_tx_weight;
|
extern int dev_tx_weight;
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ struct net_hotdata {
|
|||||||
int netdev_budget;
|
int netdev_budget;
|
||||||
int netdev_budget_usecs;
|
int netdev_budget_usecs;
|
||||||
int tstamp_prequeue;
|
int tstamp_prequeue;
|
||||||
|
int max_backlog;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct net_hotdata net_hotdata;
|
extern struct net_hotdata net_hotdata;
|
||||||
|
@ -4404,9 +4404,6 @@ EXPORT_SYMBOL(__dev_direct_xmit);
|
|||||||
* Receiver routines
|
* Receiver routines
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
int netdev_max_backlog __read_mostly = 1000;
|
|
||||||
EXPORT_SYMBOL(netdev_max_backlog);
|
|
||||||
|
|
||||||
unsigned int sysctl_skb_defer_max __read_mostly = 64;
|
unsigned int sysctl_skb_defer_max __read_mostly = 64;
|
||||||
int weight_p __read_mostly = 64; /* old backlog weight */
|
int weight_p __read_mostly = 64; /* old backlog weight */
|
||||||
int dev_weight_rx_bias __read_mostly = 1; /* bias for backlog weight */
|
int dev_weight_rx_bias __read_mostly = 1; /* bias for backlog weight */
|
||||||
@ -4713,7 +4710,7 @@ static bool skb_flow_limit(struct sk_buff *skb, unsigned int qlen)
|
|||||||
struct softnet_data *sd;
|
struct softnet_data *sd;
|
||||||
unsigned int old_flow, new_flow;
|
unsigned int old_flow, new_flow;
|
||||||
|
|
||||||
if (qlen < (READ_ONCE(netdev_max_backlog) >> 1))
|
if (qlen < (READ_ONCE(net_hotdata.max_backlog) >> 1))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
sd = this_cpu_ptr(&softnet_data);
|
sd = this_cpu_ptr(&softnet_data);
|
||||||
@ -4761,7 +4758,8 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu,
|
|||||||
if (!netif_running(skb->dev))
|
if (!netif_running(skb->dev))
|
||||||
goto drop;
|
goto drop;
|
||||||
qlen = skb_queue_len(&sd->input_pkt_queue);
|
qlen = skb_queue_len(&sd->input_pkt_queue);
|
||||||
if (qlen <= READ_ONCE(netdev_max_backlog) && !skb_flow_limit(skb, qlen)) {
|
if (qlen <= READ_ONCE(net_hotdata.max_backlog) &&
|
||||||
|
!skb_flow_limit(skb, qlen)) {
|
||||||
if (qlen) {
|
if (qlen) {
|
||||||
enqueue:
|
enqueue:
|
||||||
__skb_queue_tail(&sd->input_pkt_queue, skb);
|
__skb_queue_tail(&sd->input_pkt_queue, skb);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/netdevice.h>
|
#include <linux/netdevice.h>
|
||||||
#include <net/gro_cells.h>
|
#include <net/gro_cells.h>
|
||||||
|
#include <net/hotdata.h>
|
||||||
|
|
||||||
struct gro_cell {
|
struct gro_cell {
|
||||||
struct sk_buff_head napi_skbs;
|
struct sk_buff_head napi_skbs;
|
||||||
@ -26,7 +27,7 @@ int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb)
|
|||||||
|
|
||||||
cell = this_cpu_ptr(gcells->cells);
|
cell = this_cpu_ptr(gcells->cells);
|
||||||
|
|
||||||
if (skb_queue_len(&cell->napi_skbs) > READ_ONCE(netdev_max_backlog)) {
|
if (skb_queue_len(&cell->napi_skbs) > READ_ONCE(net_hotdata.max_backlog)) {
|
||||||
drop:
|
drop:
|
||||||
dev_core_stats_rx_dropped_inc(dev);
|
dev_core_stats_rx_dropped_inc(dev);
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
|
@ -15,4 +15,6 @@ struct net_hotdata net_hotdata __cacheline_aligned = {
|
|||||||
.netdev_budget_usecs = 2 * USEC_PER_SEC / HZ,
|
.netdev_budget_usecs = 2 * USEC_PER_SEC / HZ,
|
||||||
|
|
||||||
.tstamp_prequeue = 1,
|
.tstamp_prequeue = 1,
|
||||||
|
.max_backlog = 1000,
|
||||||
};
|
};
|
||||||
|
EXPORT_SYMBOL(net_hotdata);
|
||||||
|
@ -440,7 +440,7 @@ static struct ctl_table net_core_table[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.procname = "netdev_max_backlog",
|
.procname = "netdev_max_backlog",
|
||||||
.data = &netdev_max_backlog,
|
.data = &net_hotdata.max_backlog,
|
||||||
.maxlen = sizeof(int),
|
.maxlen = sizeof(int),
|
||||||
.mode = 0644,
|
.mode = 0644,
|
||||||
.proc_handler = proc_dointvec
|
.proc_handler = proc_dointvec
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#if IS_ENABLED(CONFIG_IPV6)
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
#include <net/ipv6_stubs.h>
|
#include <net/ipv6_stubs.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <net/hotdata.h>
|
||||||
|
|
||||||
static void handle_nonesp(struct espintcp_ctx *ctx, struct sk_buff *skb,
|
static void handle_nonesp(struct espintcp_ctx *ctx, struct sk_buff *skb,
|
||||||
struct sock *sk)
|
struct sock *sk)
|
||||||
@ -169,7 +170,8 @@ int espintcp_queue_out(struct sock *sk, struct sk_buff *skb)
|
|||||||
{
|
{
|
||||||
struct espintcp_ctx *ctx = espintcp_getctx(sk);
|
struct espintcp_ctx *ctx = espintcp_getctx(sk);
|
||||||
|
|
||||||
if (skb_queue_len(&ctx->out_queue) >= READ_ONCE(netdev_max_backlog))
|
if (skb_queue_len(&ctx->out_queue) >=
|
||||||
|
READ_ONCE(net_hotdata.max_backlog))
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
|
|
||||||
__skb_queue_tail(&ctx->out_queue, skb);
|
__skb_queue_tail(&ctx->out_queue, skb);
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <net/ip_tunnels.h>
|
#include <net/ip_tunnels.h>
|
||||||
#include <net/ip6_tunnel.h>
|
#include <net/ip6_tunnel.h>
|
||||||
#include <net/dst_metadata.h>
|
#include <net/dst_metadata.h>
|
||||||
|
#include <net/hotdata.h>
|
||||||
|
|
||||||
#include "xfrm_inout.h"
|
#include "xfrm_inout.h"
|
||||||
|
|
||||||
@ -764,7 +765,7 @@ int xfrm_trans_queue_net(struct net *net, struct sk_buff *skb,
|
|||||||
|
|
||||||
trans = this_cpu_ptr(&xfrm_trans_tasklet);
|
trans = this_cpu_ptr(&xfrm_trans_tasklet);
|
||||||
|
|
||||||
if (skb_queue_len(&trans->queue) >= READ_ONCE(netdev_max_backlog))
|
if (skb_queue_len(&trans->queue) >= READ_ONCE(net_hotdata.max_backlog))
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
|
|
||||||
BUILD_BUG_ON(sizeof(struct xfrm_trans_cb) > sizeof(skb->cb));
|
BUILD_BUG_ON(sizeof(struct xfrm_trans_cb) > sizeof(skb->cb));
|
||||||
|
Loading…
Reference in New Issue
Block a user