Skip to contentSkip to conversation

ice: Re-organizes reqstd/avail {R,T}XQ check/code for efficiency+readability

PATCH Superseded Salil Mehta 3 participants 7 messages Apr 13, 2021 – Apr 21, 2021

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ice: Re-organizes reqstd/avail {R,T}XQ check/code for efficiency+readability

If user has explicitly requested the number of {R,T}XQs, then it is unnecessary to get the count of already available {R,T}XQs from the PF avail_{r,t}xqs bitmap. This value will get overridden by user specified value in any case.

This patch does minor re-organization of the code for improving the flow and readabiltiy. This scope of improvement was found during the review of the ICE driver code.

FYI, I could not test this change due to unavailability of the hardware. It would be helpful if somebody can test this patch and provide Tested-by Tag. Many thanks!

Fixes 87324e747fde ("ice: Implement ethtool ops for channels")
Cc intel-wired-lan at lists.osuosl.org
Cc Jeff Kirsher <[email protected]>

--
Change V1->V2
(*) Fixed the comments from Anthony Nguyen(Intel)

     Link: https://lkml.org/lkml/2021/4/12/1997
---
 drivers/net/ethernet/intel/ice/ice_lib.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +8 -6
index d13c7fc8fb0a..d77133d6baa7 100644
@@ -161,12 +161,13 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id)
 
 	switch (vsi->type) {
 	case ICE_VSI_PF:
-		vsi->alloc_txq = min3(pf->num_lan_msix,
-				      ice_get_avail_txq_count(pf),
-				      (u16)num_online_cpus());
 		if (vsi->req_txq) {
 			vsi->alloc_txq = vsi->req_txq;
 			vsi->num_txq = vsi->req_txq;
+		} else {
+			vsi->alloc_txq = min3(pf->num_lan_msix,
+					      ice_get_avail_txq_count(pf),
+					      (u16)num_online_cpus());
 		}
 
 		pf->num_lan_tx = vsi->alloc_txq;
@@ -175,12 +176,13 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id)
 		if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) {
 			vsi->alloc_rxq = 1;
 		} else {
-			vsi->alloc_rxq = min3(pf->num_lan_msix,
-					      ice_get_avail_rxq_count(pf),
-					      (u16)num_online_cpus());
 			if (vsi->req_rxq) {
 				vsi->alloc_rxq = vsi->req_rxq;
 				vsi->num_rxq = vsi->req_rxq;
+			} else {
+				vsi->alloc_rxq = min3(pf->num_lan_msix,
+						      ice_get_avail_rxq_count(pf),
+						      (u16)num_online_cpus());
 			}
 		}
 
Signature · 1 line
2.17.1
Tested-by on v2 1/1
#1 lore raw

RE: [Intel-wired-lan] [PATCH V2 net] ice: Re-organizes reqstd/avail {R, T}XQ check/code for efficiency+readability

Quoted 29 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Salil Mehta
Sent: Tuesday, April 13, 2021 3:45 PM
To: davem at davemloft.net; kuba at kernel.org
Cc: salil.mehta at huawei.com; linuxarm at openeuler.org;
netdev at vger.kernel.org; linuxarm at huawei.com; linux-
kernel at vger.kernel.org; Jeff Kirsher <[email protected]>; intel- wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH V2 net] ice: Re-organizes reqstd/avail {R, T}XQ check/code for efficiency+readability

If user has explicitly requested the number of {R,T}XQs, then it is unnecessary to get the count of already available {R,T}XQs from the PF avail_{r,t}xqs bitmap. This value will get overridden by user specified value in any case.

This patch does minor re-organization of the code for improving the flow and readabiltiy. This scope of improvement was found during the review of the ICE driver code.

FYI, I could not test this change due to unavailability of the hardware. It would be helpful if somebody can test this patch and provide Tested-by Tag. Many thanks!

Fixes 87324e747fde ("ice: Implement ethtool ops for channels")
Cc intel-wired-lan at lists.osuosl.org
Cc Jeff Kirsher <[email protected]>
Quoted 7 lines

