public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: "Björn Töpel" <bjorn@kernel.org>
Cc: Michael Chan <michael.chan@broadcom.com>,
	Pavan Chebbi <pavan.chebbi@broadcom.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	Willem de Bruijn <willemb@google.com>
Subject: Re: [PATCH net-next 5/5] selftests: rss_drv: Add RSS indirection table resize tests
Date: Tue, 3 Mar 2026 16:16:08 -0800	[thread overview]
Message-ID: <20260303161608.647d4c4b@kernel.org> (raw)
In-Reply-To: <20260303181535.2671734-6-bjorn@kernel.org>

On Tue,  3 Mar 2026 19:15:33 +0100 Björn Töpel wrote:
> +def _require_dynamic_indir_size(cfg, ch_max):
> +    """Skip if the device does not dynamically size its indirection table."""
> +    ethtool(f"-X {cfg.ifname} default")
> +    ethtool(f"-L {cfg.ifname} combined 2")
> +    small = len(_get_rss(cfg)['rss-indirection-table'])
> +    ethtool(f"-L {cfg.ifname} combined {ch_max}")
> +    large = len(_get_rss(cfg)['rss-indirection-table'])
> +
> +    if small == large:
> +        raise KsftSkipEx("Device does not dynamically size indirection table")
> +
> +
>  @ksft_variants([
>      KsftNamedVariant("main", False),
>      KsftNamedVariant("ctx", True),
> @@ -76,11 +88,90 @@ def indir_size_4x(cfg, create_context):
>          _test_rss_indir_size(cfg, test_max, context=ctx_id)
>  
>  
> +@ksft_variants([
> +    KsftNamedVariant("main", False),
> +    KsftNamedVariant("ctx", True),
> +])
> +def resize_periodic(cfg, create_context):
> +    """Test that a periodic indirection table survives channel changes.
> +
> +    Set a periodic table (equal 2), reduce channels to trigger a
> +    fold, then increase to trigger an unfold. Verify the table pattern
> +    is preserved and the size tracks the channel count.
> +    """
> +    channels = cfg.ethnl.channels_get({'header': {'dev-index': cfg.ifindex}})
> +    ch_max = channels.get('combined-max', 0)
> +    qcnt = channels['combined-count']
> +
> +    if ch_max < 4:
> +        raise KsftSkipEx(f"Not enough queues for the test: max={ch_max}")
> +
> +    defer(ethtool, f"-L {cfg.ifname} combined {qcnt}")
> +    ethtool(f"-L {cfg.ifname} combined {ch_max}")
> +
> +    _require_dynamic_indir_size(cfg, ch_max)
> +
> +    ctx_id = _maybe_create_context(cfg, create_context)
> +    ctx_ref = f"context {ctx_id}" if ctx_id else ""
> +
> +    ethtool(f"-X {cfg.ifname} {ctx_ref} equal 2")
> +    if not create_context:
> +        defer(ethtool, f"-X {cfg.ifname} default")
> +
> +    orig_size = len(_get_rss(cfg, context=ctx_id)['rss-indirection-table'])
> +
> +    # Shrink — should fold
> +    ethtool(f"-L {cfg.ifname} combined 2")

I wonder if we may miss some cases because we init the table to [0, 1]
and also only enable only 2 queues. Let's set it to 4 queues here to
potentially catch the driver resetting the table? 2 vs 4 are both tiny
values.

Alternatively we could use netlink to set the inidir table as
 [1, 0] x N
rather than
 [0, 1] x N

and..

> +    rss = _get_rss(cfg, context=ctx_id)
> +    indir = rss['rss-indirection-table']
> +
> +    ksft_ge(orig_size, len(indir), "Table did not shrink")
> +    ksft_eq(set(indir), {0, 1}, "Folded table has wrong queues")

here actually check

	ksft_eq(indir, [1, 0] * (len / 2), "Folded table has wrong queues")

> +    # Grow back — should unfold
> +    ethtool(f"-L {cfg.ifname} combined {ch_max}")
> +    rss = _get_rss(cfg, context=ctx_id)
> +    indir = rss['rss-indirection-table']
> +
> +    ksft_eq(len(indir), orig_size, "Table size not restored")
> +    ksft_eq(set(indir), {0, 1}, "Unfolded table has wrong queues")
> +
> +
> +def resize_nonperiodic_reject(cfg):
> +    """Test that a non-periodic table blocks channel reduction.
> +
> +    Set equal weight across all queues so the table is not periodic
> +    at any smaller size, then verify channel reduction is rejected.
> +    """
> +    channels = cfg.ethnl.channels_get({'header': {'dev-index': cfg.ifindex}})
> +    ch_max = channels.get('combined-max', 0)
> +    qcnt = channels['combined-count']
> +
> +    if ch_max < 4:
> +        raise KsftSkipEx(f"Not enough queues for the test: max={ch_max}")
> +
> +    defer(ethtool, f"-L {cfg.ifname} combined {qcnt}")
> +    ethtool(f"-L {cfg.ifname} combined {ch_max}")
> +
> +    _require_dynamic_indir_size(cfg, ch_max)
> +
> +    ethtool(f"-X {cfg.ifname} equal {ch_max}")
> +    defer(ethtool, f"-X {cfg.ifname} default")
> +
> +    try:
> +        ethtool(f"-L {cfg.ifname} combined 2")
> +    except CmdExitFailure:
> +        pass
> +    else:
> +        raise KsftFailEx("Channel reduction should fail with non-periodic table")

grep for ksft_raises()

>  def main() -> None:
>      """ Ksft boiler plate main """
> -    with NetDrvEnv(__file__) as cfg:
> +    with NetDrvEnv(__file__, queue_count=8) as cfg:

the queue_count=8 presumably only applies to netdevsim so it should go

>          cfg.ethnl = EthtoolFamily()
> -        ksft_run([indir_size_4x], args=(cfg, ))
> +        ksft_run([indir_size_4x, resize_periodic,
> +                  resize_nonperiodic_reject], args=(cfg, ))
>      ksft_exit()
>  
>  


  reply	other threads:[~2026-03-04  0:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03 18:15 [PATCH net-next 0/5] ethtool: Dynamic RSS context indirection table resizing Björn Töpel
2026-03-03 18:15 ` [PATCH net-next 1/5] ethtool: Add RSS indirection table resize helpers Björn Töpel
2026-03-04  0:03   ` Jakub Kicinski
2026-03-04 11:37     ` Björn Töpel
2026-03-04 17:09       ` Jakub Kicinski
2026-03-03 18:15 ` [PATCH net-next 2/5] bnxt_en: Resize RSS contexts on channel count change Björn Töpel
2026-03-03 19:20   ` Michael Chan
2026-03-04 11:38     ` Björn Töpel
2026-03-04  0:05   ` Jakub Kicinski
2026-03-04 11:39     ` Björn Töpel
2026-03-03 18:15 ` [PATCH net-next 3/5] netdevsim: Add RSS context support with dynamic table sizing Björn Töpel
2026-03-04  0:07   ` Jakub Kicinski
2026-03-04 11:40     ` Björn Töpel
2026-03-03 18:15 ` [PATCH net-next 4/5] selftests: netdevsim: Add RSS indirection table resize test Björn Töpel
2026-03-04  0:07   ` Jakub Kicinski
2026-03-03 18:15 ` [PATCH net-next 5/5] selftests: rss_drv: Add RSS indirection table resize tests Björn Töpel
2026-03-04  0:16   ` Jakub Kicinski [this message]
2026-03-04  8:23 ` [PATCH net-next 0/5] ethtool: Dynamic RSS context indirection table resizing Pavan Chebbi

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=20260303161608.647d4c4b@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=bjorn@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.com \
    --cc=willemb@google.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