Skip to contentSkip to conversation

accel-config/test: load/unload uacce module at cleanup

PATCH In review ramesh.thomas at intel.com 2 participants 13 messages Apr 6, 2021

lore
Share & tools
lore

ramesh.thomas at intel.com

#0 lore raw

PATCH 1/1 accel-config/test: load/unload uacce module at cleanup

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Cleanup unloads and reloads all idxd kernel modules. This is broken due to idxd_module depending on idxd module. The order of idxd_mdev and idxd_uacce modules are not fixed requiring additional checks during the process.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 test/common | 9 +++++++++
 1 file changed, 9 insertions(+)
test/common +9 -0
index 4bd4ed3..e6e84dd 100644
@@ -99,6 +99,14 @@ check_prereq()
 #
 _cleanup()
 {
+	lsmod | grep -q "idxd_mdev" && {
+		modprobe -r idxd_mdev 2>/dev/null || :
+		sleep 1
+	}
+	lsmod | grep -q "idxd_uacce" && {
+		modprobe -r idxd_uacce
+		sleep 1
+	}
 	lsmod | grep -q "idxd_mdev" && {
 		modprobe -r idxd_mdev
 		sleep 1
@@ -108,6 +116,7 @@ _cleanup()
 		sleep 1
 	}
 	modprobe idxd
+	sleep 1
 }
 
 # json2var
Signature · 1 line
2.26.3
#1 lore raw
Quoted 22 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Cleanup unloads and reloads all idxd kernel modules. This is broken due to idxd_module depending on idxd module. The order of idxd_mdev and idxd_uacce modules are not fixed requiring additional checks during the process.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
  test/common | 9 +++++++++
  1 file changed, 9 insertions(+)
test/common +1 -0
index 4bd4ed3..e6e84dd 100644
@@ -99,6 +99,14 @@ check_prereq()
  #
  _cleanup()
  {
+	lsmod | grep -q "idxd_mdev" && {

test/common check_prereq() · line 112

Quoted 10 lines
test/common +7 -0
+		modprobe -r idxd_mdev 2>/dev/null || :
+		sleep 1
+	}
+	lsmod | grep -q "idxd_uacce" && {
+		modprobe -r idxd_uacce
+		sleep 1
+	}
  	lsmod | grep -q "idxd_mdev" && {
  		modprobe -r idxd_mdev
  		sleep 1

What is the reason having to remove idxd_mdev twice? idxd_uacce shouldn't have any dependency on blocking idxd_mdev from loading....

Quoted 8 lines
test/common +1 -0
@@ -108,6 +116,7 @@ _cleanup()
  		sleep 1
  	}
  	modprobe idxd
+	sleep 1
  }
 
  # json2var
#2 lore raw
Quoted 28 lines · Dave Jiang
Quoted 27 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Cleanup unloads and reloads all idxd kernel modules. This is broken due to idxd_module depending on idxd module. The order of idxd_mdev and idxd_uacce modules are not fixed requiring additional checks during the process.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
  test/common | 9 +++++++++
  1 file changed, 9 insertions(+)
test/common +6 -0
index 4bd4ed3..e6e84dd 100644
@@ -99,6 +99,14 @@ check_prereq()
  #
  _cleanup()
  {
+	lsmod | grep -q "idxd_mdev" && {
+		modprobe -r idxd_mdev 2>/dev/null || :
+		sleep 1
+	}
+	lsmod | grep -q "idxd_uacce" && {
+		modprobe -r idxd_uacce
Quoted 8 lines

test/common check_prereq() · line 112

Quoted 5 lines
test/common +2 -0
+		sleep 1
+	}
  	lsmod | grep -q "idxd_mdev" && {
  		modprobe -r idxd_mdev
  		sleep 1

What is the reason having to remove idxd_mdev twice? idxd_uacce shouldn't have any dependency on blocking idxd_mdev from loading....

The dependncy order of idxd_uacce and idxd_mdev is not fixed. The one that has the other as a dependent would fail if unloaded first. This workaround takes care of both cases, though it is not clean and would be better if driver ensures a fixed dependency order.

Quoted 11 lines
Quoted 10 lines
test/common +1 -0
@@ -108,6 +116,7 @@ _cleanup()
  		sleep 1
  	}
  	modprobe idxd
+	sleep 1
  }
 
  # json2var
