fix: fix login wallpaper startup delay
This commit is contained in:
@@ -99,6 +99,7 @@ static inline long _mtk_syscall4(long nr, long a1, long a2, long a3, long a4) {
|
||||
#define SYS_CLOSE 9
|
||||
#define SYS_READDIR 10
|
||||
#define SYS_ALLOC 11
|
||||
#define SYS_ALLOC_EAGER 187
|
||||
#define SYS_FREE 12
|
||||
#define SYS_GETMILLISECONDS 14
|
||||
#define SYS_GETCHAR 18
|
||||
@@ -679,6 +680,14 @@ int tolower(int c) { return (c >= 'A' && c <= 'Z') ? c + 32 : c; }
|
||||
#define HEAP_ALIGN 16ULL
|
||||
#define DIRECT_THRESHOLD (256ULL * 1024ULL)
|
||||
|
||||
/* A direct mapping is one object the caller sized itself, so it is nearly
|
||||
always written end to end (an image buffer, a loaded file). Committing it
|
||||
up front replaces one page fault, one kernel mutex acquire and one VMA walk
|
||||
per 4 KiB with a single loop -- thousands of traps for a decoded image.
|
||||
Beyond the cap, stay lazy: a very large mapping is more likely to be a
|
||||
sparsely touched reservation, and eager commit would pin the lot. */
|
||||
#define EAGER_DIRECT_LIMIT (32ULL * 1024ULL * 1024ULL)
|
||||
|
||||
struct HeapHeader {
|
||||
uint64_t magic;
|
||||
uint64_t requested_size;
|
||||
@@ -855,8 +864,10 @@ static void *heap_malloc_locked(size_t size) {
|
||||
if (needed >= DIRECT_THRESHOLD) {
|
||||
if (needed > UINT64_MAX - 0xFFFULL) return NULL;
|
||||
uint64_t mapping_size = (needed + 0xFFFULL) & ~0xFFFULL;
|
||||
long alloc_nr = (mapping_size <= EAGER_DIRECT_LIMIT)
|
||||
? SYS_ALLOC_EAGER : SYS_ALLOC;
|
||||
struct HeapHeader *hdr = (struct HeapHeader *)
|
||||
_mtk_syscall1(SYS_ALLOC, (long)mapping_size);
|
||||
_mtk_syscall1(alloc_nr, (long)mapping_size);
|
||||
if (hdr == NULL) return NULL;
|
||||
hdr->magic = DIRECT_MAGIC;
|
||||
hdr->requested_size = size;
|
||||
|
||||
Reference in New Issue
Block a user