[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACKFLimm96szzQd5AowWy-sQyfCKdoBCLgr5P68vOn6n0WKjWQ@mail.gmail.com>
Date: Tue, 29 Oct 2024 13:34:08 -0700
From: Michael Chan <michael.chan@...adcom.com>
To: Vadim Fedorenko <vadfed@...a.com>
Cc: Vadim Fedorenko <vadim.fedorenko@...ux.dev>, Pavan Chebbi <pavan.chebbi@...adcom.com>,
Jakub Kicinski <kuba@...nel.org>, Andrew Lunn <andrew+netdev@...n.ch>, Paolo Abeni <pabeni@...hat.com>,
"David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org,
Richard Cochran <richardcochran@...il.com>
Subject: Re: [PATCH net-next v3 2/2] bnxt_en: replace PTP spinlock with seqlock
On Mon, Oct 28, 2024 at 11:57 AM Vadim Fedorenko <vadfed@...a.com> wrote:
>
> We can see high contention on ptp_lock while doing RX timestamping
> on high packet rates over several queues. Spinlock is not effecient
> to protect timecounter for RX timestamps when reads are the most
> usual operations and writes are only occasional. It's better to use
> seqlock in such cases.
>
> Signed-off-by: Vadim Fedorenko <vadfed@...a.com>
> ---
> v3:
> - remove unused variable
> v2:
> - use read_excl lock to serialize reg access with FW reset
> ---
> drivers/net/ethernet/broadcom/bnxt/bnxt.c | 19 +++--
> drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 73 ++++++-------------
> drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h | 14 +++-
> 3 files changed, 46 insertions(+), 60 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> index 820c7e83e586..5ab52f7a282d 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> @@ -67,19 +67,21 @@ static int bnxt_ptp_settime(struct ptp_clock_info *ptp_info,
> if (BNXT_PTP_USE_RTC(ptp->bp))
> return bnxt_ptp_cfg_settime(ptp->bp, ns);
>
> - spin_lock_irqsave(&ptp->ptp_lock, flags);
> + write_seqlock_irqsave(&ptp->ptp_lock, flags);
> timecounter_init(&ptp->tc, &ptp->cc, ns);
> - spin_unlock_irqrestore(&ptp->ptp_lock, flags);
> + write_sequnlock_irqrestore(&ptp->ptp_lock, flags);
> return 0;
> }
>
> -/* Caller holds ptp_lock */
> static int bnxt_refclk_read(struct bnxt *bp, struct ptp_system_timestamp *sts,
> u64 *ns)
> {
> struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
> u32 high_before, high_now, low;
> + unsigned long flags;
>
> + /* We have to serialize reg access and FW reset */
> + read_seqlock_excl_irqsave(&ptp->ptp_lock, flags);
> if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state))
I think we need read_sequnlock_excl_irqrestore() here before returning.
> return -EIO;
>
> @@ -93,6 +95,7 @@ static int bnxt_refclk_read(struct bnxt *bp, struct ptp_system_timestamp *sts,
> low = readl(bp->bar0 + ptp->refclk_mapped_regs[0]);
> ptp_read_system_postts(sts);
> }
> + read_sequnlock_excl_irqrestore(&ptp->ptp_lock, flags);
> *ns = ((u64)high_now << 32) | low;
>
> return 0;
Download attachment "smime.p7s" of type "application/pkcs7-signature" (4209 bytes)
Powered by blists - more mailing lists