BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ratheesh Kannoth" <rkannoth@marvell.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v16 net-next 1/2] octeontx2: use atomic bitops for PF/VF and rep flags
Date: Sat, 19 Sep 2026 02:00:15 +0000	[thread overview]
Message-ID: <20260919020016.556051F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260918015906.1255204-2-rkannoth@marvell.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] net: torn state race condition in otx2_sync_flags_from_rep()
--

commit efc39444848abda6ed3d0dfe8f808dc182225903
Author: Ratheesh Kannoth <rkannoth@marvell.com>

octeontx2: use atomic bitops for PF/VF and rep flags

Replace non-atomic u64 flag read-modify-write with unsigned long bitmaps
and set_bit/clear_bit/test_bit access across the NIC driver. Add otx2 flag
helpers and representor state sync functionality.

> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h

[ ... ]

> +static inline void otx2_sync_flags_from_rep(struct otx2_nic *dst,
> +					    unsigned long *src_flags)
> +{
> +	unsigned int flag;
> +
> +	for (flag = 0; flag < OTX2_FLAG_MAX; flag++) {
> +		if (test_bit(flag, src_flags))
> +			set_bit(flag, &dst->flags);
> +		else
> +			clear_bit(flag, &dst->flags);
> +	}

[Severity: Medium]
Could this bit-by-bit synchronization cause a torn state for concurrent
readers?

When this loops over OTX2_FLAG_MAX bits, executing set_bit() or clear_bit()
individually, it breaks a single mask synchronization into multiple separate
atomic operations.

Concurrent fast-path readers executing otx2_tx_napi_handler() or
otx2_rcv_pkt_handler() might check pfvf->flags concurrently (for example,
OTX2_FLAG_REP_MODE_ENABLED or OTX2_FLAG_TC_MARK_ENABLED). Might they observe
an inconsistent combination of old and new flags during this loop?

This seems reachable if userspace configures TC rules on representors while
traffic is actively flowing, triggering rvu_rep_setup_tc_cb() to update the
shared structure.

> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260918015906.1255204-1-rkannoth@marvell.com?part=1

  reply	other threads:[~2026-09-19  2:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18  1:59 [PATCH v16 net-next 0/2] octeontx2: mqprio bandwidth offload for NIX TX schedulers Ratheesh Kannoth
2026-09-18  1:59 ` [PATCH v16 net-next 1/2] octeontx2: use atomic bitops for PF/VF and rep flags Ratheesh Kannoth
2026-09-19  2:00   ` sashiko-bot [this message]
2026-09-22  2:19   ` netdev-bot+sashiko
2026-09-18  1:59 ` [PATCH v16 net-next 2/2] octeontx2-pf: add mqprio bandwidth offload for NIX TX schedulers Ratheesh Kannoth
2026-09-19  2:00   ` sashiko-bot
2026-09-22  2:19   ` netdev-bot+sashiko
2026-09-23  1:46     ` Ratheesh Kannoth

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=20260919020016.556051F00898@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=rkannoth@marvell.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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