--
Change V1->V2
(*) Fixed the comments from Anthony Nguyen(Intel)

     Link: https://lkml.org/lkml/2021/4/12/1997
---
 drivers/net/ethernet/intel/ice/ice_lib.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
#2 lore raw

RE: [Intel-wired-lan] [PATCH V2 net] ice: Re-organizes reqstd/avail {R, T}XQ check/code for efficiency+readability

Quoted 40 lines

From: Brelinski, TonyX [mailto:tonyx.brelinski at intel.com]
Sent: Tuesday, April 20, 2021 9:26 PM

Quoted 11 lines

From: Intel-wired-lan <[email protected]> On Behalf Of Salil Mehta
Sent: Tuesday, April 13, 2021 3:45 PM
To: davem at davemloft.net; kuba at kernel.org
Cc: salil.mehta at huawei.com; linuxarm at openeuler.org;
netdev at vger.kernel.org; linuxarm at huawei.com; linux-
kernel at vger.kernel.org; Jeff Kirsher <[email protected]>; intel- wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH V2 net] ice: Re-organizes reqstd/avail {R, T}XQ check/code for efficiency+readability

Quoted 3 lines

If user has explicitly requested the number of {R,T}XQs, then it is unnecessary to get the count of already available {R,T}XQs from the PF avail_{r,t}xqs bitmap. This value will get overridden by user specified value

in

Quoted 14 lines

any case.

This patch does minor re-organization of the code for improving the flow and readabiltiy. This scope of improvement was found during the review of the ICE driver code.

FYI, I could not test this change due to unavailability of the hardware. It would be helpful if somebody can test this patch and provide Tested-by Tag. Many thanks!

Fixes 87324e747fde ("ice: Implement ethtool ops for channels")
Cc intel-wired-lan at lists.osuosl.org
Cc Jeff Kirsher <[email protected]>
Quoted 7 lines

--
Change V1->V2
(*) Fixed the comments from Anthony Nguyen(Intel)

     Link: https://lkml.org/lkml/2021/4/12/1997
---
 drivers/net/ethernet/intel/ice/ice_lib.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
Quoted 2 lines

Intel)

Many thanks!

Salil.

#3 lore raw

Re: [Intel-wired-lan] [PATCH V2 net] ice: Re-organizes reqstd/avail {R, T}XQ check/code for efficiency+readability

In reply to Salil Mehta

Dear Salil,

Thank you very much for your patch.

In the git commit message summary, could you please use imperative mood [1]?

Quoted 1 line

Re-organize reqstd/avail {R, T}XQ check/code for efficiency+readability

It?s a bit long though. Maybe:

Quoted 1 line

Avoid unnecessary assignment with user specified {R,T}XQs

Am 14.04.21 um 00:44 schrieb Salil Mehta:

Quoted 7 lines

If user has explicitly requested the number of {R,T}XQs, then it is unnecessary to get the count of already available {R,T}XQs from the PF avail_{r,t}xqs bitmap. This value will get overridden by user specified value in any case.

This patch does minor re-organization of the code for improving the flow and readabiltiy. This scope of improvement was found during the review of

readabil*it*y

Quoted 5 lines

the ICE driver code.

FYI, I could not test this change due to unavailability of the hardware. It would be helpful if somebody can test this patch and provide Tested-by Tag. Many thanks!

This should go outside the commit message (below the --- for example).

Quoted 1 line
Fixes 87324e747fde ("ice: Implement ethtool ops for channels")

Did you check the behavior before is actually a bug? Or is it just for the detection heuristic for commits to be applied to the stable series?

Quoted 20 lines
Cc intel-wired-lan at lists.osuosl.org
Cc Jeff Kirsher <[email protected]>

--
Change V1->V2
(*) Fixed the comments from Anthony Nguyen(Intel)

      Link: https://lkml.org/lkml/2021/4/12/1997
---
  drivers/net/ethernet/intel/ice/ice_lib.c | 14 ++++++++------
  1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +0 -1
