From d8e489443c23ad1b9753ee1b442bd586e1606796 Mon Sep 17 00:00:00 2001 From: Kenfe-Mickael Laventure Date: Wed, 11 Oct 2017 10:01:01 -0700 Subject: [PATCH] linux: Ensure count is 64bits aligned for proper atomic use on 32bits machines Signed-off-by: Kenfe-Mickael Laventure --- metrics/cgroups/oom.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/metrics/cgroups/oom.go b/metrics/cgroups/oom.go index 5a91becb3..196c8fb07 100644 --- a/metrics/cgroups/oom.go +++ b/metrics/cgroups/oom.go @@ -44,11 +44,14 @@ type oomCollector struct { } type oom struct { + // count needs to stay the first member of this struct to ensure 64bits + // alignment on a 32bits machine (e.g. arm32). This is necessary as we use + // the sync/atomic operations on this field. + count int64 id string namespace string c cgroups.Cgroup triggers []Trigger - count int64 } func (o *oomCollector) Add(id, namespace string, cg cgroups.Cgroup, triggers ...Trigger) error {