From: Alexander Duyck <alexander.duyck@gmail.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [next-queue v4 13/17] fm10k: Update adaptive ITR algorithm
Date: Thu, 15 Oct 2015 21:01:13 -0700 [thread overview]
Message-ID: <56207689.9070603@gmail.com> (raw)
In-Reply-To: <1444949681-14464-13-git-send-email-jacob.e.keller@intel.com>
On 10/15/2015 03:54 PM, Jacob Keller wrote:
> The existing adaptive ITR algorithm is overly restrictive. It throttles
> incorrectly for various traffic rates, and does not produce good
> performance. The algorithm now allows for more interrupts per second,
> and does some calculation to help improve for smaller packet loads. In
> addition, take into account the new itr_scale from the hardware which
> indicates how much to scale due to PCIe link speed.
>
> Reported-by: Matthew Vick <matthew.vick@intel.com>
> Reported-by: Alex Duyck <alexander.duyck@gmail.com>
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
> drivers/net/ethernet/intel/fm10k/fm10k.h | 1 +
> drivers/net/ethernet/intel/fm10k/fm10k_main.c | 52 ++++++++++++++++++++-------
> drivers/net/ethernet/intel/fm10k/fm10k_pci.c | 6 ++--
> 3 files changed, 45 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k.h b/drivers/net/ethernet/intel/fm10k/fm10k.h
> index a2484cb88d86..bdbb804a594f 100644
> --- a/drivers/net/ethernet/intel/fm10k/fm10k.h
> +++ b/drivers/net/ethernet/intel/fm10k/fm10k.h
> @@ -164,6 +164,7 @@ struct fm10k_ring_container {
> unsigned int total_packets; /* total packets processed this int */
> u16 work_limit; /* total work allowed per interrupt */
> u16 itr; /* interrupt throttle rate value */
> + u8 itr_scale; /* ITR adjustment scaler based on PCI speed */
> u8 count; /* total number of rings in vector */
> };
>
> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
> index 8207ee189600..8fd9a48433a0 100644
> --- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c
> +++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
> @@ -1367,7 +1367,7 @@ static bool fm10k_clean_tx_irq(struct fm10k_q_vector *q_vector,
> **/
> static void fm10k_update_itr(struct fm10k_ring_container *ring_container)
> {
> - unsigned int avg_wire_size, packets;
> + unsigned int avg_wire_size, packets, itr_round;
>
> /* Only update ITR if we are using adaptive setting */
> if (!ITR_IS_ADAPTIVE(ring_container->itr))
> @@ -1379,18 +1379,44 @@ static void fm10k_update_itr(struct fm10k_ring_container *ring_container)
>
> avg_wire_size = ring_container->total_bytes / packets;
>
> - /* Add 24 bytes to size to account for CRC, preamble, and gap */
> - avg_wire_size += 24;
> + /* The following is a crude approximation of:
> + * wmem_default / (size + overhead) = desired_pkts_per_int
> + * rate / bits_per_byte / (size + ethernet overhead) = pkt_rate
> + * (desired_pkt_rate / pkt_rate) * usecs_per_sec = ITR value
> + *
> + * Assuming wmem_default is 212992 and overhead is 640 bytes per
> + * packet, (256 skb, 64 headroom, 320 shared info), we can reduce the
> + * formula down to
> + *
> + * (34 * (size + 24)) / (size + 640) = ITR
> + *
> + * We first do some math on the packet size and then finally bitshift
> + * by 8 after rounding up. We also have to account for PCIe link speed
> + * difference as ITR scales based on this.
> + */
> + if (avg_wire_size <= 360) {
> + /* Start at 333K ints/sec and gradually drop to 77K ints/sec */
I was just rechecking the math on this and realized there was a rounding
error. This actually generates 250K interrupts per second at the peak,
not 333K. I basically had rounded down to 3 instead of up to 4 when I
calculated the value for 60 byte packets.
It's just the comment that needs to be changed. The algorithm itself
should still be good. I wouldn't have said anything but based on
Bruce's comment it looks like a v5 will probably be on the way so I
figured I would mention it.
- Alex
next prev parent reply other threads:[~2015-10-16 4:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-15 22:54 [Intel-wired-lan] [next-queue v4 01/17] fm10k: conditionally compile DCB and DebugFS support Jacob Keller
2015-10-15 22:54 ` [Intel-wired-lan] [next-queue v4 02/17] fm10k: set netdev features in one location Jacob Keller
2015-10-15 22:54 ` [Intel-wired-lan] [next-queue v4 03/17] fm10k: reset max_queues on init_hw_vf failure Jacob Keller
2015-10-15 22:54 ` [Intel-wired-lan] [next-queue v4 04/17] fm10k: always check init_hw for errors Jacob Keller
2015-10-15 22:54 ` [Intel-wired-lan] [next-queue v4 05/17] fm10k: reinitialize queuing scheme after calling init_hw Jacob Keller
2015-10-15 22:54 ` [Intel-wired-lan] [next-queue v4 06/17] fm10k: Correct typecast in fm10k_update_xc_addr_pf Jacob Keller
2015-10-15 22:54 ` [Intel-wired-lan] [next-queue v4 07/17] fm10k: explicitly typecast vlan values to u16 Jacob Keller
2015-10-15 22:54 ` [Intel-wired-lan] [next-queue v4 08/17] fm10k: add statistics for actual DWORD count of mbmem mailbox Jacob Keller
2015-10-15 22:54 ` [Intel-wired-lan] [next-queue v4 09/17] fm10k: rename mbx_tx_oversized statistic to mbx_tx_dropped Jacob Keller
2015-10-15 22:54 ` [Intel-wired-lan] [next-queue v4 10/17] fm10k: add TEB check to fm10k_gre_is_nvgre Jacob Keller
2015-10-15 22:54 ` [Intel-wired-lan] [next-queue v4 11/17] fm10k: Add support for ITR scaling based on PCIe link speed Jacob Keller
2015-10-15 22:54 ` [Intel-wired-lan] [next-queue v4 12/17] fm10k: introduce ITR_IS_ADAPTIVE macro Jacob Keller
2015-10-15 22:54 ` [Intel-wired-lan] [next-queue v4 13/17] fm10k: Update adaptive ITR algorithm Jacob Keller
2015-10-16 4:01 ` Alexander Duyck [this message]
2015-10-15 22:54 ` [Intel-wired-lan] [next-queue v4 14/17] fm10k: use macro for default Tx and Rx ITR values Jacob Keller
2015-10-15 22:54 ` [Intel-wired-lan] [next-queue v4 15/17] fm10k: change default Tx ITR to 25usec Jacob Keller
2015-10-15 22:54 ` [Intel-wired-lan] [next-queue v4 16/17] fm10k: TRIVIAL fix typo of hardware Jacob Keller
2015-10-15 22:54 ` [Intel-wired-lan] [next-queue v4 17/17] fm10k: TRIVIAL cleanup order at top of fm10k_xmit_frame Jacob Keller
2015-10-15 23:39 ` [Intel-wired-lan] [next-queue v4 01/17] fm10k: conditionally compile DCB and DebugFS support Allan, Bruce W
2015-10-16 17:50 ` Keller, Jacob E
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56207689.9070603@gmail.com \
--to=alexander.duyck@gmail.com \
--cc=intel-wired-lan@osuosl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.