index d13c7fc8fb0a..d77133d6baa7 100644
@@ -161,12 +161,13 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id)
 
  	switch (vsi->type) {
  	case ICE_VSI_PF:
-		vsi->alloc_txq = min3(pf->num_lan_msix,

drivers/net/ethernet/intel/ice/ice_lib.c static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id) · line 171

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lib.c +4 -2
-				      ice_get_avail_txq_count(pf),
-				      (u16)num_online_cpus());
  		if (vsi->req_txq) {
  			vsi->alloc_txq = vsi->req_txq;
  			vsi->num_txq = vsi->req_txq;
+		} else {
+			vsi->alloc_txq = min3(pf->num_lan_msix,
+					      ice_get_avail_txq_count(pf),
+					      (u16)num_online_cpus());
  		}

I am curious, did you check the compiler actually creates different code, or did it notice the inefficiency by itself and optimized it already?

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_lib.c +0 -3
  		pf->num_lan_tx = vsi->alloc_txq;
@@ -175,12 +176,13 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id)
  		if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) {
  			vsi->alloc_rxq = 1;
  		} else {
-			vsi->alloc_rxq = min3(pf->num_lan_msix,
-					      ice_get_avail_rxq_count(pf),
-					      (u16)num_online_cpus());

drivers/net/ethernet/intel/ice/ice_lib.c static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id) · line 188

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lib.c +4 -0
  			if (vsi->req_rxq) {
  				vsi->alloc_rxq = vsi->req_rxq;
  				vsi->num_rxq = vsi->req_rxq;
+			} else {
+				vsi->alloc_rxq = min3(pf->num_lan_msix,
+						      ice_get_avail_rxq_count(pf),
+						      (u16)num_online_cpus());
  			}
  		}
 

Kind regards,

Paul

#4 lore raw

RE: [Intel-wired-lan] [PATCH V2 net] ice: Re-organizes reqstd/avail {R, T}XQ check/code for efficiency+readability

Quoted 10 lines

From: Paul Menzel [mailto:pmenzel at molgen.mpg.de]
Sent: Wednesday, April 21, 2021 6:36 AM
To: Salil Mehta <[email protected]>
Cc: linuxarm at openeuler.org; netdev at vger.kernel.org; Linuxarm <[email protected]>; linux-kernel at vger.kernel.org; Jeff Kirsher <[email protected]>; intel-wired-lan at lists.osuosl.org; David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH V2 net] ice: Re-organizes reqstd/avail {R, T}XQ check/code for efficiency+readability

Quoted 4 lines

Dear Salil,

Thank you very much for your patch.

Thanks for the review.

Quoted 1 line

In the git commit message summary, could you please use imperative mood [1]?

No issues. There is always a scope of improvement.

Quoted 5 lines
Quoted 1 line

Re-organize reqstd/avail {R, T}XQ check/code for efficiency+readability

It?s a bit long though. Maybe:

Avoid unnecessary assignment with user specified {R,T}XQs

Umm..above conveys the wrong meaning as this is not what patch is doing.

If you see the code, in the presence of the user specified {R,T}XQs it avoids fetching available {R,T}XQ count.

What about below?

"Avoid unnecessary avail_{r,t}xq assignments if user has specified Qs"

Quoted 10 lines

Am 14.04.21 um 00:44 schrieb Salil Mehta:

Quoted 7 lines

If user has explicitly requested the number of {R,T}XQs, then it is unnecessary to get the count of already available {R,T}XQs from the PF avail_{r,t}xqs bitmap. This value will get overridden by user specified value in any case.

This patch does minor re-organization of the code for improving the flow and readabiltiy. This scope of improvement was found during the review of

readabil*it*y

