diff mbox series

[net-next] ibmvnic: Assign XPS map to correct queue index

Message ID 20230223153944.44969-1-nnac123@linux.ibm.com (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series [net-next] ibmvnic: Assign XPS map to correct queue index | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 1 blamed authors not CCed: pabeni@redhat.com; 11 maintainers not CCed: pabeni@redhat.com npiggin@gmail.com christophe.leroy@csgroup.eu ricklind@linux.ibm.com kuba@kernel.org tlfalcon@linux.ibm.com linuxppc-dev@lists.ozlabs.org edumazet@google.com mpe@ellerman.id.au danymadden@us.ibm.com davem@davemloft.net
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Nick Child Feb. 23, 2023, 3:39 p.m. UTC
When setting the XPS map value for TX queues, use the index of the
transmit queue.
Previously, the function was passing the index of the loop that iterates
over all queues (RX and TX). This was causing invalid XPS map values.

Fixes: 6831582937bd ("ibmvnic: Toggle between queue types in affinity mapping")
Signed-off-by: Nick Child <nnac123@linux.ibm.com>
---

I am a little surprised that __netif_set_xps_queue() did not complain that some
index values were greater than the number of tx queues. Though maybe the function
assumes that the developers are wise enough :)

Should __netif_set_xps_queue() have a check that index < dev->num_tx_queues?

 drivers/net/ethernet/ibm/ibmvnic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Pavan Chebbi Feb. 24, 2023, 8:49 a.m. UTC | #1
On Thu, Feb 23, 2023 at 9:10 PM Nick Child <nnac123@linux.ibm.com> wrote:
>
> When setting the XPS map value for TX queues, use the index of the
> transmit queue.
> Previously, the function was passing the index of the loop that iterates
> over all queues (RX and TX). This was causing invalid XPS map values.
>
> Fixes: 6831582937bd ("ibmvnic: Toggle between queue types in affinity mapping")
> Signed-off-by: Nick Child <nnac123@linux.ibm.com>

Fix looks good to me.
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>

> ---
>
> I am a little surprised that __netif_set_xps_queue() did not complain that some
> index values were greater than the number of tx queues. Though maybe the function
> assumes that the developers are wise enough :)

Are you sure an index greater than total tx queues was sent?
A quick look at ibmvnic_set_affinity() suggests that the condition if
(... || (i_txqs == num_txqs)) prevents overrunning available tx
queues.

>
> Should __netif_set_xps_queue() have a check that index < dev->num_tx_queues?
>
>  drivers/net/ethernet/ibm/ibmvnic.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
> index 146ca1d8031b..c63d3ec9d328 100644
> --- a/drivers/net/ethernet/ibm/ibmvnic.c
> +++ b/drivers/net/ethernet/ibm/ibmvnic.c
> @@ -296,10 +296,10 @@ static void ibmvnic_set_affinity(struct ibmvnic_adapter *adapter)
>
>                 rc = __netif_set_xps_queue(adapter->netdev,
>                                            cpumask_bits(queue->affinity_mask),
> -                                          i, XPS_CPUS);
> +                                          i_txqs - 1, XPS_CPUS);
>                 if (rc)
>                         netdev_warn(adapter->netdev, "%s: Set XPS on queue %d failed, rc = %d.\n",
> -                                   __func__, i, rc);
> +                                   __func__, i_txqs - 1, rc);
>         }
>
>  out:
> --
> 2.31.1
>
Nick Child Feb. 24, 2023, 4:34 p.m. UTC | #2
On 2/24/23 02:49, Pavan Chebbi wrote:
> On Thu, Feb 23, 2023 at 9:10 PM Nick Child <nnac123@linux.ibm.com> wrote:
>> ---
>>
>> I am a little surprised that __netif_set_xps_queue() did not complain that some
>> index values were greater than the number of tx queues. Though maybe the function
>> assumes that the developers are wise enough :)
> 
> Are you sure an index greater than total tx queues was sent?
> A quick look at ibmvnic_set_affinity() suggests that the condition if
> (... || (i_txqs == num_txqs)) prevents overrunning available tx
> queues.
> 
I believe so. The issue is we were sending "i" to 
__netif_set_xps_queue() , not i_txqs.

Take an example where num_txqs == 2 and num_rxqs == 2:
total_num_q's == 4, so i will loop until until 4.
When we get to i == 2, it will attempt to map XPS values for
the second TX queue (index 1) but we would be giving the value of
i (which is 2). The index of 2 is greater than the number of available 
tx queues. Somehow __netif_set_xps_queue() is still returning a 
successful error code.
>>
>> Should __netif_set_xps_queue() have a check that index < dev->num_tx_queues?
Jakub Kicinski Feb. 25, 2023, 2:36 a.m. UTC | #3
On Thu, 23 Feb 2023 09:39:44 -0600 Nick Child wrote:
> When setting the XPS map value for TX queues, use the index of the
> transmit queue.
> Previously, the function was passing the index of the loop that iterates
> over all queues (RX and TX). This was causing invalid XPS map values.
> 
> Fixes: 6831582937bd ("ibmvnic: Toggle between queue types in affinity mapping")
> Signed-off-by: Nick Child <nnac123@linux.ibm.com>

Applied, thanks!

> I am a little surprised that __netif_set_xps_queue() did not complain that some
> index values were greater than the number of tx queues. Though maybe the function
> assumes that the developers are wise enough :)
> 
> Should __netif_set_xps_queue() have a check that index < dev->num_tx_queues?

Seems reasonable. Let's wait for the merge window to be over and feel
free to send a patch.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 146ca1d8031b..c63d3ec9d328 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -296,10 +296,10 @@  static void ibmvnic_set_affinity(struct ibmvnic_adapter *adapter)
 
 		rc = __netif_set_xps_queue(adapter->netdev,
 					   cpumask_bits(queue->affinity_mask),
-					   i, XPS_CPUS);
+					   i_txqs - 1, XPS_CPUS);
 		if (rc)
 			netdev_warn(adapter->netdev, "%s: Set XPS on queue %d failed, rc = %d.\n",
-				    __func__, i, rc);
+				    __func__, i_txqs - 1, rc);
 	}
 
 out: