From: Akihiko Odaki <akihiko.odaki@daynix.com>
To: Nicholas Piggin <npiggin@gmail.com>, qemu-devel@nongnu.org
Cc: Dmitry Fleytman <dmitry.fleytman@gmail.com>,
Jason Wang <jasowang@redhat.com>,
Sriram Yagnaraman <sriram.yagnaraman@ericsson.com>,
Fabiano Rosas <farosas@suse.de>,
Laurent Vivier <lvivier@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 6/9] net/e1000e|igb: Fix interrupt throttling logic
Date: Sat, 18 Jan 2025 18:50:41 +0900 [thread overview]
Message-ID: <6bd93213-8b6a-4f14-a209-f2c3dca1a6c5@daynix.com> (raw)
In-Reply-To: <20250117170306.403075-7-npiggin@gmail.com>
On 2025/01/18 2:03, Nicholas Piggin wrote:
> Interrupt throttling is broken in several ways:
> - Timer expiry sends an interrupt even if there is no cause.
> - Timer expiry that results in an interrupt does not re-arm
> the timer so an interrupt can appear immediately after the
> timer expiry interrupt.
> - Interrupt auto-clear should not clear cause if an interrupt
> is delayed by throttling.
>
> Fix these by skipping the auto-clear logic if an interrupt is
> delayed, and when the throttle timer expires check the cause
> bits corresponding to the msix vector before sending an irq,
> and send it using the functions that run the throttling state
> machine and perform auto-clear.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> hw/net/e1000e_core.c | 60 +++++++++++++++++++++++++++++++++++++++-----
> hw/net/igb_core.c | 28 +++++++++++++--------
> 2 files changed, 72 insertions(+), 16 deletions(-)
>
> diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
> index e32955d244b..c5be20bcbbe 100644
> --- a/hw/net/e1000e_core.c
> +++ b/hw/net/e1000e_core.c
> @@ -168,16 +168,63 @@ e1000e_intrmgr_on_throttling_timer(void *opaque)
> }
> }
>
> +/* Find causes from IVAR vectors and only interrupt if causes are set */
This comment is misplaced as find_msix_causes() is just to find causes
and will not cause an interrupt by its own.
The function name is descriptive enough and the comment is a bit
redundant so I suggest simply removing it.
> +static uint32_t find_msix_causes(E1000ECore *core, int vec)
> +{> + uint32_t causes = 0;
> + uint32_t int_cfg;
> +
> + int_cfg = E1000_IVAR_RXQ0(core->mac[IVAR]);
> + if (E1000_IVAR_ENTRY_VALID(int_cfg) &&
> + E1000_IVAR_ENTRY_VEC(int_cfg) == vec) {
> + causes |= E1000_ICR_RXQ0;
> + }
> +
> + int_cfg = E1000_IVAR_RXQ1(core->mac[IVAR]);
> + if (E1000_IVAR_ENTRY_VALID(int_cfg) &&
> + E1000_IVAR_ENTRY_VEC(int_cfg) == vec) {
> + causes |= E1000_ICR_RXQ1;
> + }
> +
> + int_cfg = E1000_IVAR_TXQ0(core->mac[IVAR]);
> + if (E1000_IVAR_ENTRY_VALID(int_cfg) &&
> + E1000_IVAR_ENTRY_VEC(int_cfg) == vec) {
> + causes |= E1000_ICR_TXQ0;
> + }
> +
> + int_cfg = E1000_IVAR_TXQ1(core->mac[IVAR]);
> + if (E1000_IVAR_ENTRY_VALID(int_cfg) &&
> + E1000_IVAR_ENTRY_VEC(int_cfg) == vec) {
> + causes |= E1000_ICR_TXQ1;
> + }
> +
> + int_cfg = E1000_IVAR_OTHER(core->mac[IVAR]);
> + if (E1000_IVAR_ENTRY_VALID(int_cfg) &&
> + E1000_IVAR_ENTRY_VEC(int_cfg) == vec) {
> + causes |= E1000_ICR_OTHER;
> + }
> +
> + return causes;
> +}
> +
> +static void
> +e1000e_msix_notify(E1000ECore *core, uint32_t causes);
> +
> static void
> e1000e_intrmgr_on_msix_throttling_timer(void *opaque)
> {
> E1000IntrDelayTimer *timer = opaque;
> - int idx = timer - &timer->core->eitr[0];
> + E1000ECore *core = timer->core;
> + int idx = timer - &core->eitr[0];
> + uint32_t causes;
>
> timer->running = false;
>
> - trace_e1000e_irq_msix_notify_postponed_vec(idx);
> - msix_notify(timer->core->owner, idx);
> + causes = find_msix_causes(core, idx);
> + if (core->mac[IMS] & core->mac[ICR] & causes) {
To raise only pending interrupts, I think you should do:
causes = core->mac[IMS] & core->mac[ICR] & find_msix_causes(core, idx);
if (causes) {
> + trace_e1000e_irq_msix_notify_postponed_vec(idx);
> + e1000e_msix_notify(core, causes);
> + }
> }
>
> static void
> @@ -1982,10 +2029,11 @@ e1000e_msix_notify_one(E1000ECore *core, uint32_t cause, uint32_t int_cfg)
> if (E1000_IVAR_ENTRY_VALID(int_cfg)) {
> uint32_t vec = E1000_IVAR_ENTRY_VEC(int_cfg);
> if (vec < E1000E_MSIX_VEC_NUM) {
> - if (!e1000e_eitr_should_postpone(core, vec)) {
> - trace_e1000e_irq_msix_notify_vec(vec);
> - msix_notify(core->owner, vec);
> + if (e1000e_eitr_should_postpone(core, vec)) {
> + return;
> }
> + trace_e1000e_irq_msix_notify_vec(vec);
> + msix_notify(core->owner, vec);
> } else {
> trace_e1000e_wrn_msix_vec_wrong(cause, int_cfg);
> }
> diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c
> index cdebc917d2e..dad32be54fd 100644
> --- a/hw/net/igb_core.c
> +++ b/hw/net/igb_core.c
> @@ -168,16 +168,7 @@ igb_intmgr_timer_resume(IGBIntrDelayTimer *timer)
> }
>
> static void
> -igb_intrmgr_on_msix_throttling_timer(void *opaque)
> -{
> - IGBIntrDelayTimer *timer = opaque;
> - int idx = timer - &timer->core->eitr[0];
> -
> - timer->running = false;
> -
> - trace_e1000e_irq_msix_notify_postponed_vec(idx);
> - igb_msix_notify(timer->core, idx);
> -}
> +igb_intrmgr_on_msix_throttling_timer(void *opaque);
>
> static void
> igb_intrmgr_initialize_all_timers(IGBCore *core, bool create)
> @@ -2279,6 +2270,23 @@ static void igb_send_msix(IGBCore *core, uint32_t causes)
> }
> }
>
> +static void
> +igb_intrmgr_on_msix_throttling_timer(void *opaque)
> +{
> + IGBIntrDelayTimer *timer = opaque;
> + IGBCore *core = timer->core;
> + int vector = timer - &core->eitr[0];
> + uint32_t causes;
> +
> + timer->running = false;
> +
> + causes = core->mac[EICR] & core->mac[EIMS];
> + if ((causes & BIT(vector)) && !igb_eitr_should_postpone(core, vector)) {
Why does it check for igb_eitr_should_postpone() while
e1000e_intrmgr_on_msix_throttling_timer() doesn't?
Please remove it unless it is necessary; it implies
igb_eitr_should_postpone() can be true in this function and is
potentially misleading.
> + trace_e1000e_irq_msix_notify_postponed_vec(vector);
> + igb_msix_notify(core, vector);
> + }
> +}
> +
> static inline void
> igb_fix_icr_asserted(IGBCore *core)
> {
next prev parent reply other threads:[~2025-01-18 9:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-17 17:02 [PATCH 0/9] hw/e1000e|igb: interrupts and qtests fixes Nicholas Piggin
2025-01-17 17:02 ` [PATCH 1/9] qtest/e1000e|igb: Clear interrupt-cause and msix pending bits after irq Nicholas Piggin
2025-01-17 17:02 ` [PATCH 2/9] net/e1000e: Permit disabling interrupt throttling Nicholas Piggin
2025-01-17 17:02 ` [PATCH 3/9] qtest/e1000e|igb: assert irqs are clear before triggering an irq Nicholas Piggin
2025-01-18 8:14 ` Akihiko Odaki
2025-01-19 9:22 ` Yan Vugenfirer
2025-01-21 4:45 ` Nicholas Piggin
2025-01-17 17:03 ` [PATCH 4/9] net/igb: Fix interrupt throttling interval calculation Nicholas Piggin
2025-01-18 8:22 ` Akihiko Odaki
2025-01-17 17:03 ` [PATCH 5/9] net/igb: Fix EITR LLI and counter fields Nicholas Piggin
2025-01-18 8:37 ` Akihiko Odaki
2025-01-17 17:03 ` [PATCH 6/9] net/e1000e|igb: Fix interrupt throttling logic Nicholas Piggin
2025-01-18 9:50 ` Akihiko Odaki [this message]
2025-01-17 17:03 ` [PATCH 7/9] qtest/e1000e|igb: Test interrupt throttling in multiple_transfers test Nicholas Piggin
2025-01-17 17:03 ` [PATCH 8/9] net/e1000e: Fix xITR minimum value Nicholas Piggin
2025-01-18 7:50 ` Akihiko Odaki
2025-01-17 17:03 ` [PATCH 9/9] hw/net/e1000e|igb: Remove xitr_guest_value logic Nicholas Piggin
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=6bd93213-8b6a-4f14-a209-f2c3dca1a6c5@daynix.com \
--to=akihiko.odaki@daynix.com \
--cc=dmitry.fleytman@gmail.com \
--cc=farosas@suse.de \
--cc=jasowang@redhat.com \
--cc=lvivier@redhat.com \
--cc=npiggin@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sriram.yagnaraman@ericsson.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).