Thanks. Missed that earlier. My shaky fingers :(

Quoted 7 lines
Quoted 5 lines

the ICE driver code.

FYI, I could not test this change due to unavailability of the hardware. It would be helpful if somebody can test this patch and provide Tested-by Tag. Many thanks!

This should go outside the commit message (below the --- for example).

Agreed.

Quoted 4 lines
Quoted 1 line
Fixes 87324e747fde ("ice: Implement ethtool ops for channels")

Did you check the behavior before is actually a bug? Or is it just for the detection heuristic for commits to be applied to the stable series?

Right, later was the idea.

Quoted 19 lines
Quoted 6 lines
Cc intel-wired-lan at lists.osuosl.org
Cc Jeff Kirsher <[email protected]>

--
Change V1->V2
(*) Fixed the comments from Anthony Nguyen(Intel)

Review

Quoted 6 lines
      Link: https://lkml.org/lkml/2021/4/12/1997
---
  drivers/net/ethernet/intel/ice/ice_lib.c | 14 ++++++++------
  1 file changed, 8 insertions(+), 6 deletions(-)
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_lib.c

drivers/net/ethernet/intel/ice/ice_lib.c static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16

Quoted 4 lines

index d13c7fc8fb0a..d77133d6baa7 100644

drivers/net/ethernet/intel/ice/ice_lib.c +0 -0
@@ -161,12 +161,13 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16

vf_id)

Quoted 1 line
Quoted 16 lines

drivers/net/ethernet/intel/ice/ice_lib.c static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id) · line 171

Quoted 13 lines
  	switch (vsi->type) {
  	case ICE_VSI_PF:
drivers/net/ethernet/intel/ice/ice_lib.c +4 -3
-		vsi->alloc_txq = min3(pf->num_lan_msix,
-				      ice_get_avail_txq_count(pf),
-				      (u16)num_online_cpus());
  		if (vsi->req_txq) {
  			vsi->alloc_txq = vsi->req_txq;
  			vsi->num_txq = vsi->req_txq;
+		} else {
+			vsi->alloc_txq = min3(pf->num_lan_msix,
+					      ice_get_avail_txq_count(pf),
+					      (u16)num_online_cpus());
  		}

I am curious, did you check the compiler actually creates different code, or did it notice the inefficiency by itself and optimized it already?

I have not looked into that detail but irrespective of what compiler generates I would like to keep the code in a shape which is more efficient and more readable.

I do understand in certain cases we have to do tradeoff between efficiency and readability but I do not see that here.

Quoted 24 lines

drivers/net/ethernet/intel/ice/ice_lib.c static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16

Quoted 2 lines
  		pf->num_lan_tx = vsi->alloc_txq;
drivers/net/ethernet/intel/ice/ice_lib.c +0 -0
@@ -175,12 +176,13 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16

vf_id)

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_lib.c +0 -3
  		if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) {
  			vsi->alloc_rxq = 1;
  		} else {
-			vsi->alloc_rxq = min3(pf->num_lan_msix,
-					      ice_get_avail_rxq_count(pf),
-					      (u16)num_online_cpus());

drivers/net/ethernet/intel/ice/ice_lib.c static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id) · line 188

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lib.c +4 -0
  			if (vsi->req_rxq) {
  				vsi->alloc_rxq = vsi->req_rxq;
  				vsi->num_rxq = vsi->req_rxq;
+			} else {
+				vsi->alloc_rxq = min3(pf->num_lan_msix,
+						      ice_get_avail_rxq_count(pf),
+						      (u16)num_online_cpus());
  			}
  		}
 

Kind regards,

Paul

#5 lore raw

Re: [Intel-wired-lan] [PATCH V2 net] ice: Re-organizes reqstd/avail {R, T}XQ check/code for efficiency+readability

[CC: Remove Jeff, as email is rejected]

Dear Salil,

Am 21.04.21 um 09:41 schrieb Salil Mehta:

Quoted 2 lines
Quoted 2 lines

From: Paul Menzel [mailto:pmenzel at molgen.mpg.de]
Sent: Wednesday, April 21, 2021 6:36 AM

[?]

Quoted 10 lines
Quoted 1 line

In the git commit message summary, could you please use imperative mood [1]?

No issues. There is always a scope of improvement.

Quoted 5 lines
Quoted 1 line

Re-organize reqstd/avail {R, T}XQ check/code for efficiency+readability

It?s a bit long though. Maybe:

Avoid unnecessary assignment with user specified {R,T}XQs

Quoted 8 lines

Umm..above conveys the wrong meaning as this is not what patch is doing.