#3 lore raw
Quoted 36 lines · Ramesh
Quoted 27 lines · Dave Jiang
Quoted 26 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Cleanup unloads and reloads all idxd kernel modules. This is broken due to idxd_module depending on idxd module. The order of idxd_mdev and idxd_uacce modules are not fixed requiring additional checks during the process.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
   test/common | 9 +++++++++
   1 file changed, 9 insertions(+)
test/common +5 -0
index 4bd4ed3..e6e84dd 100644
@@ -99,6 +99,14 @@ check_prereq()
   #
   _cleanup()
   {
+lsmod | grep -q "idxd_mdev" && {
+modprobe -r idxd_mdev 2>/dev/null || :
+sleep 1
+}
+lsmod | grep -q "idxd_uacce" && {
Quoted 8 lines

test/common check_prereq() · line 112

Quoted 6 lines
test/common +3 -0
+modprobe -r idxd_uacce
+sleep 1
+}
   lsmod | grep -q "idxd_mdev" && {
   modprobe -r idxd_mdev
   sleep 1

What is the reason having to remove idxd_mdev twice? idxd_uacce shouldn't have any dependency on blocking idxd_mdev from loading....

Quoted 4 lines

The dependncy order of idxd_uacce and idxd_mdev is not fixed. The one that has the other as a dependent would fail if unloaded first. This workaround takes care of both cases, though it is not clean and would be better if driver ensures a fixed dependency order.

Huh I'm surprised that there is dependency between the two at all. They each really should be dependent on idxd.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
test/common +1 -0
@@ -108,6 +116,7 @@ _cleanup()
   sleep 1
   }
   modprobe idxd
+sleep 1
   }
 
   # json2var
#4 lore raw
Quoted 38 lines · Dave Jiang
Quoted 36 lines · Ramesh
Quoted 35 lines · Dave Jiang
Quoted 22 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Cleanup unloads and reloads all idxd kernel modules. This is broken due to idxd_module depending on idxd module. The order of idxd_mdev and idxd_uacce modules are not fixed requiring additional checks during the process.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
   test/common | 9 +++++++++
   1 file changed, 9 insertions(+)
test/common +1 -0
index 4bd4ed3..e6e84dd 100644
@@ -99,6 +99,14 @@ check_prereq()
   #
   _cleanup()
   {
+lsmod | grep -q "idxd_mdev" && {

test/common check_prereq() · line 112

Quoted 10 lines
test/common +7 -0
+modprobe -r idxd_mdev 2>/dev/null || :
+sleep 1
+}
+lsmod | grep -q "idxd_uacce" && {
+modprobe -r idxd_uacce
+sleep 1
+}
   lsmod | grep -q "idxd_mdev" && {
   modprobe -r idxd_mdev
   sleep 1

What is the reason having to remove idxd_mdev twice? idxd_uacce shouldn't have any dependency on blocking idxd_mdev from loading....

Quoted 7 lines
Quoted 4 lines

The dependncy order of idxd_uacce and idxd_mdev is not fixed. The one that has the other as a dependent would fail if unloaded first. This workaround takes care of both cases, though it is not clean and would be better if driver ensures a fixed dependency order.

Huh I'm surprised that there is dependency between the two at all. They each really should be dependent on idxd.

It complains about idxd being busy so it is possible the dependency is inside idxd. However, if the unload order is switched between uacce and mdev, then it would unload ok. The failing order is random.

Should we remove the code doing the unload and reload of modules in dsa_test? I don't think we should need to unload and reload drivers after every test which will only hide driver instability issues.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
test/common +1 -0
@@ -108,6 +116,7 @@ _cleanup()
   sleep 1
   }
   modprobe idxd
+sleep 1
   }
 
   # json2var
