diff options
| author | 2024-09-27 08:13:52 +0200 | |
|---|---|---|
| committer | 2024-09-27 08:13:52 +0200 | |
| commit | 3a39d672e7f48b8d6b91a09afa4b55352773b4b5 (patch) | |
| tree | f7ec4043b508f48430dd09ac338c38acf7d5a6cd /tools/testing/shared/linux.c | |
| parent | net: sparx5: Fix invalid timestamps (diff) | |
| parent | Merge tag 'net-6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net (diff) | |
| download | wireguard-linux-3a39d672e7f48b8d6b91a09afa4b55352773b4b5.tar.xz wireguard-linux-3a39d672e7f48b8d6b91a09afa4b55352773b4b5.zip | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Cross-merge networking fixes after downstream PR.
No conflicts and no adjacent changes.
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to '')
| -rw-r--r-- | tools/testing/shared/linux.c (renamed from tools/testing/radix-tree/linux.c) | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/tools/testing/radix-tree/linux.c b/tools/testing/shared/linux.c index 4eb442206d01..17263696b5d8 100644 --- a/tools/testing/radix-tree/linux.c +++ b/tools/testing/shared/linux.c @@ -26,8 +26,21 @@ struct kmem_cache { unsigned int non_kernel; unsigned long nr_allocated; unsigned long nr_tallocated; + bool exec_callback; + void (*callback)(void *); + void *private; }; +void kmem_cache_set_callback(struct kmem_cache *cachep, void (*callback)(void *)) +{ + cachep->callback = callback; +} + +void kmem_cache_set_private(struct kmem_cache *cachep, void *private) +{ + cachep->private = private; +} + void kmem_cache_set_non_kernel(struct kmem_cache *cachep, unsigned int val) { cachep->non_kernel = val; @@ -58,9 +71,17 @@ void *kmem_cache_alloc_lru(struct kmem_cache *cachep, struct list_lru *lru, { void *p; + if (cachep->exec_callback) { + if (cachep->callback) + cachep->callback(cachep->private); + cachep->exec_callback = false; + } + if (!(gfp & __GFP_DIRECT_RECLAIM)) { - if (!cachep->non_kernel) + if (!cachep->non_kernel) { + cachep->exec_callback = true; return NULL; + } cachep->non_kernel--; } @@ -223,6 +244,9 @@ kmem_cache_create(const char *name, unsigned int size, unsigned int align, ret->objs = NULL; ret->ctor = ctor; ret->non_kernel = 0; + ret->exec_callback = false; + ret->callback = NULL; + ret->private = NULL; return ret; } |