If you see the code, in the presence of the user specified {R,T}XQs it avoids fetching available {R,T}XQ count.

What about below?

"Avoid unnecessary avail_{r,t}xq assignments if user has specified Qs"

Sounds good, still a little long. Maybe:

Quoted 66 lines

Avoid unnecessary avail_{r,t}xq assignments with user specified Qs

Quoted 10 lines

Am 14.04.21 um 00:44 schrieb Salil Mehta:

Quoted 7 lines

If user has explicitly requested the number of {R,T}XQs, then it is unnecessary to get the count of already available {R,T}XQs from the PF avail_{r,t}xqs bitmap. This value will get overridden by user specified value in any case.

This patch does minor re-organization of the code for improving the flow and readabiltiy. This scope of improvement was found during the review of

readabil*it*y

Thanks. Missed that earlier. My shaky fingers :(

Quoted 7 lines
Quoted 5 lines

the ICE driver code.

FYI, I could not test this change due to unavailability of the hardware. It would be helpful if somebody can test this patch and provide Tested-by Tag. Many thanks!

This should go outside the commit message (below the --- for example).

Agreed.

Quoted 4 lines
Quoted 1 line
Fixes 87324e747fde ("ice: Implement ethtool ops for channels")

Did you check the behavior before is actually a bug? Or is it just for the detection heuristic for commits to be applied to the stable series?

Right, later was the idea.

Quoted 17 lines
Quoted 17 lines
Cc intel-wired-lan at lists.osuosl.org
Cc Jeff Kirsher <[email protected]>

--
Change V1->V2
(*) Fixed the comments from Anthony Nguyen(Intel)

       Link: https://lkml.org/lkml/2021/4/12/1997
---
   drivers/net/ethernet/intel/ice/ice_lib.c | 14 ++++++++------
   1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +0 -0
index d13c7fc8fb0a..d77133d6baa7 100644
@@ -161,12 +161,13 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id)
 
Quoted 16 lines

drivers/net/ethernet/intel/ice/ice_lib.c static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id) · line 171

Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_lib.c +4 -3
   	switch (vsi->type) {
   	case ICE_VSI_PF:
-		vsi->alloc_txq = min3(pf->num_lan_msix,
-				      ice_get_avail_txq_count(pf),
-				      (u16)num_online_cpus());
   		if (vsi->req_txq) {
   			vsi->alloc_txq = vsi->req_txq;
   			vsi->num_txq = vsi->req_txq;
+		} else {
+			vsi->alloc_txq = min3(pf->num_lan_msix,
+					      ice_get_avail_txq_count(pf),
+					      (u16)num_online_cpus());
   		}

I am curious, did you check the compiler actually creates different code, or did it notice the inefficiency by itself and optimized it already?

Quoted 5 lines

I have not looked into that detail but irrespective of what compiler generates I would like to keep the code in a shape which is more efficient and more readable.

I do understand in certain cases we have to do tradeoff between efficiency and readability but I do not see that here.

I agree, as *efficiency* is mentioned several times, I assume it was tested. Thank you for the clarification.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lib.c +0 -3
   		pf->num_lan_tx = vsi->alloc_txq;
@@ -175,12 +176,13 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id)
   		if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) {
   			vsi->alloc_rxq = 1;
   		} else {
-			vsi->alloc_rxq = min3(pf->num_lan_msix,
-					      ice_get_avail_rxq_count(pf),
-					      (u16)num_online_cpus());
   			if (vsi->req_rxq) {
   				vsi->alloc_rxq = vsi->req_rxq;
Quoted 8 lines
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_lib.c static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id) · line 188

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_lib.c +4 -0
   				vsi->num_rxq = vsi->req_rxq;
+			} else {
+				vsi->alloc_rxq = min3(pf->num_lan_msix,
+						      ice_get_avail_rxq_count(pf),
+						      (u16)num_online_cpus());
   			}
   		}
 

Kind regards,

Paul

#6 lore raw

RE: [Intel-wired-lan] [PATCH V2 net] ice: Re-organizes reqstd/avail {R, T}XQ check/code for efficiency+readability

Quoted 4 lines

