Process-control should also support taskset

Setting CPU-affinity for a process with taskset is not handled by process-control plug. The following error is observed. The solution as of now is to stage util-linux package along with snap but ideally I would love to have it controlled by process-control plug (as nice is already handled with the plug) .

# critcal_service
#!/bin/sh -
nice --19 taskset -c 1  $SNAP/bin/my_serv

= AppArmor =
Time: Feb 16 16:00:12
Log: apparmor="DENIED" operation="exec" profile="snap.mysnap.crtical_service" name="/usr/bin/taskset" 

pid=27578 comm=“nice” requested_mask=“x” denied_mask=“x” fsuid=0 ouid=0
File: /usr/bin/taskset (exec)
Suggestions:
* adjust snap to ship ‘taskset’
* adjust program to use relative paths if the snap already ships ‘taskset’

That error actually tells you that the problem is that your command cannot find the command taskset. It does not indicate that the cpu affinity call is unsupported at all. While you might be correct that the cpu affinity won’t work your log does not state that. Instead it states what you should do, namely add taskset into your snap.

@lucyllewy thanks for the reply, Yes I do understand the error and as I have mentioned I also have the issue resolved by packaging taskset along with my snap. What I am actually expecting is that this feature (setting cpu affinity with taskset should be handled by process-control plug it self rather that we packaging the binary (call it a feature request or enhancement).

I’ve added this to the list of the next batch of policy investigations/updates. Thanks for the report!

Thanks @jdstrand , looking forward

FYI, https://github.com/snapcore/snapd/pull/5006

1 Like