package: Add cpulimit
PATCH 1/1 package: Add cpulimit
Cpulimit is a tool which limits the CPU usage of a process (expressed in percentage, not in CPU time). It is useful to control batch jobs, when you don't want them to eat too many CPU cycles.
--- package/Config.in | 1 + package/cpulimit/Config.in | 7 +++++++ package/cpulimit/cpulimit.mk | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 package/cpulimit/Config.in create mode 100644 package/cpulimit/cpulimit.mk
package/Config.in +1 -0
@@ -2524,6 +2524,7 @@ menu "System tools" source "package/circus/Config.in" source "package/containerd/Config.in" source "package/coreutils/Config.in" + source "package/cpulimit/Config.in" source "package/cpuload/Config.in" source "package/daemon/Config.in" source "package/dc3dd/Config.in"
package/cpulimit/Config.in new file +7 -0
@@ -0,0 +1,7 @@ +config BR2_PACKAGE_CPULIMIT + bool "cpulimit" + help + Cpulimit is a tool which limits the CPU usage of a process (expressed + in percentage, not in CPU time) + + https://github.com/opsengine/cpulimit
package/cpulimit/cpulimit.mk new file +23 -0
@@ -0,0 +1,23 @@ +################################################################################ +# +# cpulimit +# +################################################################################ + +CPULIMIT_VERSION = v0.2 +CPULIMIT_SOURCE = $(CPULIMIT_VERSION).tar.gz +CPULIMIT_SITE = https://github.com/opsengine/cpulimit/archive/refs/tags/$(CPULIMIT_VERSION) +CPULIMIT_LICENSE = GPL-2.0+ +CPULIMIT_LICENSE_FILES = LICENSE + +define CPULIMIT_BUILD_CMDS + $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D) \ + LDLIBS="$(TARGET_LDFLAGS)" +endef + +define CPULIMIT_INSTALL_TARGET_CMDS + $(INSTALL) -D -m 0755 $(@D)/src/cpulimit \ + $(TARGET_DIR)/usr/bin/cpulimit +endef + +$(eval $(generic-package))
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Florian" == Florian Fainelli <[email protected]> writes:
Cpulimit is a tool which limits the CPU usage of a process (expressed in percentage, not in CPU time). It is useful to control batch jobs, when you don't want them to eat too many CPU cycles.
Signed-off-by Florian Fainelli <[email protected]>
Thanks, a few comments:
Quoted 7 lines
--- package/Config.in | 1 + package/cpulimit/Config.in | 7 +++++++ package/cpulimit/cpulimit.mk | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 package/cpulimit/Config.in create mode 100644 package/cpulimit/cpulimit.mk
You are missing a cpulimit.hash with the tarball and license file hashes:
https://nightly.buildroot.org/#adding-packages-hash
And an entry in DEVELOPERS:
https://nightly.buildroot.org/#DEVELOPERS
Quoted 18 lines
package/Config.in +1
-0@@ -2524,6 +2524,7 @@ menu "System tools" source "package/circus/Config.in" source "package/containerd/Config.in" source "package/coreutils/Config.in" + source "package/cpulimit/Config.in" source "package/cpuload/Config.in" source "package/daemon/Config.in" source "package/dc3dd/Config.in"package/cpulimit/Config.in new file +0
-0
package/cpulimit/Config.in line 5
Quoted 5 lines
package/cpulimit/Config.in new file +5
-0@@ -0,0 +1,7 @@ +config BR2_PACKAGE_CPULIMIT + bool "cpulimit" + help + Cpulimit is a tool which limits the CPU usage of a process (expressed + in percentage, not in CPU time)
./utils/check-package complains about the line length here:
package/cpulimit/Config.in:4: help text: <tab><2 spaces><62 chars> (http://nightly.buildroot.org/#writing-rules-config-in)
Quoted 8 lines
package/cpulimit/Config.in new file +2
-0+ + https://github.com/opsengine/cpulimitpackage/cpulimit/cpulimit.mk new file +0
-0
package/cpulimit/cpulimit.mk line 9
Quoted 9 lines
package/cpulimit/cpulimit.mk new file +9
-0@@ -0,0 +1,23 @@ +################################################################################ +# +# cpulimit +# +################################################################################ + +CPULIMIT_VERSION = v0.2 +CPULIMIT_SOURCE = $(CPULIMIT_VERSION).tar.gz +CPULIMIT_SITE = https://github.com/opsengine/cpulimit/archive/refs/tags/$(CPULIMIT_VERSION)
We have a github helper, so you can just do:
CPULIMIT_VERSION = 0.2CPULIMIT_SITE = $(call github,opsengine,cpulimit,v$(CPULIMIT_VERSION))
I did a test build here and it fails to build with glibc, as it uses sys/sysctl.h (which was removed in glibc 2.32):
* The deprecated <sys/sysctl.h> header and the sysctl function have been removed. To support old binaries, the sysctl function continues to exist as a compatibility symbol (on those architectures which had it), but always fails with ENOSYS. This reflects the removal of the system call from all architectures, starting with Linux 5.5.
Does this utility work with 5.5+ kernels? Musl afaik also doesn't have sys/sysctl.h.
process_group.c: In function ‘find_process_by_name’:
process_group.c:64:15: warning: implicit declaration of function ‘basename’ [-Wimplicit-function-declaration]
64 | if (strncmp(basename(proc.command), process_name, strlen(process_name))==0 && kill(pid,SIGCONT)==0) {
| ^~~~~~~~
process_group.c:64:15: warning: passing argument 1 of ‘strncmp’ makes pointer from integer without a cast [-Wint-conversion]
64 | if (strncmp(basename(proc.command), process_name, strlen(process_name))==0 && kill(pid,SIGCONT)==0) {
| ^~~~~~~~~~~~~~~~~~~~~~
| |
| int
In file included from process_group.c:22:
/home/peko/source/buildroot/output/host/aarch64-buildroot-linux-gnu/sysroot/usr/include/string.h:143:33: note: expected ‘const char *’ but argument is of type ‘int’
143 | extern int strncmp (const char *__s1, const char *__s2, size_t __n)
| ~~~~~~~~~~~~^~~~
/home/peko/source/buildroot/output/host/bin/aarch64-none-linux-gnu-gcc -o cpulimit cpulimit.c list.o process_iterator.o process_group.o -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -g0 -D_FORTIFY_SOURCE=1
cpulimit.c:41:10: fatal error: sys/sysctl.h: No such file or directory
41 | #include <sys/sysctl.h>
| ^~~~~~~~~~~~~~compilation terminated.
I didn't look at the code, but it would be good to make it work on modern systems. Alternatively you will need to make it depend on uClibc.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 18 lines · Peter Korsgaard
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Florian" == Florian Fainelli <[email protected]> writes:
Cpulimit is a tool which limits the CPU usage of a process (expressed in percentage, not in CPU time). It is useful to control batch jobs, when you don't want them to eat too many CPU cycles.
Signed-off-by Florian Fainelli <[email protected]>Thanks, a few comments:
Quoted 7 lines
--- package/Config.in | 1 + package/cpulimit/Config.in | 7 +++++++ package/cpulimit/cpulimit.mk | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 package/cpulimit/Config.in create mode 100644 package/cpulimit/cpulimit.mk
Quoted 8 lines
You are missing a cpulimit.hash with the tarball and license file hashes:
https://nightly.buildroot.org/#adding-packages-hash
And an entry in DEVELOPERS:
Will update, thanks!
Quoted 55 lines
Quoted 19 lines
package/Config.in +1
-0@@ -2524,6 +2524,7 @@ menu "System tools" source "package/circus/Config.in" source "package/containerd/Config.in" source "package/coreutils/Config.in" + source "package/cpulimit/Config.in" source "package/cpuload/Config.in" source "package/daemon/Config.in" source "package/dc3dd/Config.in"package/cpulimit/Config.in new file +0
-0package/cpulimit/Config.in line 5
Quoted 5 lines
package/cpulimit/Config.in new file +5
-0@@ -0,0 +1,7 @@ +config BR2_PACKAGE_CPULIMIT + bool "cpulimit" + help + Cpulimit is a tool which limits the CPU usage of a process (expressed + in percentage, not in CPU time)./utils/check-package complains about the line length here:
package/cpulimit/Config.in:4: help text: <tab><2 spaces><62 chars> (http://nightly.buildroot.org/#writing-rules-config-in)
Quoted 8 lines
package/cpulimit/Config.in new file +2
-0+ + https://github.com/opsengine/cpulimitpackage/cpulimit/cpulimit.mk new file +0
-0package/cpulimit/cpulimit.mk line 9
Quoted 9 lines
package/cpulimit/cpulimit.mk new file +9
-0@@ -0,0 +1,23 @@ +################################################################################ +# +# cpulimit +# +################################################################################ + +CPULIMIT_VERSION = v0.2 +CPULIMIT_SOURCE = $(CPULIMIT_VERSION).tar.gz +CPULIMIT_SITE = https://github.com/opsengine/cpulimit/archive/refs/tags/$(CPULIMIT_VERSION)We have a github helper, so you can just do:
CPULIMIT_VERSION= 0.2CPULIMIT_SITE= $(call github,opsengine,cpulimit,v$(CPULIMIT_VERSION))I did a test build here and it fails to build with glibc, as it uses
sys/sysctl.h(which was removed in glibc 2.32):
Quoted 8 lines
* The deprecated <
sys/sysctl.h> header and the sysctl function have been removed. To support old binaries, the sysctl function continues to exist as a compatibility symbol (on those architectures which had it), but always fails with ENOSYS. This reflects the removal of the system call from all architectures, starting with Linux 5.5.Does this utility work with 5.5+ kernels? Musl afaik also doesn't have
sys/sysctl.h.
It does work with 5.10, but it was built with a toolchain that used 4.1 kernel headers and glibc 2.27, so I did not see that.
Quoted 18 lines
process_group.c: In function ‘find_process_by_name’:
process_group.c:64:15: warning: implicit declaration of function ‘basename’ [-Wimplicit-function-declaration]64 | if (strncmp(basename(proc.command), process_name, strlen(process_name))==0 && kill(pid,SIGCONT)==0) { | ^~~~~~~~ process_group.c:64:15: warning: passing argument 1 of ‘strncmp’ makes pointer from integer without a cast [-Wint-conversion] 64 | if (strncmp(basename(proc.command), process_name, strlen(process_name))==0 && kill(pid,SIGCONT)==0) { | ^~~~~~~~~~~~~~~~~~~~~~ | | | int In file included from process_group.c:22: /home/peko/source/buildroot/output/host/aarch64-buildroot-linux-gnu/sysroot/usr/include/string.h:143:33: note: expected ‘const char *’ but argument is of type ‘int’ 143 | extern int strncmp (const char *__s1, const char *__s2, size_t __n) | ~~~~~~~~~~~~^~~~ /home/peko/source/buildroot/output/host/bin/aarch64-none-linux-gnu-gcc -o cpulimit cpulimit.c list.o process_iterator.o process_group.o -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -g0 -D_FORTIFY_SOURCE=1 cpulimit.c:41:10: fatal error: sys/sysctl.h: No such file or directory 41 | #include <sys/sysctl.h> | ^~~~~~~~~~~~~~
Quoted 6 lines
compilation terminated.
I didn't look at the code, but it would be good to make it work on modern systems. Alternatively you will need to make it depend on uClibc.
For sure, I will submit a v2 after going through the various pull requests and issues to see if those are not already fixed.
Thanks Peter!
Signature · 5 lines
Florian _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot