# cpuset problem



## antolap (Dec 17, 2017)

On a machine, with one processor (two cores), I get errors using cpuset:


```
# /usr/bin/cpuset  -l 0 -s 1                                                                                        
cpuset: setaffinity: Resource deadlock avoided

also trying with -l1:

# /usr/bin/cpuset  -l 1 -s 1
cpuset: setaffinity: Resource deadlock avoided

# uname -a
FreeBSD bsd11-4g 11.1-RELEASE-p4 FreeBSD 11.1-RELEASE-p4 #0: Tue Nov 14 06:12:40 UTC 2017     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
```

why?


----------



## Snurg (Dec 17, 2017)

Now that is funny.
I guess you found your computer bogged down by some strange processes regarding millions of files and megabyte-sized arglists.
And you now want to restrict those strange processes to a subset of the CPUs you have.

I didn't know of the `cpuset` utility before, got curious, read the `man` page, and it answers a low-priority question I had. Namely how to reserve one processor core to handle important controller I/O that does not allow delays like from normal scheduler.
So I actually got an useful tip from you, and this is why you got your second <Thanks> since you joined the forums.

Regarding your question, I give you a hint.
_Try to create a cpuset first and use that._


----------



## antolap (Dec 17, 2017)

Snurg, the computer on which I compiled the custom kernel with ARG_MAX = 2 billions is for my use only and I'm not crazy to ask support for it, I know that it's very unstable, and that It could happen a lot of strange things there..

This computer instead, where I'm running `cpuset`, is perfectly working with 11.1 release of FreeBSD (unmodified) installed on it


----------



## Snurg (Dec 17, 2017)

Ok, then the process basically is to create cpusets.
That are data structures which the kernel uses.

Basically you say:
I want to have process/jail/whatever exclusive access to cpu #2.

Thus you create a permit form. It says "Permit #2". Because #0 and #1 are reserved for system usage.

Then you write, for example "Programs cpueater1 and cpueater2 are allowed exclusively to eat cpu #2."
Finally you give that form to the kernel scheduler.

Bingo!


----------



## antolap (Dec 17, 2017)

Could you help me?
If I do:
`cpuset -l 0 myprogram`
all is ok: myprogram works on core 0

If I do:
`cpuset -l 1 myprogram`
all is ok: myprogram works on core 1

What I'd like to do is to say to operating system, to not schedule anything on core1, so that I can you it freely
I don't understand why it says:


> Resource deadlock avoided



Please help me
Thanks


----------



## antolap (Dec 17, 2017)

I'm near the solution: I need to change it at boot time


----------