#5 lore raw
Quoted 42 lines · Ramesh
Quoted 41 lines · Dave Jiang
Quoted 40 lines · Ramesh
Quoted 27 lines · Dave Jiang
Quoted 26 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Cleanup unloads and reloads all idxd kernel modules. This is broken due to idxd_module depending on idxd module. The order of idxd_mdev and idxd_uacce modules are not fixed requiring additional checks during the process.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
    test/common | 9 +++++++++
    1 file changed, 9 insertions(+)
test/common +5 -0
index 4bd4ed3..e6e84dd 100644
@@ -99,6 +99,14 @@ check_prereq()
    #
    _cleanup()
    {
+lsmod | grep -q "idxd_mdev" && {
+modprobe -r idxd_mdev 2>/dev/null || :
+sleep 1
+}
+lsmod | grep -q "idxd_uacce" && {
Quoted 8 lines

test/common check_prereq() · line 112

Quoted 6 lines
test/common +3 -0
+modprobe -r idxd_uacce
+sleep 1
+}
    lsmod | grep -q "idxd_mdev" && {
    modprobe -r idxd_mdev
    sleep 1

What is the reason having to remove idxd_mdev twice? idxd_uacce shouldn't have any dependency on blocking idxd_mdev from loading....

The dependncy order of idxd_uacce and idxd_mdev is not fixed. The one that has the other as a dependent would fail if unloaded first. This workaround takes care of both cases, though it is not clean and would be better if driver ensures a fixed dependency order.

Quoted 5 lines
Quoted 2 lines

Huh I'm surprised that there is dependency between the two at all. They each really should be dependent on idxd.

It complains about idxd being busy so it is possible the dependency is inside idxd. However, if the unload order is switched between uacce and mdev, then it would unload ok. The failing order is random.

That is definitely strange. I wonder if it has to do with idxd/sysfs/udev. Guess not a big deal if we need to wait for things to settle.

Quoted 4 lines

Should we remove the code doing the unload and reload of modules in dsa_test? I don't think we should need to unload and reload drivers after every test which will only hide driver instability issues.

Well for dsa_test, the idea was that we are running on a fresh slate and not inherit something from a previous test. That way any issue we found is no dependency on previous tests. Also after the test is run, we probably want to unload for another test or even just operation for something else. It also excercises the load/unload and see if we hit any issues from that.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
test/common +1 -0
@@ -108,6 +116,7 @@ _cleanup()
    sleep 1
    }
    modprobe idxd
+sleep 1
    }
 
    # json2var
Reviewed-by on v1 1/1
#6 lore raw
In reply to ramesh.thomas at intel.com
Quoted 9 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Cleanup unloads and reloads all idxd kernel modules. This is broken due to idxd_module depending on idxd module. The order of idxd_mdev and idxd_uacce modules are not fixed requiring additional checks during the process.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>

I would maybe add a comment explaining the weird behavior observed.

Reviewed-by Dave Jiang <dave.jiang(a)intel.com>
Quoted 31 lines
---
  test/common | 9 +++++++++
  1 file changed, 9 insertions(+)
test/common +9 -0
index 4bd4ed3..e6e84dd 100644
@@ -99,6 +99,14 @@ check_prereq()
  #
  _cleanup()
  {
+	lsmod | grep -q "idxd_mdev" && {
+		modprobe -r idxd_mdev 2>/dev/null || :
+		sleep 1
+	}
+	lsmod | grep -q "idxd_uacce" && {
+		modprobe -r idxd_uacce
+		sleep 1
+	}
  	lsmod | grep -q "idxd_mdev" && {
  		modprobe -r idxd_mdev
  		sleep 1
@@ -108,6 +116,7 @@ _cleanup()
  		sleep 1
  	}
  	modprobe idxd
+	sleep 1
  }
 
  # json2var
#7 lore raw
Quoted 9 lines · Dave Jiang
Quoted 7 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Cleanup unloads and reloads all idxd kernel modules. This is broken due to idxd_module depending on idxd module. The order of idxd_mdev and idxd_uacce modules are not fixed requiring additional checks during the process.

Quoted 4 lines
Quoted 2 lines
Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>

I would maybe add a comment explaining the weird behavior observed.

