ANDROID: fix ABI-break in struct cgroup_root
Fix the ABI issues introduced by commit dd9542ae7c7c ("cgroup: Make
operations on the cgroup root_list RCU safe"). Use _some_ of the bits
reserved in cgroup_root for the new root->rcu member. This new offset
restricts the usage of kfree_rcu() though, so this call has replaced
with call_rcu() instead. Update the stg file with this update:
type 'struct cgroup_root' changed
member 'u8 android_backport_reserved1[28]' was removed
member 'union { struct callback_head rcu; struct { u8 android_backport_reserved1[28]; }; union { }; }' was added
Bug: 379227997
Bug: 383435602
Suggested-by: T.J. Mercier <tjmercier@google.com>
Change-Id: I3e76ca05ee6d68f7167bf487348f438cd2a00d5f
Signed-off-by: Carlos Llamas <cmllamas@google.com>
diff --git a/android/abi_gki_aarch64.stg b/android/abi_gki_aarch64.stg
index b6daf6a..d18b154 100644
--- a/android/abi_gki_aarch64.stg
+++ b/android/abi_gki_aarch64.stg
@@ -42238,6 +42238,10 @@
type_id: 0x34f6a768
}
member {
+ id: 0x2efe0273
+ type_id: 0x34d679de
+}
+member {
id: 0x2f1819a7
type_id: 0x334e168e
}
@@ -43855,6 +43859,11 @@
offset: 256
}
member {
+ id: 0x3f2a640d
+ type_id: 0x7387dd81
+ offset: 49472
+}
+member {
id: 0x3f2df7ff
type_id: 0x7399b0f3
offset: 320
@@ -49702,10 +49711,9 @@
type_id: 0x92233392
}
member {
- id: 0xb2e8fb7e
+ id: 0xb2e8f417
name: "android_backport_reserved1"
type_id: 0x1159eb36
- offset: 49472
}
member {
id: 0x71aeb2cd
@@ -221688,6 +221696,14 @@
}
}
struct_union {
+ id: 0x34d679de
+ kind: STRUCT
+ definition {
+ bytesize: 32
+ member_id: 0xb2e8f417
+ }
+}
+struct_union {
id: 0x34ed11d4
kind: STRUCT
definition {
@@ -225848,6 +225864,16 @@
}
}
struct_union {
+ id: 0x7387dd81
+ kind: UNION
+ definition {
+ bytesize: 32
+ member_id: 0x95dac977
+ member_id: 0x2efe0273
+ member_id: 0x36752b74
+ }
+}
+struct_union {
id: 0x7399b0f3
kind: UNION
definition {
@@ -231430,7 +231456,7 @@
member_id: 0x2d2d08b0
member_id: 0xe8e1b772
member_id: 0x0de6d95b
- member_id: 0xb2e8fb7e
+ member_id: 0x3f2a640d
}
}
struct_union {
diff --git a/android/abi_gki_aarch64.stg.allowed_breaks b/android/abi_gki_aarch64.stg.allowed_breaks
index 0343d10..63be23b 100644
--- a/android/abi_gki_aarch64.stg.allowed_breaks
+++ b/android/abi_gki_aarch64.stg.allowed_breaks
@@ -77,3 +77,6 @@
type 'enum ftrace_dump_mode' changed
enumerator 'DUMP_PARAM' (3) was added
+type 'struct cgroup_root' changed
+ member 'u8 android_backport_reserved1[28]' was removed
+ member 'union { struct callback_head rcu; struct { u8 android_backport_reserved1[28]; }; union { }; }' was added
diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
index c231544..87c57b18 100644
--- a/include/linux/cgroup-defs.h
+++ b/include/linux/cgroup-defs.h
@@ -575,7 +575,6 @@ struct cgroup_root {
/* A list running through the active hierarchies */
struct list_head root_list;
- struct rcu_head rcu;
/* Hierarchy-specific flags */
unsigned int flags;
@@ -586,7 +585,8 @@ struct cgroup_root {
/* The name for this hierarchy - may be empty */
char name[MAX_CGROUP_ROOT_NAMELEN];
- ANDROID_BACKPORT_RESERVE_ARRAY(1, CGROUP_SUBSYS_COUNT * sizeof(atomic_t));
+ ANDROID_BACKPORT_USE_ARRAY(1, CGROUP_SUBSYS_COUNT * sizeof(atomic_t),
+ struct rcu_head rcu);
};
/*
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index f3f3bef..4615555 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -1315,9 +1315,14 @@ static void cgroup_exit_root_id(struct cgroup_root *root)
idr_remove(&cgroup_hierarchy_idr, root->hierarchy_id);
}
+static void __cgroup_free_root(struct rcu_head *rcu)
+{
+ kfree(container_of(rcu, struct cgroup_root, rcu));
+}
+
void cgroup_free_root(struct cgroup_root *root)
{
- kfree_rcu(root, rcu);
+ call_rcu(&root->rcu, __cgroup_free_root);
}
static void cgroup_destroy_root(struct cgroup_root *root)