Commit 5dc51ec8 authored by Martin Karsten's avatar Martin Karsten Committed by Jakub Kicinski
Browse files

net: Add napi_struct parameter irq_suspend_timeout



Add a per-NAPI IRQ suspension parameter, which can be get/set with
netdev-genl.

This patch doesn't change any behavior but prepares the code for other
changes in the following commits which use irq_suspend_timeout as a
timeout for IRQ suspension.

Signed-off-by: default avatarMartin Karsten <mkarsten@uwaterloo.ca>
Co-developed-by: default avatarJoe Damato <jdamato@fastly.com>
Signed-off-by: default avatarJoe Damato <jdamato@fastly.com>
Tested-by: default avatarJoe Damato <jdamato@fastly.com>
Tested-by: default avatarMartin Karsten <mkarsten@uwaterloo.ca>
Acked-by: default avatarStanislav Fomichev <sdf@fomichev.me>
Reviewed-by: default avatarSridhar Samudrala <sridhar.samudrala@intel.com>
Link: https://patch.msgid.link/20241109050245.191288-2-jdamato@fastly.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent f0fe51a0
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -263,6 +263,11 @@ attribute-sets:
             the end of a NAPI cycle. This may add receive latency in exchange
             for reducing the number of frames processed by the network stack.
        type: uint
      -
        name: irq-suspend-timeout
        doc: The timeout, in nanoseconds, of how long to suspend irq
             processing, if event polling finds events
        type: uint
  -
    name: queue
    attributes:
@@ -653,6 +658,7 @@ operations:
            - pid
            - defer-hard-irqs
            - gro-flush-timeout
            - irq-suspend-timeout
      dump:
        request:
          attributes:
@@ -704,6 +710,7 @@ operations:
            - id
            - defer-hard-irqs
            - gro-flush-timeout
            - irq-suspend-timeout

kernel-family:
  headers: [ "linux/list.h"]
+2 −0
Original line number Diff line number Diff line
@@ -348,6 +348,7 @@ struct gro_list {
 */
struct napi_config {
	u64 gro_flush_timeout;
	u64 irq_suspend_timeout;
	u32 defer_hard_irqs;
	unsigned int napi_id;
};
@@ -384,6 +385,7 @@ struct napi_struct {
	struct hrtimer		timer;
	struct task_struct	*thread;
	unsigned long		gro_flush_timeout;
	unsigned long		irq_suspend_timeout;
	u32			defer_hard_irqs;
	/* control-path-only fields follow */
	struct list_head	dev_list;
+1 −0
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ enum {
	NETDEV_A_NAPI_PID,
	NETDEV_A_NAPI_DEFER_HARD_IRQS,
	NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT,
	NETDEV_A_NAPI_IRQ_SUSPEND_TIMEOUT,

	__NETDEV_A_NAPI_MAX,
	NETDEV_A_NAPI_MAX = (__NETDEV_A_NAPI_MAX - 1)
+2 −0
Original line number Diff line number Diff line
@@ -6666,6 +6666,7 @@ static void napi_restore_config(struct napi_struct *n)
{
	n->defer_hard_irqs = n->config->defer_hard_irqs;
	n->gro_flush_timeout = n->config->gro_flush_timeout;
	n->irq_suspend_timeout = n->config->irq_suspend_timeout;
	/* a NAPI ID might be stored in the config, if so use it. if not, use
	 * napi_hash_add to generate one for us. It will be saved to the config
	 * in napi_disable.
@@ -6680,6 +6681,7 @@ static void napi_save_config(struct napi_struct *n)
{
	n->config->defer_hard_irqs = n->defer_hard_irqs;
	n->config->gro_flush_timeout = n->gro_flush_timeout;
	n->config->irq_suspend_timeout = n->irq_suspend_timeout;
	n->config->napi_id = n->napi_id;
	napi_hash_del(n);
}
+25 −0
Original line number Diff line number Diff line
@@ -236,6 +236,31 @@ static inline void netdev_set_gro_flush_timeout(struct net_device *netdev,
		netdev->napi_config[i].gro_flush_timeout = timeout;
}

/**
 * napi_get_irq_suspend_timeout - get the irq_suspend_timeout
 * @n: napi struct to get the irq_suspend_timeout from
 *
 * Return: the per-NAPI value of the irq_suspend_timeout field.
 */
static inline unsigned long
napi_get_irq_suspend_timeout(const struct napi_struct *n)
{
	return READ_ONCE(n->irq_suspend_timeout);
}

/**
 * napi_set_irq_suspend_timeout - set the irq_suspend_timeout for a napi
 * @n: napi struct to set the irq_suspend_timeout
 * @timeout: timeout value to set
 *
 * napi_set_irq_suspend_timeout sets the per-NAPI irq_suspend_timeout
 */
static inline void napi_set_irq_suspend_timeout(struct napi_struct *n,
						unsigned long timeout)
{
	WRITE_ONCE(n->irq_suspend_timeout, timeout);
}

int rps_cpumask_housekeeping(struct cpumask *mask);

#if defined(CONFIG_DEBUG_NET) && defined(CONFIG_BPF_SYSCALL)
Loading