I have a new finding. Even though "modprobe -r" returns failure and prints error message "modprobe: FATAL: Module idxd is in use.", the module is still unloaded. It does not give that error on the second module that is unloaded so I earlier thought it has to do with the order. This seems to be a bug in the driver and is easily reproducible.

Since it returns failure, the test script aborts with error. I will modify the workaround to not trap on the error and continue. That way we don't need the second unload attempt of the same module. I will add a comment describing this as a workaround for the above behavior.

Quoted 35 lines
Reviewed-by Dave Jiang <dave.jiang(a)intel.com>
Quoted 31 lines
---
  test/common | 9 +++++++++
  1 file changed, 9 insertions(+)
test/common +9 -0
index 4bd4ed3..e6e84dd 100644
@@ -99,6 +99,14 @@ check_prereq()
  #
  _cleanup()
  {
+	lsmod | grep -q "idxd_mdev" && {
+		modprobe -r idxd_mdev 2>/dev/null || :
+		sleep 1
+	}
+	lsmod | grep -q "idxd_uacce" && {
+		modprobe -r idxd_uacce
+		sleep 1
+	}
  	lsmod | grep -q "idxd_mdev" && {
  		modprobe -r idxd_mdev
  		sleep 1
@@ -108,6 +116,7 @@ _cleanup()
  		sleep 1
  	}
  	modprobe idxd
+	sleep 1
  }
 
  # json2var
#8 lore raw
Quoted 9 lines · Ramesh
Quoted 8 lines · Dave Jiang
Quoted 7 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Cleanup unloads and reloads all idxd kernel modules. This is broken due to idxd_module depending on idxd module. The order of idxd_mdev and idxd_uacce modules are not fixed requiring additional checks during the process.

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>

I would maybe add a comment explaining the weird behavior observed.

I have a new finding. Even though "modprobe -r" returns failure and prints error message "modprobe: FATAL: Module idxd is in use.", the module is still unloaded. It does not give that error on the second module that is unloaded so I earlier thought it has to do with the order. This seems to be a bug in the driver and is easily reproducible.

Hmm.....if so it would be more in the device driver framework than the driver. The driver only supply the init/remove callbacks. It doesn't have any control over the load/unload mechanism. It can hold ref count on the module, but we don't do that.

Quoted 6 lines

Since it returns failure, the test script aborts with error. I will modify the workaround to not trap on the error and continue. That way we don't need the second unload attempt of the same module. I will add a comment describing this as a workaround for the above behavior.

Does rmmod complain? That's usually what I use.

Quoted 34 lines
Quoted 34 lines
Reviewed-by Dave Jiang <dave.jiang(a)intel.com>
Quoted 31 lines
---
   test/common | 9 +++++++++
   1 file changed, 9 insertions(+)
test/common +9 -0
index 4bd4ed3..e6e84dd 100644
@@ -99,6 +99,14 @@ check_prereq()
   #
   _cleanup()
   {
+lsmod | grep -q "idxd_mdev" && {
+modprobe -r idxd_mdev 2>/dev/null || :
+sleep 1
+}
+lsmod | grep -q "idxd_uacce" && {
+modprobe -r idxd_uacce
+sleep 1
+}
   lsmod | grep -q "idxd_mdev" && {
   modprobe -r idxd_mdev
   sleep 1
@@ -108,6 +116,7 @@ _cleanup()
   sleep 1
   }
   modprobe idxd
+sleep 1
   }
 
   # json2var
#9 lore raw
Quoted 20 lines · Dave Jiang
Quoted 9 lines · Ramesh
Quoted 8 lines · Dave Jiang
Quoted 7 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Cleanup unloads and reloads all idxd kernel modules. This is broken due to idxd_module depending on idxd module. The order of idxd_mdev and idxd_uacce modules are not fixed requiring additional checks during the process.

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>

I would maybe add a comment explaining the weird behavior observed.

I have a new finding. Even though "modprobe -r" returns failure and prints error message "modprobe: FATAL: Module idxd is in use.", the module is still unloaded. It does not give that error on the second module that is unloaded so I earlier thought it has to do with the order. This seems to be a bug in the driver and is easily reproducible.