From: Paul Menzel [mailto:pmenzel at molgen.mpg.de]
Sent: Wednesday, April 21, 2021 8:54 AM

[CC: Remove Jeff, as email is rejected]

Yes, thanks for the reminder. I had noticed it earlier.

[...]

Quoted 25 lines
Quoted 1 line
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_lib.c

Quoted 4 lines
Quoted 4 lines

drivers/net/ethernet/intel/ice/ice_lib.c static void ice_vsi_set_num_qs(struct ice_vsi *vsi,

Quoted 4 lines

index d13c7fc8fb0a..d77133d6baa7 100644

drivers/net/ethernet/intel/ice/ice_lib.c +0 -0
@@ -161,12 +161,13 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi,

u16 vf_id)

Quoted 18 lines
Quoted 17 lines
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_lib.c +0 -1
   	switch (vsi->type) {
   	case ICE_VSI_PF:
-		vsi->alloc_txq = min3(pf->num_lan_msix,

drivers/net/ethernet/intel/ice/ice_lib.c static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id) · line 171

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lib.c +4 -2
-				      ice_get_avail_txq_count(pf),
-				      (u16)num_online_cpus());
   		if (vsi->req_txq) {
   			vsi->alloc_txq = vsi->req_txq;
   			vsi->num_txq = vsi->req_txq;
+		} else {
+			vsi->alloc_txq = min3(pf->num_lan_msix,
+					      ice_get_avail_txq_count(pf),
+					      (u16)num_online_cpus());
   		}

I am curious, did you check the compiler actually creates different code, or did it notice the inefficiency by itself and optimized it already?

Quoted 8 lines
Quoted 5 lines

I have not looked into that detail but irrespective of what compiler generates I would like to keep the code in a shape which is more efficient and more readable.

I do understand in certain cases we have to do tradeoff between efficiency and readability but I do not see that here.

I agree, as *efficiency* is mentioned several times, I assume it was tested. Thank you for the clarification.

I mentioned inefficient because below code gets executed unnecessarily.

/**
* ice_get_avail_q_count - Get count of queues in use
* @pf_qmap: bitmap to get queue use count from
* @lock: pointer to a mutex that protects access to pf_qmap
* @size: size of the bitmap
*/
static u16
ice_get_avail_q_count(unsigned long *pf_qmap, struct mutex *lock, u16 size)

{
	unsigned long bit;
	u16 count = 0;

	mutex_lock(lock);
	for_each_clear_bit(bit, pf_qmap, size)
		count++;
	mutex_unlock(lock);

	return count;
}

/**
* ice_get_avail_txq_count - Get count of Tx queues in use
* @pf: pointer to an ice_pf instance
*/
u16 ice_get_avail_txq_count(struct ice_pf *pf)

{
	return ice_get_avail_q_count(pf->avail_txqs, &pf->avail_q_mutex,
				     pf->max_pf_txqs);
}
Quoted 24 lines
Quoted 2 lines
Quoted 2 lines

drivers/net/ethernet/intel/ice/ice_lib.c static void ice_vsi_set_num_qs(struct ice_vsi *vsi,

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_lib.c +0 -0
   		pf->num_lan_tx = vsi->alloc_txq;
@@ -175,12 +176,13 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi,

u16 vf_id)

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_lib.c +0 -3
   		if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) {
   			vsi->alloc_rxq = 1;
   		} else {
-			vsi->alloc_rxq = min3(pf->num_lan_msix,
-					      ice_get_avail_rxq_count(pf),
-					      (u16)num_online_cpus());
   			if (vsi->req_rxq) {
   				vsi->alloc_rxq = vsi->req_rxq;
Quoted 8 lines
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_lib.c static void ice_vsi_set_num_qs(struct ice_vsi *vsi, u16 vf_id) · line 188

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_lib.c +4 -0
   				vsi->num_rxq = vsi->req_rxq;
+			} else {
+				vsi->alloc_rxq = min3(pf->num_lan_msix,
+						      ice_get_avail_rxq_count(pf),
+						      (u16)num_online_cpus());
   			}
   		}
 

Kind regards,

Paul