* [Buildroot] [PATCH v2 1/1] cgroupsfs: new package
@ 2016-02-12 14:20 Niranjan Reddy
2016-02-12 15:17 ` Thomas Petazzoni
0 siblings, 1 reply; 4+ messages in thread
From: Niranjan Reddy @ 2016-02-12 14:20 UTC (permalink / raw)
To: buildroot
From: Niranjan <niranjan.reddy@rockwellcollins.com>
This package consists of scripts that setup cgroups at boot
without doing any cgroup management or classification of
tasks into cgroups
Signed-off-by: Niranjan Reddy <niranjan.reddy@rockwellcollins.com>
---
Changes v1 -> v2:
- Changed navigation options in Config.in ( suggested by Arnout).
- Removed CGROUPFS_INSTALL_TARGET and cgroupfs-mount.upstart from cgroupfs.mk file as it was
not required.
- Added S30cgroupfs startup script which gets installed to /etc/init.d
- Added details of version,copyright and licence file.
---
package/Config.in | 1 +
package/cgroupfs/Config.in | 19 +++++++++++++++++
package/cgroupfs/S30cgroupfs | 50 ++++++++++++++++++++++++++++++++++++++++++++
package/cgroupfs/cgroupfs.mk | 22 +++++++++++++++++++
4 files changed, 92 insertions(+)
create mode 100644 package/cgroupfs/Config.in
create mode 100644 package/cgroupfs/S30cgroupfs
create mode 100644 package/cgroupfs/cgroupfs.mk
diff --git a/package/Config.in b/package/Config.in
index a5b31aa..452fd0b 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1571,6 +1571,7 @@ if BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
source "package/dcron/Config.in"
source "package/debianutils/Config.in"
endif
+ source "package/cgroupfs/Config.in"
source "package/dsp-tools/Config.in"
source "package/emlog/Config.in"
source "package/ftop/Config.in"
diff --git a/package/cgroupfs/Config.in b/package/cgroupfs/Config.in
new file mode 100644
index 0000000..e0b685c
--- /dev/null
+++ b/package/cgroupfs/Config.in
@@ -0,0 +1,19 @@
+config BR2_PACKAGE_CGROUPFS
+ bool "cgroupfs"
+ depends on !BR2_INIT_SYSTEMD
+ help
+ cgroupfs mount and umount scripts.
+
+ requires a Linux kernel >= 3.0 with the following options
+ enabled:
+
+ - CONFIG_BLK_CGROUP
+ - CONFIG_CGROUPS
+ - CONFIG_CGROUP_CPUACCT
+ - CONFIG_CGROUP_DEVICE
+ - CONFIG_CGROUP_FREEZER
+ - CONFIG_CGROUP_WRITEBACK
+ - CONFIG_CGROUP_SCHED
+ - CONFIG_CGROUP_PIDS
+
+ https://github.com/tianon/cgroupfs-mount
diff --git a/package/cgroupfs/S30cgroupfs b/package/cgroupfs/S30cgroupfs
new file mode 100644
index 0000000..86819de
--- /dev/null
+++ b/package/cgroupfs/S30cgroupfs
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# cgroupfs: Set up cgroupfs mounts.
+#
+# description: Control groups are a kernel mechanism for tracking and imposing
+# limits on resource usage on groups of tasks.
+#
+#
+
+RETVAL=0
+case "$1" in
+ start)
+ test -x /usr/bin/cgroupfs-mount || exit 0
+ echo "Mounting cgroupfs hierarchy"
+ /usr/bin/cgroupfs-mount
+ RETVAL=$?
+ ;;
+
+ stop)
+ test -x /usr/bin/cgroupfs-umount || exit 0
+ echo "Unmounting cgroupfs hierarchy"
+ /usr/bin/cgroupfs-umount
+ RETVAL=$?
+ ;;
+
+ restart|force-reload)
+ if mountpoint -q /sys/fs/cgroup; then
+ $0 stop
+ fi
+ exec $0 start
+ ;;
+
+ status)
+ if mountpoint -q /sys/fs/cgroup; then
+ # TODO decide whether to detect "partial mounted" status (ie, whether all available subsystems are mounted correctly)
+ echo "cgroupfs hierarchy is mounted"
+ exit 0
+ else
+ echo "cgroupfs hierarchy is not mounted"
+ exit 1
+ fi
+ ;;
+
+ *)
+ echo "Usage: $0 {start|stop|restart|status}"
+ exit 1
+ ;;
+esac
+
+exit $RETVAL
diff --git a/package/cgroupfs/cgroupfs.mk b/package/cgroupfs/cgroupfs.mk
new file mode 100644
index 0000000..8d178ff
--- /dev/null
+++ b/package/cgroupfs/cgroupfs.mk
@@ -0,0 +1,22 @@
+#############################################################
+#
+# cgroupfs
+#
+#############################################################
+CGROUPFS_VERSION = 7285bf44402029394808339f69f4f293730fc2c6
+CGROUPFS_SITE = $(call github,tianon,cgroupfs-mount,$(CGROUPFS_VERSION))
+CGROUPFS_LICENSE = GPL-3+
+CGROUPFS_LICENSE_FILES = COPYRIGHT
+
+define CGROUPFS_INSTALL_TARGET_CMDS
+ $(INSTALL) -D -m 0755 $(@D)/cgroupfs-mount $(TARGET_DIR)/usr/bin/cgroupfs-mount
+ $(INSTALL) -D -m 0755 $(@D)/cgroupfs-umount $(TARGET_DIR)/usr/bin/cgroupfs-umount
+endef
+
+define CGROUPFS_INSTALL_INIT_SYSV
+ $(INSTALL) -m 0755 -D package/cgroupfs/S30cgroupfs \
+ $(TARGET_DIR)/etc/init.d/S30cgroupfs
+
+endef
+
+$(eval $(generic-package))
--
2.5.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH v2 1/1] cgroupsfs: new package
2016-02-12 14:20 [Buildroot] [PATCH v2 1/1] cgroupsfs: new package Niranjan Reddy
@ 2016-02-12 15:17 ` Thomas Petazzoni
2016-02-12 16:14 ` Arnout Vandecappelle
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Petazzoni @ 2016-02-12 15:17 UTC (permalink / raw)
To: buildroot
Hello,
Thanks for this new iteration! See some comments below.
On Fri, 12 Feb 2016 19:50:42 +0530, Niranjan Reddy wrote:
> From: Niranjan <niranjan.reddy@rockwellcollins.com>
We want the first name + last name in the From: field.
> diff --git a/package/cgroupfs/S30cgroupfs b/package/cgroupfs/S30cgroupfs
> new file mode 100644
> index 0000000..86819de
> --- /dev/null
> +++ b/package/cgroupfs/S30cgroupfs
> @@ -0,0 +1,50 @@
> +#!/bin/sh
> +#
> +# cgroupfs: Set up cgroupfs mounts.
> +#
> +# description: Control groups are a kernel mechanism for tracking and imposing
> +# limits on resource usage on groups of tasks.
> +#
> +#
Generally speaking, you should look at some other init scripts in
Buildroot, to be more similar to what they look like.
> +
> +RETVAL=0
> +case "$1" in
> + start)
> + test -x /usr/bin/cgroupfs-mount || exit 0
Not needed.
> + echo "Mounting cgroupfs hierarchy"
Use printf here
> + /usr/bin/cgroupfs-mount
And do something like:
printf "Mounting cgroupfs hierarchy: "
/usr/bin/cgroupfs-mount
[ $? = 0 ] && echo "OK" || echo "FAIL"
> + RETVAL=$?
I don't think there's any need for a RETVAL variable, just do exit $?
at the end of the script, like S50dropbear is doing.
> + ;;
> +
> + stop)
> + test -x /usr/bin/cgroupfs-umount || exit 0
> + echo "Unmounting cgroupfs hierarchy"
> + /usr/bin/cgroupfs-umount
> + RETVAL=$?
> + ;;
> +
> + restart|force-reload)
> + if mountpoint -q /sys/fs/cgroup; then
> + $0 stop
> + fi
> + exec $0 start
> + ;;
> +
> + status)
> + if mountpoint -q /sys/fs/cgroup; then
> + # TODO decide whether to detect "partial mounted" status (ie, whether all available subsystems are mounted correctly)
This comment needs to be wrapped. Or handled :)
> + echo "cgroupfs hierarchy is mounted"
> + exit 0
> + else
> + echo "cgroupfs hierarchy is not mounted"
> + exit 1
> + fi
> + ;;
> +
> + *)
> + echo "Usage: $0 {start|stop|restart|status}"
> + exit 1
> + ;;
> +esac
Also, we often put the start(), stop() and status() code in functions,
so that the indentation remains more reasonable. Again, see S50dropbear
for a pretty good example.
> diff --git a/package/cgroupfs/cgroupfs.mk b/package/cgroupfs/cgroupfs.mk
> new file mode 100644
> index 0000000..8d178ff
> --- /dev/null
> +++ b/package/cgroupfs/cgroupfs.mk
> @@ -0,0 +1,22 @@
> +#############################################################
> +#
> +# cgroupfs
> +#
> +#############################################################
We want 80 hash signs here. Yes that's silly. But we like it :)
And also, an empty new line between this comment header and the first
variable.
> +CGROUPFS_VERSION = 7285bf44402029394808339f69f4f293730fc2c6
> +CGROUPFS_SITE = $(call github,tianon,cgroupfs-mount,$(CGROUPFS_VERSION))
> +CGROUPFS_LICENSE = GPL-3+
Should be GPLv3+
> +CGROUPFS_LICENSE_FILES = COPYRIGHT
> +
> +define CGROUPFS_INSTALL_TARGET_CMDS
> + $(INSTALL) -D -m 0755 $(@D)/cgroupfs-mount $(TARGET_DIR)/usr/bin/cgroupfs-mount
> + $(INSTALL) -D -m 0755 $(@D)/cgroupfs-umount $(TARGET_DIR)/usr/bin/cgroupfs-umount
> +endef
> +
> +define CGROUPFS_INSTALL_INIT_SYSV
> + $(INSTALL) -m 0755 -D package/cgroupfs/S30cgroupfs \
You can use $(CGROUPFS_PKGDIR) instead of package/cgroupfs/
Also, your should add a .hash file to this package.
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH v2 1/1] cgroupsfs: new package
2016-02-12 15:17 ` Thomas Petazzoni
@ 2016-02-12 16:14 ` Arnout Vandecappelle
2016-02-16 6:08 ` Niranjan Reddy
0 siblings, 1 reply; 4+ messages in thread
From: Arnout Vandecappelle @ 2016-02-12 16:14 UTC (permalink / raw)
To: buildroot
On 12-02-16 16:17, Thomas Petazzoni wrote:
> Hello,
>
> Thanks for this new iteration! See some comments below.
>
> On Fri, 12 Feb 2016 19:50:42 +0530, Niranjan Reddy wrote:
>> From: Niranjan <niranjan.reddy@rockwellcollins.com>
[snip]
>> + status)
>> + if mountpoint -q /sys/fs/cgroup; then
>> + # TODO decide whether to detect "partial mounted" status (ie, whether all available subsystems are mounted correctly)
>
> This comment needs to be wrapped. Or handled :)
Actually, we don't need status, only very old init scripts (or init scripts
delivered by the package) have that.
Regards,
Arnout
>
>> + echo "cgroupfs hierarchy is mounted"
>> + exit 0
>> + else
>> + echo "cgroupfs hierarchy is not mounted"
>> + exit 1
>> + fi
>> + ;;
>> +
>> + *)
>> + echo "Usage: $0 {start|stop|restart|status}"
>> + exit 1
>> + ;;
>> +esac
>
> Also, we often put the start(), stop() and status() code in functions,
> so that the indentation remains more reasonable. Again, see S50dropbear
> for a pretty good example.
>
[snip]
--
Arnout Vandecappelle arnout dot vandecappelle at essensium dot com
Senior Embedded Software Architect . . . . . . +32-478-010353 (mobile)
Essensium, Mind division . . . . . . . . . . . . . . http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium . . . . . BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH v2 1/1] cgroupsfs: new package
2016-02-12 16:14 ` Arnout Vandecappelle
@ 2016-02-16 6:08 ` Niranjan Reddy
0 siblings, 0 replies; 4+ messages in thread
From: Niranjan Reddy @ 2016-02-16 6:08 UTC (permalink / raw)
To: buildroot
Hi Arnout & Thomas,
updated all your comments and sent new version (v3) of Patch.
Thanks,
Niranjan Reddy
On Fri, Feb 12, 2016 at 9:44 PM, Arnout Vandecappelle <arnout@mind.be>
wrote:
>
>
> On 12-02-16 16:17, Thomas Petazzoni wrote:
> > Hello,
> >
> > Thanks for this new iteration! See some comments below.
> >
> > On Fri, 12 Feb 2016 19:50:42 +0530, Niranjan Reddy wrote:
> >> From: Niranjan <niranjan.reddy@rockwellcollins.com>
> [snip]
> >> + status)
> >> + if mountpoint -q /sys/fs/cgroup; then
> >> + # TODO decide whether to detect "partial mounted"
> status (ie, whether all available subsystems are mounted correctly)
> >
> > This comment needs to be wrapped. Or handled :)
>
> Actually, we don't need status, only very old init scripts (or init
> scripts
> delivered by the package) have that.
>
>
> Regards,
> Arnout
>
> >
> >> + echo "cgroupfs hierarchy is mounted"
> >> + exit 0
> >> + else
> >> + echo "cgroupfs hierarchy is not mounted"
> >> + exit 1
> >> + fi
> >> + ;;
> >> +
> >> + *)
> >> + echo "Usage: $0 {start|stop|restart|status}"
> >> + exit 1
> >> + ;;
> >> +esac
> >
> > Also, we often put the start(), stop() and status() code in functions,
> > so that the indentation remains more reasonable. Again, see S50dropbear
> > for a pretty good example.
> >
> [snip]
>
> --
> Arnout Vandecappelle arnout dot vandecappelle at essensium dot com
> Senior Embedded Software Architect . . . . . . +32-478-010353 (mobile)
> Essensium, Mind division . . . . . . . . . . . . . . http://www.mind.be
> G.Geenslaan 9, 3001 Leuven, Belgium . . . . . BE 872 984 063 RPR Leuven
> LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
> GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20160216/8713ce6c/attachment.html>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-16 6:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-12 14:20 [Buildroot] [PATCH v2 1/1] cgroupsfs: new package Niranjan Reddy
2016-02-12 15:17 ` Thomas Petazzoni
2016-02-12 16:14 ` Arnout Vandecappelle
2016-02-16 6:08 ` Niranjan Reddy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox