RFS hardware acceleration (v3)
Subsystems (4)
cover RFS hardware acceleration (v3)
This patch series extends RFS to use hardware RX filters where available. Depending on the number of hardware RX queues and their IRQs' affinity, this should reduce the need for IPIs or at least get packets delivered to the right NUMA node.
The first patch implements IRQ affinity notifiers, based on the outline that Thomas Gleixner wrote in response to the previous version of this patch series. This has been updated based on Thomas's previous comments.
The second patch is a generalisation of the CPU affinity reverse- mapping, plus functions to maintain such a mapping based on the new IRQ affinity notifiers. This has been updated based on Eric Dumazet's comments.
The remaining patches add the RFS acceleration hooks and an implementation in the sfc driver. I have changed the sfc driver's strategy for reclaiming entries in the filter table entry from the previous version. The table can now be scanned at the end of each NAPI polling interval, based on the rate at which filters are being added. However, I haven't yet constructed a good test case that involves turnover of flows so I have yet to settle on a good strategy for this.
Ben.
Ben Hutchings (5):
genirq: Add IRQ affinity notifiers
lib: cpu_rmap: CPU affinity reverse-mapping
net: RPS: Enable hardware acceleration of RFS
sfc: Limit filter search depth further for performance hints (i.e.
RFS)
sfc: Implement hardware acceleration of RFS
drivers/net/sfc/efx.c | 49 ++++++++- drivers/net/sfc/efx.h | 16 +++ drivers/net/sfc/filter.c | 107 ++++++++++++++++- drivers/net/sfc/net_driver.h | 3 + include/linux/cpu_rmap.h | 73 ++++++++++++ include/linux/interrupt.h | 31 +++++ include/linux/irqdesc.h | 3 + include/linux/netdevice.h | 33 +++++- kernel/irq/manage.c | 82 +++++++++++++ lib/Kconfig | 4 + lib/Makefile | 2 + lib/cpu_rmap.c | 269 ++++++++++++++++++++++++++++++++++++++++++ net/Kconfig | 6 + net/core/dev.c | 97 ++++++++++++++- 14 files changed, 760 insertions(+), 15 deletions(-) create mode 100644 include/linux/cpu_rmap.h create mode 100644 lib/cpu_rmap.c
Signature · 7 lines
1.7.3.4 -- Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 1/5 genirq: Add IRQ affinity notifiers
When initiating I/O on a multiqueue and multi-IRQ device, we may want to select a queue for which the response will be handled on the same or a nearby CPU. This requires a reverse-map of IRQ affinity. Add a notification mechanism to support this.
This is based closely on work by Thomas Gleixner <[email protected]>.
---
Thomas, I hope this answers all your comments. If you are happy with this, can it go into net-next-2.6 so the rest of this series can get into 2.6.39?
Ben.
include/linux/interrupt.h | 31 +++++++++++++++++ include/linux/irqdesc.h | 3 ++ kernel/irq/manage.c | 82 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 0 deletions(-)
include/linux/interrupt.h +31 -0
@@ -14,6 +14,8 @@#include <linux/smp.h> #include <linux/percpu.h> #include <linux/hrtimer.h> +#include <linux/kref.h> +#include <linux/workqueue.h> #include <asm/atomic.h> #include <asm/ptrace.h>
@@ -240,6 +242,35 @@ extern int irq_can_set_affinity(unsigned int irq);extern int irq_select_affinity (unsigned int irq);extern int irq_set_affinity_hint (unsigned int irq,const struct cpumask *m); + +/** +* struct irq_affinity_notify - context for notification of IRQ affinity changes +* @irq: Interrupt to which notification applies +* @kref: Reference count, for internal use +* @work: Work item, for internal use +* @notify: Function to be called on change. This will be +* called in process context. +* @release: Function to be called on release. This will be +* called in process context. Once registered, the +* structure must only be freed when this function is +* called or later. +*/ +struct irq_affinity_notify { +unsigned int irq; +struct kref kref; +struct work_struct work; +void (*notify)(struct irq_affinity_notify *,const cpumask_t *mask); +void (*release)(struct kref *ref); +}; + +extern int +irq_set_affinity_notifier (unsigned int irq,struct irq_affinity_notify *notify); + +static inline void irq_run_affinity_notifiers (void ) +{ +flush_scheduled_work (); +} +#else /* CONFIG_SMP */ static inline int irq_set_affinity (unsigned int irq,const struct cpumask *m)
include/linux/irqdesc.h +3 -0
@@ -8,6 +8,7 @@* For now it's included from <linux/irq.h> */ +struct irq_affinity_notify ;struct proc_dir_entry ;struct timer_rand_state ;/**
@@ -24,6 +25,7 @@ struct timer_rand_state;* @last_unhandled: aging timer for unhandled count * @irqs_unhandled: stats field for spurious unhandled interrupts * @lock: locking for SMP +* @affinity_notify: context for notification of affinity changes * @pending_mask: pending rebalanced interrupts * @threads_active: number of irqaction threads currently running * @wait_for_threads: wait queue for sync_irq to wait for threaded handlers
@@ -70,6 +72,7 @@ struct irq_desc {raw_spinlock_t lock;#ifdef CONFIG_SMP const struct cpumask *affinity_hint; +struct irq_affinity_notify *affinity_notify;#ifdef CONFIG_GENERIC_PENDING_IRQ cpumask_var_t pending_mask;#endif
kernel/irq/manage.c +82 -0
100 lines not on this page · raw message
Signature · 8 lines
1.7.3.4 -- Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 2/5 lib: cpu_rmap: CPU affinity reverse-mapping
In reply to Ben HutchingsWhen initiating I/O on a multiqueue and multi-IRQ device, we may want to select a queue for which the response will be handled on the same or a nearby CPU. This requires a reverse-map of IRQ affinity. Add library functions to support a generic reverse-mapping from CPUs to objects with affinity and the specific case where the objects are IRQs.
--- include/linux/cpu_rmap.h | 73 +++++++++++++ lib/Kconfig | 4 + lib/Makefile | 2 + lib/cpu_rmap.c | 269 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 348 insertions(+), 0 deletions(-) create mode 100644 include/linux/cpu_rmap.h create mode 100644 lib/cpu_rmap.c
include/linux/cpu_rmap.h new file +73 -0
@@ -0,0 +1,73 @@ +/* +* cpu_rmap.c: CPU affinity reverse-map support +* Copyright 2011 Solarflare Communications Inc. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation, incorporated herein by reference. +*/ + +#include <linux/cpumask.h> +#include <linux/gfp.h> +#include <linux/slab.h> + +/** +* struct cpu_rmap - CPU affinity reverse-map +* @size: Number of objects to be reverse-mapped +* @used: Number of objects added +* @obj: Pointer to array of object pointers +* @near: For each CPU, the index and distance to the nearest object, +* based on affinity masks +*/ +struct cpu_rmap { +u16 size, used; +void **obj; +struct { +u16 index; +u16 dist; + } near[0 ]; +}; +#define CPU_RMAP_DIST_INF 0xffff + +extern struct cpu_rmap *alloc_cpu_rmap (unsigned int size,gfp_t flags); + +/** +* free_cpu_rmap - free CPU affinity reverse-map +* @rmap: Reverse-map allocated with alloc_cpu_rmap(), or %NULL +*/ +static inline void free_cpu_rmap (struct cpu_rmap *rmap) +{ +kfree (rmap); +} + +extern int cpu_rmap_add (struct cpu_rmap *rmap,void *obj); +extern int cpu_rmap_update (struct cpu_rmap *rmap,u16 index, +const struct cpumask *affinity); + +static inline u16 cpu_rmap_lookup_index (struct cpu_rmap *rmap,unsigned int cpu) +{ +return rmap->near[cpu].index; +} + +static inline void *cpu_rmap_lookup_obj (struct cpu_rmap *rmap,unsigned int cpu) +{ +return rmap->obj[rmap->near[cpu].index]; +} + +#ifdef CONFIG_GENERIC_HARDIRQS + +/** +* alloc_irq_cpu_rmap - allocate CPU affinity reverse-map for IRQs +* @size: Number of objects to be mapped +* +* Must be called in process context. +*/ +static inline struct cpu_rmap *alloc_irq_cpu_rmap (unsigned int size) +{ +return alloc_cpu_rmap (size,GFP_KERNEL ); +} +extern void free_irq_cpu_rmap (struct cpu_rmap *rmap); + +extern int irq_cpu_rmap_add (struct cpu_rmap *rmap,int irq); + +#endif
lib/Kconfig +4 -0
@@ -201,6 +201,10 @@ config DISABLE_OBSOLETE_CPUMASK_FUNCTIONS bool "Disable obsolete cpumask functions" if DEBUG_PER_CPU_MAPS depends on EXPERIMENTAL && BROKEN +config CPU_RMAP + bool + depends on SMP + # # Netlink attribute parsing support is select'ed if needed #
lib/Makefile +2 -0
@@ -110,6 +110,8 @@ obj-$(CONFIG_ATOMIC64_SELFTEST) += atomic64_test.o obj-$(CONFIG_AVERAGE) += average.o +obj-$(CONFIG_CPU_RMAP) += cpu_rmap.o + hostprogs-y := gen_crc32table clean-files := crc32table.h
lib/cpu_rmap.c new file +269 -0
269 lines not on this page · raw message
Signature · 8 lines
1.7.3.4 -- Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 3/5 net: RPS: Enable hardware acceleration of RFS
In reply to Ben HutchingsAllow drivers for multiqueue hardware with flow filter tables to accelerate RFS. The driver must:
1. Set net_device::rx_cpu_rmap to a cpu_rmap of the RX completion IRQs (in queue order). This will provide a mapping from CPUs to the queues for which completions are handled nearest to them.
2. Implement net_device_ops::ndo_rx_flow_steer. This operation adds or replaces a filter steering the given flow to the given RX queue, if possible.
3. Periodically remove filters for which rps_may_expire_flow() returns true.
--- include/linux/netdevice.h | 33 ++++++++++++++- net/Kconfig | 6 +++ net/core/dev.c | 97 ++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 127 insertions(+), 9 deletions(-)
include/linux/netdevice.h +30 -3
@@ -551,14 +551,16 @@ struct rps_map {#define RPS_MAP_SIZE (_num) (sizeof(struct rps_map) + (_num * sizeof(u16)))/* -* The rps_dev_flow structure contains the mapping of a flow to a CPU and the -* tail pointer for that CPU's input queue at the time of last enqueue. +* The rps_dev_flow structure contains the mapping of a flow to a CPU, the +* tail pointer for that CPU's input queue at the time of last enqueue, and +* a hardware filter index. */ struct rps_dev_flow {u16 cpu; -u16 fill; +u16 filter;unsigned int last_qtail; }; +#define RPS_NO_FILTER 0xffff/* * The rps_dev_flow_table structure contains a table of flow mappings.
@@ -608,6 +610,11 @@ static inline void rps_reset_sock_flow(struct rps_sock_flow_table *table,extern struct rps_sock_flow_table __rcu *rps_sock_flow_table; +#ifdef CONFIG_RFS_ACCEL +extern bool rps_may_expire_flow (struct net_device *dev,u16 rxq_index, +u32 flow_id,u16 filter_id); +#endif +/* This structure contains an instance of an RX queue. */ struct netdev_rx_queue {struct rps_map __rcu *rps_map;
@@ -753,6 +760,13 @@ struct xps_dev_maps {* int (*ndo_set_vf_port)(struct net_device *dev, int vf, * struct nlattr *port[]); * int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb); +* +* RFS acceleration. +* int (*ndo_rx_flow_steer)(struct net_device *dev, const struct sk_buff *skb, +* u16 rxq_index, u32 flow_id); +* Set hardware filter for RFS. rxq_index is the target queue index; +* flow_id is a flow ID to be passed to rps_may_expire_flow() later. +* Return the filter ID on success, or a negative error code. */ #define HAVE_NET_DEVICE_OPS struct net_device_ops {
@@ -825,6 +839,12 @@ struct net_device_ops {int (*ndo_fcoe_get_wwn)(struct net_device *dev,u64 *wwn,int type);#endif +#ifdef CONFIG_RFS_ACCEL +int (*ndo_rx_flow_steer)(struct net_device *dev, +const struct sk_buff *skb, +u16 rxq_index, +u32 flow_id); +#endif };/*
@@ -1039,6 +1059,13 @@ struct net_device {/* Number of RX queues currently active in device */ unsigned int real_num_rx_queues; + +#ifdef CONFIG_RFS_ACCEL +/* CPU reverse-mapping for RX completion interrupts, indexed +* by RX queue number. Assigned by driver. This must only be +* set if the ndo_rx_flow_steer operation is defined. */ +struct cpu_rmap *rx_cpu_rmap; +#endif #endif rx_handler_func_t __rcu *rx_handler;
net/Kconfig +6 -0
@@ -221,6 +221,12 @@ config RPS depends on SMP && SYSFS && USE_GENERIC_SMP_HELPERS default y +config RFS_ACCEL + boolean + depends on RPS && GENERIC_HARDIRQS + select CPU_RMAP + default y + config XPS boolean depends on SMP && SYSFS && USE_GENERIC_SMP_HELPERS
net/core/dev.c +91 -6
121 lines not on this page · raw message
Signature · 8 lines
1.7.3.4 -- Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 4/5 sfc: Limit filter search depth further for performance hints (i.e. RFS)
In reply to Ben Hutchings---
I consider this experimental still; so it's not signed-off.
Ben.
drivers/net/sfc/filter.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)
drivers/net/sfc/filter.c +9 -4
@@ -27,6 +27,10 @@*/ #define FILTER_CTL_SRCH_MAX 200 +/* Don't try very hard to find space for performance hints, as this is +* counter-productive. */ +#define FILTER_CTL_SRCH_HINT_MAX 5 +enum efx_filter_table_id {EFX_FILTER_TABLE_RX_IP =0 ,EFX_FILTER_TABLE_RX_MAC ,
@@ -325,15 +329,16 @@ static int efx_filter_search(struct efx_filter_table *table, struct efx_filter_spec *spec, u32 key, bool for_insert, int *depth_required) { - unsigned hash, incr, filter_idx, depth; + unsigned hash, incr, filter_idx, depth, depth_max;struct efx_filter_spec *cmp; hash =efx_filter_hash (key); incr =efx_filter_increment (key); + depth_max = (spec->priority <=EFX_FILTER_PRI_HINT ? +FILTER_CTL_SRCH_HINT_MAX :FILTER_CTL_SRCH_MAX );for (depth =1 , filter_idx = hash & (table->size -1 ); - depth <=FILTER_CTL_SRCH_MAX && -test_bit (filter_idx, table->used_bitmap); + depth <= depth_max &&test_bit (filter_idx, table->used_bitmap); ++depth) { cmp = &table->spec[filter_idx];if (efx_filter_equal (spec, cmp))
@@ -342,7 +347,7 @@ static int efx_filter_search(struct efx_filter_table *table, }if (!for_insert)return -ENOENT ; -if (depth >FILTER_CTL_SRCH_MAX ) +if (depth > depth_max)return -EBUSY ; found: *depth_required = depth;
Signature · 8 lines
1.7.3.4 -- Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 5/5 sfc: Implement hardware acceleration of RFS
In reply to Ben Hutchings---
I consider this experimental still, so it's not signed-off.
Ben.
drivers/net/sfc/efx.c | 49 +++++++++++++++++++++- drivers/net/sfc/efx.h | 16 +++++++ drivers/net/sfc/filter.c | 94 ++++++++++++++++++++++++++++++++++++++++++ drivers/net/sfc/net_driver.h | 3 + 4 files changed, 160 insertions(+), 2 deletions(-)
drivers/net/sfc/efx.c +47 -2
@@ -21,6 +21,7 @@#include <linux/ethtool.h> #include <linux/topology.h> #include <linux/gfp.h> +#include <linux/cpu_rmap.h> #include "net_driver.h" #include "efx.h" #include "nic.h"
@@ -307,6 +308,8 @@ static int efx_poll(struct napi_struct *napi, int budget) channel->irq_mod_score =0 ; } +efx_filter_rfs_expire (channel); +/* There is no race here; although napi_disable() will * only wait for napi_complete(), this isn't a problem * since efx_channel_processed() will have no effect if
@@ -1175,10 +1178,32 @@ static int efx_wanted_channels(void)return count; } +static int +efx_init_rx_cpu_rmap (struct efx_nic *efx,struct msix_entry *xentries) +{ +#ifdef CONFIG_RFS_ACCEL +int i, rc; + + efx->net_dev->rx_cpu_rmap =alloc_irq_cpu_rmap (efx->n_rx_channels); +if (!efx->net_dev->rx_cpu_rmap) +return -ENOMEM ; +for (i =0 ; i < efx->n_rx_channels; i++) { + rc =irq_cpu_rmap_add (efx->net_dev->rx_cpu_rmap, + xentries[i].vector); +if (rc) { +free_irq_cpu_rmap (efx->net_dev->rx_cpu_rmap); + efx->net_dev->rx_cpu_rmap =NULL ; +return rc; + } + } +#endif +return 0 ; +} +/* Probe the number and type of interrupts we are able to obtain, and * the resulting numbers of channels and RX queues. */ -static void efx_probe_interrupts (struct efx_nic *efx) +static int efx_probe_interrupts (struct efx_nic *efx) {int max_channels =min_t (int, efx->type->phys_addr_channels,EFX_MAX_CHANNELS );
@@ -1220,6 +1245,11 @@ static void efx_probe_interrupts(struct efx_nic *efx) efx->n_tx_channels = efx->n_channels; efx->n_rx_channels = efx->n_channels; } + rc =efx_init_rx_cpu_rmap (efx, xentries); +if (rc) { +pci_disable_msix (efx->pci_dev); +return rc; + }for (i =0 ; i < n_channels; i++)efx_get_channel (efx, i)->irq = xentries[i].vector;
@@ -1253,6 +1283,8 @@ static void efx_probe_interrupts(struct efx_nic *efx) efx->n_tx_channels =1 ; efx->legacy_irq = efx->pci_dev->irq; } + +return 0 ; }static void efx_remove_interrupts (struct efx_nic *efx)
@@ -1302,7 +1334,9 @@ static int efx_probe_nic(struct efx_nic *efx)/* Determine the number of channels and queues by trying to hook * in MSI-X interrupts. */ -efx_probe_interrupts (efx); + rc =efx_probe_interrupts (efx); +if (rc) + goto fail;if (efx->n_channels >1 )get_random_bytes (&efx->rx_hash_key,sizeof (efx->rx_hash_key));
@@ -1317,6 +1351,10 @@ static int efx_probe_nic(struct efx_nic *efx)efx_init_irq_moderation (efx, tx_irq_mod_usec, rx_irq_mod_usec, true);return 0 ; + +fail: + efx->type->remove (efx); +return rc; }static void efx_remove_nic (struct efx_nic *efx)
@@ -1849,6 +1887,9 @@ static const struct net_device_ops efx_netdev_ops = {#ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = efx_netpoll,#endif +#ifdef CONFIG_RFS_ACCEL + .ndo_rx_flow_steer = efx_filter_rfs, +#endif };static void efx_update_name (struct efx_nic *efx)
@@ -2288,6 +2329,10 @@ static void efx_fini_struct(struct efx_nic *efx)*/ static void efx_pci_remove_main (struct efx_nic *efx) { +#ifdef CONFIG_RFS_ACCEL +free_irq_cpu_rmap (efx->net_dev->rx_cpu_rmap); + efx->net_dev->rx_cpu_rmap =NULL ; +#endif efx_nic_fini_interrupt (efx);efx_fini_channels (efx);efx_fini_port (efx);
drivers/net/sfc/efx.h +16 -0
@@ -74,6 +74,22 @@ extern int efx_filter_remove_filter(struct efx_nic *efx, struct efx_filter_spec *spec);extern void efx_filter_clear_rx (struct efx_nic *efx,enum efx_filter_priority priority); +#ifdef CONFIG_RFS_ACCEL +extern int efx_filter_rfs (struct net_device *net_dev,const struct sk_buff *skb, +u16 rxq_index,u32 flow_id); +extern unsigned __efx_filter_rfs_expire (struct efx_nic *efx,unsigned quota); +static inline void efx_filter_rfs_expire (struct efx_channel *channel) +{ +if (channel->rfs_filters_added >=100 ) { + channel->rfs_filters_added -= +__efx_filter_rfs_expire (channel->efx,100 ); + } +} +#define efx_filter_rfs_enabled () 1 +#else +static inline void efx_filter_rfs_expire (struct efx_channel *channel) {} +#define efx_filter_rfs_enabled () 0 +#endif /* Channels */ extern void efx_process_channel_now (struct efx_channel *channel);
drivers/net/sfc/filter.c +94 -0
117 lines not on this page · raw message
drivers/net/sfc/net_driver.h +3 -0
@@ -358,6 +358,9 @@ struct efx_channel {unsigned int irq_count;unsigned int irq_mod_score; +#ifdef CONFIG_RFS_ACCEL +unsigned int rfs_filters_added; +#endif int rx_alloc_level;int rx_alloc_push_pages;
Signature · 7 lines
1.7.3.4 -- Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Re: [PATCH net-next-2.6 1/5] genirq: Add IRQ affinity notifiers
In reply to Ben HutchingsQuoted 5 lines · Ben Hutchings
When initiating I/O on a multiqueue and multi-IRQ device, we may want to select a queue for which the response will be handled on the same or a nearby CPU. This requires a reverse-map of IRQ affinity. Add a notification mechanism to support this.
Quoted 7 lines
This is based closely on work by Thomas Gleixner <[email protected]>.
Signed-off-by Ben Hutchings <[email protected]>---
Thomas, I hope this answers all your comments. If you are happy with this, can it go into net-next-2.6 so the rest of this series can get into 2.6.39?
Looks good, but I prefer to take it via the tip/genirq branch as I have other changes pending to that code. I'll put this into a separate branch based on rc1 as a single commit so Dave can pull that branch into netdev. Dave ?
Thanks,
tglx
David Miller
maintainerRe: [PATCH net-next-2.6 1/5] genirq: Add IRQ affinity notifiers
From: Thomas Gleixner <[email protected]>
Date: Wed, 19 Jan 2011 22:19:04 +0100 (CET)
Quoted 15 lines
Quoted 5 lines · Ben Hutchings
When initiating I/O on a multiqueue and multi-IRQ device, we may want to select a queue for which the response will be handled on the same or a nearby CPU. This requires a reverse-map of IRQ affinity. Add a notification mechanism to support this.
Quoted 7 lines
This is based closely on work by Thomas Gleixner <[email protected]>.
Signed-off-by Ben Hutchings <[email protected]>---
Thomas, I hope this answers all your comments. If you are happy with this, can it go into net-next-2.6 so the rest of this series can get into 2.6.39?
Quoted 4 lines
Looks good, but I prefer to take it via the tip/genirq branch as I have other changes pending to that code. I'll put this into a separate branch based on rc1 as a single commit so Dave can pull that branch into netdev. Dave ?
But if you do that what happens down the line when Linus pulls our trees in?
If he takes your tip/genirq first, I have merge hassles to deal with.
If he takes the -rc1 relative version I end up with, you'll have the merge hassles.
Re: [PATCH net-next-2.6 1/5] genirq: Add IRQ affinity notifiers
Quoted 23 lines · David Miller
From: Thomas Gleixner <[email protected]>
Date: Wed, 19 Jan 2011 22:19:04 +0100 (CET)Quoted 15 lines
Quoted 5 lines · Ben Hutchings
When initiating I/O on a multiqueue and multi-IRQ device, we may want to select a queue for which the response will be handled on the same or a nearby CPU. This requires a reverse-map of IRQ affinity. Add a notification mechanism to support this.
Quoted 7 lines
This is based closely on work by Thomas Gleixner <[email protected]>.
Signed-off-by Ben Hutchings <[email protected]>---
Thomas, I hope this answers all your comments. If you are happy with this, can it go into net-next-2.6 so the rest of this series can get into 2.6.39?Quoted 4 lines
Looks good, but I prefer to take it via the tip/genirq branch as I have other changes pending to that code. I'll put this into a separate branch based on rc1 as a single commit so Dave can pull that branch into netdev. Dave ?
Quoted 7 lines
But if you do that what happens down the line when Linus pulls our trees in?
If he takes your tip/genirq first, I have merge hassles to deal with.
If he takes the -rc1 relative version I end up with, you'll have the merge hassles.
Nothing will happen and no hassels at all, because your tree and my tree have the exact same commit with the exact same sha1. You don't have further changes in your tree which touch genirq stuff and I don't have anything which touches net.
Thanks,
tglx
David Miller
maintainerRe: [PATCH net-next-2.6 1/5] genirq: Add IRQ affinity notifiers
From: Thomas Gleixner <[email protected]>
Date: Wed, 19 Jan 2011 22:39:04 +0100 (CET)
Quoted 29 lines · David Miller
Quoted 28 lines
From: Thomas Gleixner <[email protected]>
Date: Wed, 19 Jan 2011 22:19:04 +0100 (CET)Quoted 15 lines
Quoted 5 lines · Ben Hutchings
When initiating I/O on a multiqueue and multi-IRQ device, we may want to select a queue for which the response will be handled on the same or a nearby CPU. This requires a reverse-map of IRQ affinity. Add a notification mechanism to support this.
Quoted 7 lines
This is based closely on work by Thomas Gleixner <[email protected]>.
Signed-off-by Ben Hutchings <[email protected]>---
Thomas, I hope this answers all your comments. If you are happy with this, can it go into net-next-2.6 so the rest of this series can get into 2.6.39?Quoted 4 lines
Looks good, but I prefer to take it via the tip/genirq branch as I have other changes pending to that code. I'll put this into a separate branch based on rc1 as a single commit so Dave can pull that branch into netdev. Dave ?
But if you do that what happens down the line when Linus pulls our trees in?
If he takes your tip/genirq first, I have merge hassles to deal with.
Quoted 7 lines
Quoted 2 lines
If he takes the -rc1 relative version I end up with, you'll have the merge hassles.
Nothing will happen and no hassels at all, because your tree and my tree have the exact same commit with the exact same sha1. You don't have further changes in your tree which touch genirq stuff and I don't have anything which touches net.
You said you had stuff before Ben's patches, and that's why you needed to provide me with an -rc1 relative version of his commits.
If that's not the case, then yes it would work just fine.
Just give me the URL to pull from, thanks!
Re: [PATCH net-next-2.6 1/5] genirq: Add IRQ affinity notifiers
Quoted 9 lines · David Miller
From: Thomas Gleixner <[email protected]>
Date: Wed, 19 Jan 2011 22:39:04 +0100 (CET)Quoted 4 lines
Nothing will happen and no hassels at all, because your tree and my tree have the exact same commit with the exact same sha1. You don't have further changes in your tree which touch genirq stuff and I don't have anything which touches net.
You said you had stuff before Ben's patches, and that's why you needed to provide me with an -rc1 relative version of his commits.
Sorry, I meant other stuff pending (not yet applied) which will interfere with that patch. And even if I would have pending patches in git already it would not matter:
tip/irq/core some stuff based on whatever
tip/irq/for-net single patch based on rc1
tip/irq/core merges tip/irq/for-net _before_ offering it to Linus
You pull tip/irq/for-net and nothing breaks :)
Quoted 3 lines
If that's not the case, then yes it would work just fine.
Just give me the URL to pull from, thanks!
Will do, give me a day or two !
Thanks,
tglx
[tip:irq/numa] genirq: Add IRQ affinity notifiers
In reply to Ben HutchingsCommit-ID: cd7eab44e9946c28d595abe3e9a43e945bc49141 Gitweb: http://git.kernel.org/tip/cd7eab44e9946c28d595abe3e9a43e945bc49141 Author: Ben Hutchings <[email protected]> AuthorDate: Wed, 19 Jan 2011 21:01:44 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Sat, 22 Jan 2011 17:34:25 +0100
genirq: Add IRQ affinity notifiers
When initiating I/O on a multiqueue and multi-IRQ device, we may want to select a queue for which the response will be handled on the same or a nearby CPU. This requires a reverse-map of IRQ affinity. Add a notification mechanism to support this.
This is based closely on work by Thomas Gleixner <[email protected]>.
LKML-Reference: <1295470904.11126.84.camel@bwh-desktop>
--- include/linux/interrupt.h | 33 +++++++++++++++++- include/linux/irqdesc.h | 3 ++ kernel/irq/manage.c | 82 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 1 deletions(-)
include/linux/interrupt.h +32 -1
@@ -14,6 +14,8 @@#include <linux/smp.h> #include <linux/percpu.h> #include <linux/hrtimer.h> +#include <linux/kref.h> +#include <linux/workqueue.h> #include <asm/atomic.h> #include <asm/ptrace.h>
@@ -240,6 +242,35 @@ extern int irq_can_set_affinity(unsigned int irq);extern int irq_select_affinity (unsigned int irq);extern int irq_set_affinity_hint (unsigned int irq,const struct cpumask *m); + +/** +* struct irq_affinity_notify - context for notification of IRQ affinity changes +* @irq: Interrupt to which notification applies +* @kref: Reference count, for internal use +* @work: Work item, for internal use +* @notify: Function to be called on change. This will be +* called in process context. +* @release: Function to be called on release. This will be +* called in process context. Once registered, the +* structure must only be freed when this function is +* called or later. +*/ +struct irq_affinity_notify { +unsigned int irq; +struct kref kref; +struct work_struct work; +void (*notify)(struct irq_affinity_notify *,const cpumask_t *mask); +void (*release)(struct kref *ref); +}; + +extern int +irq_set_affinity_notifier (unsigned int irq,struct irq_affinity_notify *notify); + +static inline void irq_run_affinity_notifiers (void ) +{ +flush_scheduled_work (); +} +#else /* CONFIG_SMP */ static inline int irq_set_affinity (unsigned int irq,const struct cpumask *m)
@@ -255,7 +286,7 @@ static inline int irq_can_set_affinity(unsigned int irq)static inline int irq_select_affinity (unsigned int irq) {return 0 ; }static inline int irq_set_affinity_hint (unsigned int irq, -const struct cpumask *m) +const struct cpumask *m) {return -EINVAL ; }
include/linux/irqdesc.h +3 -0
@@ -8,6 +8,7 @@* For now it's included from <linux/irq.h> */ +struct irq_affinity_notify ;struct proc_dir_entry ;struct timer_rand_state ;/**
@@ -24,6 +25,7 @@ struct timer_rand_state;* @last_unhandled: aging timer for unhandled count * @irqs_unhandled: stats field for spurious unhandled interrupts * @lock: locking for SMP +* @affinity_notify: context for notification of affinity changes * @pending_mask: pending rebalanced interrupts * @threads_active: number of irqaction threads currently running * @wait_for_threads: wait queue for sync_irq to wait for threaded handlers
@@ -70,6 +72,7 @@ struct irq_desc {raw_spinlock_t lock;#ifdef CONFIG_SMP const struct cpumask *affinity_hint; +struct irq_affinity_notify *affinity_notify;#ifdef CONFIG_GENERIC_PENDING_IRQ cpumask_var_t pending_mask;#endif
kernel/irq/manage.c +82 -0
100 lines not on this page · raw message
Re: [PATCH net-next-2.6 1/5] genirq: Add IRQ affinity notifiers
In reply to David MillerQuoted 2 lines · David Miller
You said you had stuff before Ben's patches, and that's why you needed to provide me with an -rc1 relative version of his commits.
I hope a rc2 relative version works as well :)
Quoted 3 lines
If that's not the case, then yes it would work just fine.
Just give me the URL to pull from, thanks!
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git irq/numa
@Ben: Your patch was pretty white space damaged. Please be more careful next time.
Thanks,
tglx
David Miller
maintainerRe: [PATCH net-next-2.6 1/5] genirq: Add IRQ affinity notifiers
In reply to Ben HutchingsFrom: Ben Hutchings <[email protected]>
Date: Wed, 19 Jan 2011 21:01:44 +0000
Quoted 5 lines
When initiating I/O on a multiqueue and multi-IRQ device, we may want to select a queue for which the response will be handled on the same or a nearby CPU. This requires a reverse-map of IRQ affinity. Add a notification mechanism to support this.
Quoted 7 lines
This is based closely on work by Thomas Gleixner <[email protected]>.
Signed-off-by Ben Hutchings <[email protected]>---
Thomas, I hope this answers all your comments. If you are happy with this, can it go into net-next-2.6 so the rest of this series can get into 2.6.39?
I've pulled from Thomas's tree to get this commit into net-next-2.6, thanks.
Re: [PATCH net-next-2.6 2/5] lib: cpu_rmap: CPU affinity reverse-mapping
In reply to Ben HutchingsFrom: Ben Hutchings <[email protected]>
Date: Wed, 19 Jan 2011 21:03:25 +0000
Quoted 8 lines
When initiating I/O on a multiqueue and multi-IRQ device, we may want to select a queue for which the response will be handled on the same or a nearby CPU. This requires a reverse-map of IRQ affinity. Add library functions to support a generic reverse-mapping from CPUs to objects with affinity and the specific case where the objects are IRQs.
Signed-off-by Ben Hutchings <[email protected]>
Applied.
Re: [PATCH net-next-2.6 3/5] net: RPS: Enable hardware acceleration of RFS
In reply to Ben HutchingsFrom: Ben Hutchings <[email protected]>
Date: Wed, 19 Jan 2011 21:03:53 +0000
Quoted 7 lines
Allow drivers for multiqueue hardware with flow filter tables to accelerate RFS. The driver must:
1. Set
net_device::rx_cpu_rmapto acpu_rmapof the RX completion IRQs (in queue order). This will provide a mapping from CPUs to the queues for which completions are handled nearest to them.
Quoted 8 lines
2. Implement
net_device_ops::ndo_rx_flow_steer. This operation adds or replaces a filter steering the given flow to the given RX queue, if possible.3. Periodically remove filters for which
rps_may_expire_flow()returns true.Signed-off-by Ben Hutchings <[email protected]>
Applied.
David Miller
maintainerRe: [PATCH net-next-2.6 4/5] sfc: Limit filter search depth further for performance hints (i.e. RFS)
In reply to Ben HutchingsPlease resubmit #4 and #5 when you are confident enough to sign off on them, then I'll add them to net-next-2.6
Thanks.
Re: [PATCH net-next-2.6 1/5] genirq: Add IRQ affinity notifiers
In reply to Thomas GleixnerQuoted 6 lines · Thomas Gleixner
Quoted 2 lines · David Miller
You said you had stuff before Ben's patches, and that's why you needed to provide me with an -rc1 relative version of his commits.
I hope a rc2 relative version works as well :)
Quoted 8 lines
Quoted 3 lines
If that's not the case, then yes it would work just fine.
Just give me the URL to pull from, thanks!
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.gitirq/numa@Ben: Your patch was pretty white space damaged. Please be more careful next time.
Oh, I see that struct irq_affinity_notify members were indented with spaces; is that what you mean? Sorry, I've no idea how that happened.
Anyway, thanks for applying this.
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.