ANDROID: vendor_hooks: add hook to retry mempool allocation without delay
Allow important priority threads to retry mempool allocation, achieving fast memory allocation and solving lagging problems caused by delaying 5 seconds. Bug: 423832910 Change-Id: I80e6b1c55652f5a62ac36bbf0091d22ec7fb6189 Signed-off-by: Justin Jiang <justinjiang@vivo.corp-partner.google.com>
This commit is contained in:
committed by
Treehugger Robot
parent
45afa56280
commit
68191d9c7a
@@ -677,3 +677,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_filemap_folio_mapped);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_folio_remove_rmap_ptes);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_pageset_update);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_xhci_full_reset_on_remove);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mempool_alloc_skip_wait);
|
||||
|
@@ -596,6 +596,9 @@ DECLARE_HOOK(android_vh_folio_remove_rmap_ptes,
|
||||
DECLARE_HOOK(android_vh_pageset_update,
|
||||
TP_PROTO(unsigned long *high, unsigned long *batch),
|
||||
TP_ARGS(high, batch));
|
||||
DECLARE_HOOK(android_vh_mempool_alloc_skip_wait,
|
||||
TP_PROTO(gfp_t *gfp_flags, bool *skip_wait),
|
||||
TP_ARGS(gfp_flags, skip_wait));
|
||||
#endif /* _TRACE_HOOK_MM_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
|
@@ -19,6 +19,8 @@
|
||||
#include <linux/mempool.h>
|
||||
#include <linux/writeback.h>
|
||||
#include "slab.h"
|
||||
#undef CREATE_TRACE_POINTS
|
||||
#include <trace/hooks/mm.h>
|
||||
|
||||
#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB_DEBUG_ON)
|
||||
static void poison_error(mempool_t *pool, void *element, size_t size,
|
||||
@@ -383,6 +385,7 @@ void *mempool_alloc(mempool_t *pool, gfp_t gfp_mask)
|
||||
unsigned long flags;
|
||||
wait_queue_entry_t wait;
|
||||
gfp_t gfp_temp;
|
||||
bool skip_wait = false;
|
||||
|
||||
VM_WARN_ON_ONCE(gfp_mask & __GFP_ZERO);
|
||||
might_alloc(gfp_mask);
|
||||
@@ -428,6 +431,11 @@ repeat_alloc:
|
||||
spin_unlock_irqrestore(&pool->lock, flags);
|
||||
return NULL;
|
||||
}
|
||||
trace_android_vh_mempool_alloc_skip_wait(&gfp_temp, &skip_wait);
|
||||
if (skip_wait) {
|
||||
spin_unlock_irqrestore(&pool->lock, flags);
|
||||
goto repeat_alloc;
|
||||
}
|
||||
|
||||
/* Let's wait for someone else to return an element to @pool */
|
||||
init_wait(&wait);
|
||||
|
Reference in New Issue
Block a user