Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 5e9a8cb

Browse files
Sai Harshini Nimmalatoddkjos
authored andcommitted
ANDROID: GKI: Add to task_struct size via cmdline
To reduce the size of vendor data allocated in the task_struct, from 512 bytes to a significantly lower 48 bytes, the move to a dynamically sized task_struct is being made. As part of this effort, provide means for vendors to pass a size value via kernel cmdline. Use the passed value to dynamically add to the task_struct size to accommodate vendor data. The cmdline parameter to be used is 'android_task_struct_vendor_size'. For eg., vendors can add the following to the bootargs section of their devicetree to add an extra 512 bytes to the task_struct: "android_task_struct_vendor_size=512" To access this additional memory, use the android_task_vendor_data function provided. Bug: 233921394 Change-Id: I6d5ab92080b82f29bbe9735d40f7d0b1e5bb5913 Signed-off-by: Sai Harshini Nimmala <[email protected]>
1 parent 1827ee5 commit 5e9a8cb

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

arch/x86/kernel/fpu/init.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ static void __init fpu__init_task_struct_size(void)
173173
CHECK_MEMBER_AT_END_OF(struct thread_struct, fpu);
174174
CHECK_MEMBER_AT_END_OF(struct task_struct, thread);
175175

176+
if (arch_task_struct_size > sizeof(struct task_struct)) {
177+
pr_warn("WARNING: Extra space requested by android_arch_task_struct_size overwritten by %s\n",
178+
__func__);
179+
}
176180
arch_task_struct_size = task_size;
177181
}
178182

kernel/fork.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,24 @@ static void __init set_max_threads(unsigned int max_threads_suggested)
10341034
#ifdef CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT
10351035
/* Initialized by the architecture: */
10361036
int arch_task_struct_size __read_mostly;
1037+
1038+
static int __init arch_task_struct_size_setup(char *str)
1039+
{
1040+
u64 size;
1041+
1042+
if (!str)
1043+
return -EINVAL;
1044+
1045+
size = memparse(str, &str);
1046+
1047+
if (size < 0 || size > CONFIG_GKI_TASK_STRUCT_VENDOR_SIZE_MAX)
1048+
return -EINVAL;
1049+
1050+
arch_task_struct_size = sizeof(struct task_struct) + size;
1051+
1052+
return 0;
1053+
}
1054+
early_param("android_task_struct_vendor_size", arch_task_struct_size_setup);
10371055
#endif
10381056

10391057
static void __init task_struct_whitelist(unsigned long *offset, unsigned long *size)

kernel/sched/sched.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3865,4 +3865,12 @@ void sched_enq_and_set_task(struct sched_enq_and_set_ctx *ctx);
38653865

38663866
#include "ext.h"
38673867

3868+
static inline void *android_task_vendor_data(struct task_struct *p)
3869+
{
3870+
if (p == &init_task)
3871+
return &vendor_data_pad[0];
3872+
3873+
return p + 1;
3874+
}
3875+
38683876
#endif /* _KERNEL_SCHED_SCHED_H */

0 commit comments

Comments
 (0)