[v3,1/1] examples/l2fwd-jobstats: fix lock availability

Message ID 20240730100335.3734796-1-rkudurumalla@marvell.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series [v3,1/1] examples/l2fwd-jobstats: fix lock availability |

Checks

Context Check Description
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Rakesh Kudurumalla July 30, 2024, 10:03 a.m. UTC
This patch addresses the issue by introducing a delay
before acquiring the lock in the loop. This delay allows for better
availability of the lock, ensuring that show_lcore_stats() can
periodically update the statistics even when forwarding jobs are running.

Fixes: 204896f8d66c ("examples/l2fwd-jobstats: add new example")
Cc: stable@dpdk.org

Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
---
v3: updated subject message
v2: updated commit description

 examples/l2fwd-jobstats/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Thomas Monjalon July 30, 2024, 4:12 p.m. UTC | #1
Hello,

30/07/2024 12:03, Rakesh Kudurumalla:
> This patch addresses the issue by introducing a delay

Please start with describing the issue.

> before acquiring the lock in the loop. This delay allows for better
> availability of the lock, ensuring that show_lcore_stats() can
> periodically update the statistics even when forwarding jobs are running.

Why a delay is better than a pause?

> @@ -542,7 +542,7 @@ l2fwd_main_loop(void)
>  		} while (likely(stats_read_pending == 0));
>  
>  		rte_spinlock_unlock(&qconf->lock);
> -		rte_pause();
> +		rte_delay_us(10);
>  	}
  
Rakesh Kudurumalla Aug. 8, 2024, 11:41 a.m. UTC | #2
From: Thomas Monjalon <thomas@monjalon.net>
Sent: Tuesday, July 30, 2024 9:42 PM
To: Rakesh Kudurumalla <rkudurumalla@marvell.com>
Cc: ferruh.yigit@amd.com; andrew.rybchenko@oktetlabs.ru; orika@nvidia.com; dev@dpdk.org; Jerin Jacob <jerinj@marvell.com>; Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>; stable@dpdk.org
Subject: [EXTERNAL] Re: [PATCH v3 1/1] examples/l2fwd-jobstats: fix lock availability

Hello, 30/07/2024 12: 03, Rakesh Kudurumalla: > This patch addresses the issue by introducing a delay Please start with describing the issue. > before acquiring the lock in the loop. This delay allows for better > availability of the


Hello,



30/07/2024 12:03, Rakesh Kudurumalla:

> This patch addresses the issue by introducing a delay



Please start with describing the issue.



> before acquiring the lock in the loop. This delay allows for better

> availability of the lock, ensuring that show_lcore_stats() can

> periodically update the statistics even when forwarding jobs are running.



Why a delay is better than a pause?



due to high frequency of polling in l2fwd_main_loop()  rte_pause() is not yieding the processor

to display stats relating to fwd and flush execution time so added a delay achieve the same.



> @@ -542,7 +542,7 @@ l2fwd_main_loop(void)

>                           } while (likely(stats_read_pending == 0));

>

>                           rte_spinlock_unlock(&qconf->lock);

> -                        rte_pause();

> +                       rte_delay_us(10);

>           }
  
Thomas Monjalon Aug. 8, 2024, 12:22 p.m. UTC | #3
08/08/2024 13:41, Rakesh Kudurumalla:
> 
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Tuesday, July 30, 2024 9:42 PM
> To: Rakesh Kudurumalla <rkudurumalla@marvell.com>
> Cc: ferruh.yigit@amd.com; andrew.rybchenko@oktetlabs.ru; orika@nvidia.com; dev@dpdk.org; Jerin Jacob <jerinj@marvell.com>; Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>; stable@dpdk.org
> Subject: [EXTERNAL] Re: [PATCH v3 1/1] examples/l2fwd-jobstats: fix lock availability
> 
> Hello, 30/07/2024 12: 03, Rakesh Kudurumalla: > This patch addresses the issue by introducing a delay Please start with describing the issue. > before acquiring the lock in the loop. This delay allows for better > availability of the
> 
> 
> Hello,
> 
> 
> 
> 30/07/2024 12:03, Rakesh Kudurumalla:
> 
> > This patch addresses the issue by introducing a delay
> 
> 
> 
> Please start with describing the issue.