Quoted 4 lines

Hmm.....if so it would be more in the device driver framework than the driver. The driver only supply the init/remove callbacks. It doesn't have any control over the load/unload mechanism. It can hold ref count on the module, but we don't do that.

It returns an error and prints "FATAL" in the message so it does look like a real bug. I think I know what is going on, though I don't know why. When the second module is unloaded, modprobe also unloads idxd. Which means whenever it unloads either idxd_mdev or idxd_uacce, it tries to unload idxd and fails if another module dependent on idxd is still loaded blocking idxd from getting unloaded. Do you think idxd should maintain a reference count or similar indication so modprobe does not try to unload it when a dependent module is unloaded while other dependent ones are still active?

Quoted 9 lines
Quoted 8 lines

Since it returns failure, the test script aborts with error. I will modify the workaround to not trap on the error and continue. That way we don't need the second unload attempt of the same module. I will add a comment describing this as a workaround for the above behavior.

Does rmmod complain? That's usually what I use.

rmmod does not complain. For now I can us it instead of modprobe.

#10 lore raw
Quoted 23 lines · Ramesh
Quoted 18 lines · Dave Jiang
Quoted 9 lines · Ramesh
Quoted 8 lines · Dave Jiang
Quoted 7 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Cleanup unloads and reloads all idxd kernel modules. This is broken due to idxd_module depending on idxd module. The order of idxd_mdev and idxd_uacce modules are not fixed requiring additional checks during the process.

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>

I would maybe add a comment explaining the weird behavior observed.

I have a new finding. Even though "modprobe -r" returns failure and prints error message "modprobe: FATAL: Module idxd is in use.", the module is still unloaded. It does not give that error on the second module that is unloaded so I earlier thought it has to do with the order. This seems to be a bug in the driver and is easily reproducible.

Quoted 4 lines

Hmm.....if so it would be more in the device driver framework than the driver. The driver only supply the init/remove callbacks. It doesn't have any control over the load/unload mechanism. It can hold ref count on the module, but we don't do that.

Quoted 9 lines

It returns an error and prints "FATAL" in the message so it does look like a real bug. I think I know what is going on, though I don't know why. When the second module is unloaded, modprobe also unloads idxd. Which means whenever it unloads either idxd_mdev or idxd_uacce, it tries to unload idxd and fails if another module dependent on idxd is still loaded blocking idxd from getting unloaded. Do you think idxd should maintain a reference count or similar indication so modprobe does not try to unload it when a dependent module is unloaded while other dependent ones are still active?

Ah I guess that makes sense. But idxd actually knows nothing about the other drivers depending on it. So I don't think we can do anything about that. I think that is the behavior of modprobe -r where it tries to unload all the relevant modules. I think for our purpose, rmmod works better as it just unloads the module you specify. Here's from the man page. Essentially it tries to remove the other module. But I guess it's not smart enough to be aware of dependency from some other module on the module it attempts to remove.

       -r, --remove
           This option causes modprobe to remove rather than insert a
module. If the modules it
           depends on are also unused, modprobe will try to remove them
too. Unlike insertion, more
           than one module can be specified on the command line (it
does not make sense to specify
           module parameters when removing modules).

Quoted 11 lines
Quoted 8 lines
Quoted 7 lines

Since it returns failure, the test script aborts with error. I will modify the workaround to not trap on the error and continue. That way we don't need the second unload attempt of the same module. I will add a comment describing this as a workaround for the above behavior.

Does rmmod complain? That's usually what I use.

rmmod does not complain. For now I can us it instead of modprobe.

#11 lore raw

-r, --remove

This option causes modprobe to remove rather than insert a

module. If the modules it depends on are also unused, modprobe will try to remove them

too. Unlike insertion, more than one module can be specified on the command line (it

does not make sense to specify module parameters when removing modules).

Maybe a bug in modprobe? It shouldn’t try to remove idxd when the first of the

dependent modules is removed (because idxd is still “in use” by the other).

Either that, or IDXD and these two dependent modules aren’t setting the right

bits to let modprobe know what is going on?

-Tony