Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CPU affinity on FreeBSD #566

Closed
oberstet opened this issue Dec 31, 2014 · 9 comments
Closed

Support CPU affinity on FreeBSD #566

oberstet opened this issue Dec 31, 2014 · 9 comments

Comments

@oberstet
Copy link

It seems, getting/setting CPU affinity is not supported on FreeBSD:

Python 2.7.8 (a980ebb26592ed26706cd33a4e05eb45b5d3ea09, Dec 13 2014, 07:55:06)
[PyPy 2.4.0 with GCC 4.2.1 Compatible FreeBSD Clang 3.4.1 (tags/RELEASE_34/dot1-final 208032)] on freebsd10
Type "help", "copyright", "credits" or "license" for more information.
>>>> import psutil
>>>> psutil.__version__
'2.1.3'
>>>> p = psutil.Process()
>>>> p.cpu_affinity()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Process' object has no attribute 'cpu_affinity'
>>>>
@giampaolo
Copy link
Owner

Yes, it's not supported because FreeBSD does not support it.

@oberstet
Copy link
Author

FreeBSD does support it: https://www.freebsd.org/cgi/man.cgi?query=cpuset&sektion=2

@giampaolo giampaolo reopened this Dec 31, 2014
@giampaolo
Copy link
Owner

Ah cool! I didn't know that. Added to the TODO list.

@oberstet
Copy link
Author

Awesome! psutil rocks.

@giampaolo
Copy link
Owner

http://sources.freebsd.org/RELENG_9/src/usr.bin/cpuset/cpuset.c is the implementation of the "cpuset" command and looks like the right way to go.

@giampaolo
Copy link
Owner

Implemented in cd37f64

@oberstet
Copy link
Author

oberstet commented Jan 1, 2015

Fantastic! I've tested trunk: works as expected .. cool. We are using psutil in https://github.com/crossbario/crossbar .. and this feature is highly appreciated.

Test system: FreeBSD 10.1 amd64 PyPy 2.4

Thank you very much! Ah, and happy new year;)

@giampaolo
Copy link
Owner

Glad you appreciated it and crossbar.io looks like a very interesting project.
I fixed some (not all) warnings in 842e4fb.
Happy new year to you too. =)

@oberstet
Copy link
Author

oberstet commented Jan 1, 2015

Warnings .. thx! Nearly gone now .. here, just for the record:

cc -O2 -fPIC -Wimplicit -I/usr/local/include -O3 -march=native -I/home/oberstet/pypy1/include -c psutil/_psutil_bsd.c -o build/temp.freebsd-10.1-RELEASE-amd64-2.7/psutil/_psutil_bsd.o
psutil/_psutil_bsd.c:106:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
psutil/_psutil_bsd.c:1160:44: warning: field precision should have type 'int', but argument has type 'unsigned long' [-Wformat]
                    path, sizeof(path), "%.*s",
                                         ~~^~
psutil/_psutil_bsd.c:2004:41: warning: field precision should have type 'int', but argument has type 'unsigned long' [-Wformat]
        snprintf(path, sizeof(path), "%.*s",
                                      ~~^~
3 warnings generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants