From c79de97cccbe695cd37d3be1985c8e0e5100d51d Mon Sep 17 00:00:00 2001 From: Greg Hackmann Date: Mon, 24 Jun 2013 18:41:46 -0700 Subject: bionic: replace 4K property pages with 32K property pages Fixes apps compiled statically against new libc but running with old init Bug: 9558625 Change-Id: I79e6f02575d278d4c7d8e8546d772ed0529bcaab Signed-off-by: Greg Hackmann --- libc/include/sys/_system_properties.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libc/include/sys/_system_properties.h b/libc/include/sys/_system_properties.h index 4971a4c..702a4b2 100644 --- a/libc/include/sys/_system_properties.h +++ b/libc/include/sys/_system_properties.h @@ -45,10 +45,10 @@ typedef struct prop_msg prop_msg; /* (4 header words + 28 toc words) = 128 bytes */ /* 128 bytes header and toc + 28 prop_infos @ 128 bytes = 3712 bytes */ -#define PA_COUNT_MAX 28 -#define PA_REGION_COUNT 128 -#define PA_INFO_START 128 -#define PA_SIZE 4096 +#define PA_COUNT_MAX 247 +#define PA_REGION_COUNT 16 +#define PA_INFO_START 1024 +#define PA_SIZE 32768 #define TOC_NAME_LEN(toc) ((toc) >> 24) #define TOC_TO_INFO(area, toc) ((prop_info*) (((char*) area) + ((toc) & 0xFFFFFF))) -- cgit v1.1 From 7751d9158f2dede814be920f80f5ff0b60856d1a Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Thu, 12 Sep 2013 21:47:20 -0700 Subject: Use kernel default for initial thread size Bug: 10697851 Change-Id: I8d980f5e0b584799536f6e6b891056c968d26cdf --- libc/bionic/libc_init_common.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp index 1fc490e..c10abad 100644 --- a/libc/bionic/libc_init_common.cpp +++ b/libc/bionic/libc_init_common.cpp @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include "atexit.h" @@ -62,6 +64,21 @@ uintptr_t __stack_chk_guard = 0; unsigned int __page_size = PAGE_SIZE; unsigned int __page_shift = PAGE_SHIFT; +static size_t get_stack_size() { + const size_t minimal_stack_size = 128 * 1024; + size_t stack_size = minimal_stack_size; + struct rlimit stack_limit; + int rlimit_result = getrlimit(RLIMIT_STACK, &stack_limit); + if ((rlimit_result == 0) && (stack_limit.rlim_cur != RLIM_INFINITY)) { + stack_size = stack_limit.rlim_cur; + stack_size = (stack_size & ~(PAGE_SIZE - 1)); + if (stack_size < minimal_stack_size) { + stack_size = minimal_stack_size; + } + } + return stack_size; +} + /* Init TLS for the initial thread. Called by the linker _before_ libc is mapped * in memory. Beware: all writes to libc globals from this function will * apply to linker-private copies and will not be visible from libc later on. @@ -76,9 +93,9 @@ unsigned int __page_shift = PAGE_SHIFT; void __libc_init_tls(KernelArgumentBlock& args) { __libc_auxv = args.auxv; - unsigned stack_top = (__get_sp() & ~(PAGE_SIZE - 1)) + PAGE_SIZE; - unsigned stack_size = 128 * 1024; - unsigned stack_bottom = stack_top - stack_size; + uintptr_t stack_top = (__get_sp() & ~(PAGE_SIZE - 1)) + PAGE_SIZE; + size_t stack_size = get_stack_size(); + uintptr_t stack_bottom = stack_top - stack_size; static void* tls[BIONIC_TLS_SLOTS]; static pthread_internal_t thread; -- cgit v1.1