All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v3] package: Add cpulimit
@ 2022-05-05 17:22 Florian Fainelli
  2022-05-05 19:41 ` Peter Korsgaard
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2022-05-05 17:22 UTC (permalink / raw)
  To: buildroot; +Cc: Florian Fainelli, mmayer, thomas.petazzoni, yann.morin.1998

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 <f.fainelli@gmail.com>
---
Changes in v3:

- dropped CPULIMIT_SOURCE
- dropped 'v' from CPULIMIT_VERSION
- updated hash file with new tarball name

Changes in v2:

- added DEVELOPERS entry
- back ported 2 patches from upstream project pull requests to address
  build warnings
- added _GNU_SOURCE to the CFLAGS
- added hash file
- corrected check-package warnings

 DEVELOPERS                                    |  3 +
 package/Config.in                             |  1 +
 ...0001-Fix-crash-and-compiler-warnings.patch | 56 +++++++++++++++++++
 ...l.h-and-add-missing-libgen.h-include.patch | 41 ++++++++++++++
 package/cpulimit/Config.in                    |  7 +++
 package/cpulimit/cpulimit.hash                |  3 +
 package/cpulimit/cpulimit.mk                  | 23 ++++++++
 7 files changed, 134 insertions(+)
 create mode 100644 package/cpulimit/0001-Fix-crash-and-compiler-warnings.patch
 create mode 100644 package/cpulimit/0002-Remove-sys-sysctl.h-and-add-missing-libgen.h-include.patch
 create mode 100644 package/cpulimit/Config.in
 create mode 100644 package/cpulimit/cpulimit.hash
 create mode 100644 package/cpulimit/cpulimit.mk

diff --git a/DEVELOPERS b/DEVELOPERS
index 292b91913715..c54b6b5c0979 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -965,6 +965,9 @@ N:	Filip Skoneczny <fskoneczny@gmail.com>
 F:	board/sinovoip/m1-plus
 F:	configs/bananapi_m1_plus_defconfig
 
+N:	Florian Fainelli <f.fainelli@gmail.com>
+F:	package/cpulimit/
+
 N:	Floris Bos <bos@je-eigen-domein.nl>
 F:	package/ipmitool/
 F:	package/odhcploc/
diff --git a/package/Config.in b/package/Config.in
index befeadc27b8b..889213413302 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -2522,6 +2522,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"
diff --git a/package/cpulimit/0001-Fix-crash-and-compiler-warnings.patch b/package/cpulimit/0001-Fix-crash-and-compiler-warnings.patch
new file mode 100644
index 000000000000..826d83097c11
--- /dev/null
+++ b/package/cpulimit/0001-Fix-crash-and-compiler-warnings.patch
@@ -0,0 +1,56 @@
+From d1f42082590bed42cbf6ef1bf37e936df1afbf6b Mon Sep 17 00:00:00 2001
+From: Tobias Tangemann <tobias@tangemann.org>
+Date: Thu, 9 Jul 2015 23:51:07 +0200
+Subject: [PATCH] Fix crash (and compiler warnings)
+
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+---
+ src/cpulimit.c                | 2 +-
+ src/process_group.c           | 4 ++++
+ tests/process_iterator_test.c | 2 +-
+ 3 files changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/src/cpulimit.c b/src/cpulimit.c
+index 50eabeacf214..42d7ca280738 100644
+--- a/src/cpulimit.c
++++ b/src/cpulimit.c
+@@ -43,7 +43,7 @@
+ #include <sys/types.h>
+ #include <sys/wait.h>
+ 
+-#ifdef __APPLE__ || __FREEBSD__
++#if defined(__APPLE__) || defined(__FREEBSD__)
+ #include <libgen.h>
+ #endif
+ 
+diff --git a/src/process_group.c b/src/process_group.c
+index 06d73a6f3541..c9e148cd1b60 100644
+--- a/src/process_group.c
++++ b/src/process_group.c
+@@ -25,6 +25,10 @@
+ #include <sys/time.h>
+ #include <signal.h>
+ 
++#if defined(__APPLE__) || defined(__FREEBSD__)
++#include <libgen.h>
++#endif
++
+ #include <assert.h>
+ 
+ #include "process_iterator.h"
+diff --git a/tests/process_iterator_test.c b/tests/process_iterator_test.c
+index 16151967eb24..1bfc167ba895 100644
+--- a/tests/process_iterator_test.c
++++ b/tests/process_iterator_test.c
+@@ -28,7 +28,7 @@
+ #include <signal.h>
+ #include <string.h>
+ 
+-#ifdef __APPLE__ || __FREEBSD__
++#if defined(__APPLE__) || defined(__FREEBSD__)
+ #include <libgen.h>
+ #endif
+ 
+-- 
+2.25.1
+
diff --git a/package/cpulimit/0002-Remove-sys-sysctl.h-and-add-missing-libgen.h-include.patch b/package/cpulimit/0002-Remove-sys-sysctl.h-and-add-missing-libgen.h-include.patch
new file mode 100644
index 000000000000..283648ed67f2
--- /dev/null
+++ b/package/cpulimit/0002-Remove-sys-sysctl.h-and-add-missing-libgen.h-include.patch
@@ -0,0 +1,41 @@
+From 4c1e021037550c437c7da3a276b95b5bf79e967e Mon Sep 17 00:00:00 2001
+From: Portia <stephensportia@gmail.com>
+Date: Sun, 1 May 2022 12:43:35 +1000
+Subject: [PATCH] Remove sys/sysctl.h and add missing libgen.h include
+
+- sys/sysctl.h has been deprecated and should be removed
+- Adds missing libgen.h include when calling basename()
+
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+---
+ src/cpulimit.c      | 1 -
+ src/process_group.c | 1 +
+ 2 files changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/cpulimit.c b/src/cpulimit.c
+index 50eabeacf214..5b0ec4978f02 100644
+--- a/src/cpulimit.c
++++ b/src/cpulimit.c
+@@ -38,7 +38,6 @@
+ #include <string.h>
+ #include <sys/stat.h>
+ #include <sys/time.h>
+-#include <sys/sysctl.h>
+ #include <sys/resource.h>
+ #include <sys/types.h>
+ #include <sys/wait.h>
+diff --git a/src/process_group.c b/src/process_group.c
+index 06d73a6f3541..d4f6fab3385c 100644
+--- a/src/process_group.c
++++ b/src/process_group.c
+@@ -24,6 +24,7 @@
+ #include <limits.h>
+ #include <sys/time.h>
+ #include <signal.h>
++#include <libgen.h>
+ 
+ #include <assert.h>
+ 
+-- 
+2.25.1
+
diff --git a/package/cpulimit/Config.in b/package/cpulimit/Config.in
new file mode 100644
index 000000000000..f9f39474a2ab
--- /dev/null
+++ b/package/cpulimit/Config.in
@@ -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
diff --git a/package/cpulimit/cpulimit.hash b/package/cpulimit/cpulimit.hash
new file mode 100644
index 000000000000..c6ef4b2e69d1
--- /dev/null
+++ b/package/cpulimit/cpulimit.hash
@@ -0,0 +1,3 @@
+# sha256sum locally computed:
+sha256  64312f9ac569ddcadb615593cd002c94b76e93a0d4625d3ce1abb49e08e2c2da  cpulimit-0.2.tar.gz
+sha256  920489ca9da706d842870701155e70a101315ba0783cff39765d7e15e0916a4a  LICENSE
diff --git a/package/cpulimit/cpulimit.mk b/package/cpulimit/cpulimit.mk
new file mode 100644
index 000000000000..a864685a846f
--- /dev/null
+++ b/package/cpulimit/cpulimit.mk
@@ -0,0 +1,23 @@
+################################################################################
+#
+# cpulimit
+#
+################################################################################
+
+CPULIMIT_VERSION = 0.2
+CPULIMIT_SITE = $(call github,opsengine,cpulimit,v$(CPULIMIT_VERSION))
+CPULIMIT_LICENSE = GPL-2.0+
+CPULIMIT_LICENSE_FILES = LICENSE
+
+define CPULIMIT_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D) \
+		CFLAGS="$(TARGET_CFLAGS) -D_GNU_SOURCE" \
+		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))
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Buildroot] [PATCH v3] package: Add cpulimit
  2022-05-05 17:22 [Buildroot] [PATCH v3] package: Add cpulimit Florian Fainelli
@ 2022-05-05 19:41 ` Peter Korsgaard
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Korsgaard @ 2022-05-05 19:41 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: yann.morin.1998, thomas.petazzoni, mmayer, buildroot

