Skip to contentSkip to conversation

xsk: Return -EINVAL instead of -EBUSY after xsk_get_pool_from_qid() fails

PATCH In review Wang Hai 3 participants 5 messages Jun 2, 2021

Subsystems (4)
lore
Share & tools
lore

Wang Hai

author
#0 lore raw

PATCH 1/1 xsk: Return -EINVAL instead of -EBUSY after xsk_get_pool_from_qid() fails

xsk_get_pool_from_qid() fails not because the device's queues are busy, but because the queue_id exceeds the current number of queues. So when it fails, it is better to return -EINVAL instead of -EBUSY.

---
 net/xdp/xsk_buff_pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/xdp/xsk_buff_pool.c +1 -1
index 8de01aaac4a0..30ece117117a 100644
@@ -135,7 +135,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
 		return -EINVAL;
 
 	if (xsk_get_pool_from_qid(netdev, queue_id))
-		return -EBUSY;
+		return -EINVAL;
 
 	pool->netdev = netdev;
 	pool->queue_id = queue_id;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 15 lines · Wang Hai

xsk_get_pool_from_qid() fails not because the device's queues are busy, but because the queue_id exceeds the current number of queues. So when it fails, it is better to return -EINVAL instead of -EBUSY.

---
 net/xdp/xsk_buff_pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/xdp/xsk_buff_pool.c +0 -0
index 8de01aaac4a0..30ece117117a 100644

net/xdp/xsk_buff_pool.c int xp_assign_dev(struct xsk_buff_pool *pool, · line 138

Quoted 5 lines
net/xdp/xsk_buff_pool.c +1 -1
@@ -135,7 +135,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
                return -EINVAL;
 
        if (xsk_get_pool_from_qid(netdev, queue_id))
-               return -EBUSY;
+               return -EINVAL;

I guess your intent here is to return -EINVAL only when the queue_id is larger than the number of active queues. But this patch also changes the return code when the queue id is already in use and in that case we should continue to return -EBUSY. As this function is used by a number of drivers, the easiest way to accomplish this is to introduce a test for queue_id out of bounds before this if-statement and return -EINVAL there.

Quoted 5 lines
net/xdp/xsk_buff_pool.c +0 -1
        pool->netdev = netdev;
        pool->queue_id = queue_id;
--

2.17.1

#2 lore raw
Quoted 18 lines · Magnus Karlsson
Quoted 17 lines · Wang Hai

xsk_get_pool_from_qid() fails not because the device's queues are busy, but because the queue_id exceeds the current number of queues. So when it fails, it is better to return -EINVAL instead of -EBUSY.

---
 net/xdp/xsk_buff_pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/xdp/xsk_buff_pool.c +0 -0
index 8de01aaac4a0..30ece117117a 100644
@@ -135,7 +135,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
                return -EINVAL;
 
Quoted 11 lines

net/xdp/xsk_buff_pool.c int xp_assign_dev(struct xsk_buff_pool *pool, · line 138

Quoted 3 lines
net/xdp/xsk_buff_pool.c +1 -1
        if (xsk_get_pool_from_qid(netdev, queue_id))
-               return -EBUSY;
+               return -EINVAL;

I guess your intent here is to return -EINVAL only when the queue_id is larger than the number of active queues. But this patch also changes the return code when the queue id is already in use and in that case we should continue to return -EBUSY. As this function is used by a number of drivers, the easiest way to accomplish this is to introduce a test for queue_id out of bounds before this if-statement and return -EINVAL there.

Isn't the return code ABI by now, though?

-Toke

#3 lore raw
Quoted 33 lines · Toke Høiland-Jørgensen
Quoted 18 lines · Magnus Karlsson
Quoted 17 lines · Wang Hai

xsk_get_pool_from_qid() fails not because the device's queues are busy, but because the queue_id exceeds the current number of queues. So when it fails, it is better to return -EINVAL instead of -EBUSY.

---
 net/xdp/xsk_buff_pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/xdp/xsk_buff_pool.c +0 -0
index 8de01aaac4a0..30ece117117a 100644
@@ -135,7 +135,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
                return -EINVAL;
 
Quoted 11 lines

net/xdp/xsk_buff_pool.c int xp_assign_dev(struct xsk_buff_pool *pool, · line 138

Quoted 3 lines
net/xdp/xsk_buff_pool.c +1 -1
        if (xsk_get_pool_from_qid(netdev, queue_id))
-               return -EBUSY;
+               return -EINVAL;

I guess your intent here is to return -EINVAL only when the queue_id is larger than the number of active queues. But this patch also changes the return code when the queue id is already in use and in that case we should continue to return -EBUSY. As this function is used by a number of drivers, the easiest way to accomplish this is to introduce a test for queue_id out of bounds before this if-statement and return -EINVAL there.

Quoted 1 line

Isn't the return code ABI by now, though?

You are probably right and in that case this should not change at all. It has been returning this for quite a while too as it is nothing new. But I leave the final decision to other people on the list.

Quoted 2 lines

-Toke

#4 lore raw
In reply to Magnus Karlsson

Sorry, I misunderstood here, this is a faulty patch and no changes are needed here. Please ignore this patch

Quoted 17 lines · Magnus Karlsson
Quoted 16 lines · Wang Hai

xsk_get_pool_from_qid() fails not because the device's queues are busy, but because the queue_id exceeds the current number of queues. So when it fails, it is better to return -EINVAL instead of -EBUSY.

---
  net/xdp/xsk_buff_pool.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/xdp/xsk_buff_pool.c +0 -0
index 8de01aaac4a0..30ece117117a 100644
@@ -135,7 +135,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
                 return -EINVAL;
 
Quoted 5 lines

net/xdp/xsk_buff_pool.c int xp_assign_dev(struct xsk_buff_pool *pool, · line 138

Quoted 3 lines
net/xdp/xsk_buff_pool.c +1 -1
         if (xsk_get_pool_from_qid(netdev, queue_id))
-               return -EBUSY;
+               return -EINVAL;

I guess your intent here is to return -EINVAL only when the queue_id is larger than the number of active queues.

Yes, I just confirmed that this has been implemented in xp_assign_dev().

int xp_assign_dev()

{

...

    err = xsk_reg_pool_at_qid(netdev, pool, queue_id);

    if (err)

        return err;     //return -EINVAL;

...

}

Quoted 14 lines

But this patch also
changes the return code when the queue id is already in use and in that case we should continue to return -EBUSY. As this function is used by a number of drivers, the easiest way to accomplish this is to introduce a test for queue_id out of bounds before this if-statement and return -EINVAL there.

Quoted 5 lines
net/xdp/xsk_buff_pool.c +0 -1
         pool->netdev = netdev;
         pool->queue_id = queue_id;
--

2.17.1

.