You should explain the race is managed with a spinlock,
and where the threads are running (one is a timer).


> > before acquiring the lock in the loop. This delay allows for better
> > availability of the lock, ensuring that show_lcore_stats() can
> > periodically update the statistics even when forwarding jobs are running.
> 
> 
> Why a delay is better than a pause?
> 
> 
> due to high frequency of polling in l2fwd_main_loop()  rte_pause() is not yieding the processor
> to display stats relating to fwd and flush execution time so added a delay achieve the same.

Which CPU did you try?
  
Rakesh Kudurumalla Aug. 11, 2024, 4 p.m. UTC | #4
> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Thursday, August 8, 2024 5:52 PM
> To: Rakesh Kudurumalla <rkudurumalla@marvell.com>
> Cc: ferruh.yigit@amd.com; andrew.rybchenko@oktetlabs.ru;
> orika@nvidia.com; dev@dpdk.org; Jerin Jacob <jerinj@marvell.com>; Nithin
> Kumar Dabilpuram <ndabilpuram@marvell.com>; stable@dpdk.org
> Subject: Re: [EXTERNAL] Re: [PATCH v3 1/1] examples/l2fwd-jobstats: fix lock
> availability
> 
> 08/08/2024 13: 41, Rakesh Kudurumalla: > > From: Thomas Monjalon
> <thomas@ monjalon. net> > Sent: Tuesday, July 30, 2024 9: 42 PM > To:
> Rakesh Kudurumalla <rkudurumalla@ marvell. com> > Cc:
> ferruh. yigit@ amd. com; andrew. rybchenko@ oktetlabs. ru;
> 
> 08/08/2024 13:41, Rakesh Kudurumalla:
> >
> > From: Thomas Monjalon <thomas@monjalon.net>
> > Sent: Tuesday, July 30, 2024 9:42 PM
> > To: Rakesh Kudurumalla <rkudurumalla@marvell.com>
> > Cc: ferruh.yigit@amd.com; andrew.rybchenko@oktetlabs.ru;
> > orika@nvidia.com; dev@dpdk.org; Jerin Jacob <jerinj@marvell.com>;
> > Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>; stable@dpdk.org
> > Subject: [EXTERNAL] Re: [PATCH v3 1/1] examples/l2fwd-jobstats: fix
> > lock availability
> >
> > Hello, 30/07/2024 12: 03, Rakesh Kudurumalla: > This patch addresses
> > the issue by introducing a delay Please start with describing the
> > issue. > before acquiring the lock in the loop. This delay allows for
> > better > availability of the
> >
> >
> > Hello,
> >
> >
> >
> > 30/07/2024 12:03, Rakesh Kudurumalla:
> >
> > > This patch addresses the issue by introducing a delay
> >
> >
> >
> > Please start with describing the issue.
> 
> You should explain the race is managed with a spinlock, and where the
> threads are running (one is a timer).
> Updated commit message in V5
> 
> > > before acquiring the lock in the loop. This delay allows for better
> > > availability of the lock, ensuring that show_lcore_stats() can
> > > periodically update the statistics even when forwarding jobs are running.
> >
> >
> > Why a delay is better than a pause?
> >
> >
> > due to high frequency of polling in l2fwd_main_loop()  rte_pause() is
> > not yieding the processor to display stats relating to fwd and flush
> execution time so added a delay achieve the same.
> 
> Which CPU did you try?
> arm
  

Patch

diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c
index 308b8edd20..7bb38b290f 100644
--- a/examples/l2fwd-jobstats/main.c
+++ b/examples/l2fwd-jobstats/main.c
@@ -542,7 +542,7 @@  l2fwd_main_loop(void)
 		} while (likely(stats_read_pending == 0));
 
 		rte_spinlock_unlock(&qconf->lock);
-		rte_pause();
+		rte_delay_us(10);
 	}
 	/* >8 End of minimize impact of stats reading. */
 }