>>>>> "Florian" == Florian Fainelli <f.fainelli@gmail.com> 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 <f.fainelli@gmail.com>
 > ---
 > Changes in v3:

 > - dropped CPULIMIT_SOURCE
 > - dropped 'v' from CPULIMIT_VERSION
 > - updated hash file with new tarball name

 > Changes in v2:

 > - added DEVELOPERS entry
 > - back ported 2 patches from upstream project pull requests to address
 >   build warnings
 > - added _GNU_SOURCE to the CFLAGS
 > - added hash file
 > - corrected check-package warnings

..

 > +++ b/package/cpulimit/0001-Fix-crash-and-compiler-warnings.patch
 > @@ -0,0 +1,56 @@
 > +From d1f42082590bed42cbf6ef1bf37e936df1afbf6b Mon Sep 17 00:00:00 2001
 > +From: Tobias Tangemann <tobias@tangemann.org>
 > +Date: Thu, 9 Jul 2015 23:51:07 +0200
 > +Subject: [PATCH] Fix crash (and compiler warnings)
 > +
 > +Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

I've added links to the upstream pull requests for both patches.

 > +++ b/package/cpulimit/Config.in
 > @@ -0,0 +1,7 @@
 > +config BR2_PACKAGE_CPULIMIT
 > +	bool "cpulimit"

It uses fork(), so I've added a BR2_USE_MMU dependency.

Committed with these fixes, thanks.

-- 
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-05 19:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 17:22 [Buildroot] [PATCH v3] package: Add cpulimit Florian Fainelli
2022-05-05 19:41 ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.