diff mbox series

atl1c: optimize rx loop

Message ID 20210319040447.527-1-liew.s.piaw@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series atl1c: optimize rx loop | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers warning 5 maintainers not CCed: zhangchangzhong@huawei.com christophe.jaillet@wanadoo.fr tglx@linutronix.de yanaijie@huawei.com jesse.brandeburg@intel.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 31 this patch: 31
netdev/kdoc success Errors and warnings before: 3 this patch: 3
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 31 this patch: 31
netdev/header_inline success Link

Commit Message

Sieng-Piaw Liew March 19, 2021, 4:04 a.m. UTC
Remove this trivial bit of inefficiency from the rx receive loop,
results in increase of a few Mbps in iperf3. Tested on Intel Core2
platform.

Signed-off-by: Sieng Piaw Liew <liew.s.piaw@gmail.com>
---
 drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Willy Tarreau March 19, 2021, 4:15 a.m. UTC | #1
On Fri, Mar 19, 2021 at 12:04:47PM +0800, Sieng Piaw Liew wrote:
> Remove this trivial bit of inefficiency from the rx receive loop,
> results in increase of a few Mbps in iperf3. Tested on Intel Core2
> platform.
> 
> Signed-off-by: Sieng Piaw Liew <liew.s.piaw@gmail.com>
> ---
>  drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> index 3f65f2b370c5..b995f9a0479c 100644
> --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> @@ -1796,9 +1796,7 @@ static void atl1c_clean_rx_irq(struct atl1c_adapter *adapter,
>  	struct atl1c_recv_ret_status *rrs;
>  	struct atl1c_buffer *buffer_info;
>  
> -	while (1) {
> -		if (*work_done >= work_to_do)
> -			break;
> +	while (*work_done < work_to_do) {

It should not change anything, or only based on the compiler's optimization
and should not result in a measurable difference because what it does is
exactly the same. Have you really compared the compiled output code to
explain the difference ? I strongly suspect you'll find no difference at
all.

Thus for me it's certainly not an optimization, it could be qualified as
a cleanup to improve code readability however.

Willy
Sieng-Piaw Liew March 22, 2021, 12:54 a.m. UTC | #2
On Fri, Mar 19, 2021 at 05:15:35AM +0100, Willy Tarreau wrote:
> On Fri, Mar 19, 2021 at 12:04:47PM +0800, Sieng Piaw Liew wrote:
> > Remove this trivial bit of inefficiency from the rx receive loop,
> > results in increase of a few Mbps in iperf3. Tested on Intel Core2
> > platform.
> > 
> > Signed-off-by: Sieng Piaw Liew <liew.s.piaw@gmail.com>
> > ---
> >  drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> > index 3f65f2b370c5..b995f9a0479c 100644
> > --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> > +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> > @@ -1796,9 +1796,7 @@ static void atl1c_clean_rx_irq(struct atl1c_adapter *adapter,
> >  	struct atl1c_recv_ret_status *rrs;
> >  	struct atl1c_buffer *buffer_info;
> >  
> > -	while (1) {
> > -		if (*work_done >= work_to_do)
> > -			break;
> > +	while (*work_done < work_to_do) {
> 
> It should not change anything, or only based on the compiler's optimization
> and should not result in a measurable difference because what it does is
> exactly the same. Have you really compared the compiled output code to
> explain the difference ? I strongly suspect you'll find no difference at
> all.
> 
> Thus for me it's certainly not an optimization, it could be qualified as
> a cleanup to improve code readability however.
> 
> Willy

You're right. Objdump and diff showed no difference.

Regards,
Sieng Piaw
diff mbox series

Patch

diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
index 3f65f2b370c5..b995f9a0479c 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
@@ -1796,9 +1796,7 @@  static void atl1c_clean_rx_irq(struct atl1c_adapter *adapter,
 	struct atl1c_recv_ret_status *rrs;
 	struct atl1c_buffer *buffer_info;
 
-	while (1) {
-		if (*work_done >= work_to_do)
-			break;
+	while (*work_done < work_to_do) {
 		rrs = ATL1C_RRD_DESC(rrd_ring, rrd_ring->next_to_clean);
 		if (likely(RRS_RXD_IS_VALID(rrs->word3))) {
 			rfd_num = (rrs->word0 >> RRS_RX_RFD_CNT_SHIFT) &