* [PATCH] lib,kprobes: objpool_try_add_slot merged into objpool_push
@ 2023-10-25 5:31 wuqiang.matt
0 siblings, 0 replies; only message in thread
From: wuqiang.matt @ 2023-10-25 5:31 UTC (permalink / raw)
To: linux-trace-kernel, mhiramat, davem, anil.s.keshavamurthy,
naveen.n.rao, rostedt, peterz, akpm, sander, ebiggers,
dan.j.williams, jpoimboe
Cc: linux-kernel, lkp, mattwu, wuqiang.matt
After several rounds of objpool improvements the existence
of inline function objpool_try_add_slot is not appropriate
any more:
1) push can only happen on local cpu node, the cpu param of
objpool_try_add_slot is misleading
2) objpool_push is only a wrapper of objpool_try_add_slot,
with the original loop of all cpu nodes removed
Signed-off-by: wuqiang.matt <wuqiang.matt@bytedance.com>
---
lib/objpool.c | 26 +++++++++-----------------
1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/lib/objpool.c b/lib/objpool.c
index a032701beccb..7474a3a60cad 100644
--- a/lib/objpool.c
+++ b/lib/objpool.c
@@ -152,13 +152,17 @@ int objpool_init(struct objpool_head *pool, int nr_objs, int object_size,
}
EXPORT_SYMBOL_GPL(objpool_init);
-/* adding object to slot, abort if the slot was already full */
-static inline int
-objpool_try_add_slot(void *obj, struct objpool_head *pool, int cpu)
+/* reclaim an object to object pool */
+int objpool_push(void *obj, struct objpool_head *pool)
{
- struct objpool_slot *slot = pool->cpu_slots[cpu];
+ struct objpool_slot *slot;
uint32_t head, tail;
+ unsigned long flags;
+
+ /* disable local irq to avoid preemption & interruption */
+ raw_local_irq_save(flags);
+ slot = pool->cpu_slots[raw_smp_processor_id()];
/* loading tail and head as a local snapshot, tail first */
tail = READ_ONCE(slot->tail);
@@ -173,21 +177,9 @@ objpool_try_add_slot(void *obj, struct objpool_head *pool, int cpu)
/* update sequence to make this obj available for pop() */
smp_store_release(&slot->last, tail + 1);
- return 0;
-}
-
-/* reclaim an object to object pool */
-int objpool_push(void *obj, struct objpool_head *pool)
-{
- unsigned long flags;
- int rc;
-
- /* disable local irq to avoid preemption & interruption */
- raw_local_irq_save(flags);
- rc = objpool_try_add_slot(obj, pool, raw_smp_processor_id());
raw_local_irq_restore(flags);
- return rc;
+ return 0;
}
EXPORT_SYMBOL_GPL(objpool_push);
--
2.40.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-10-25 5:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-25 5:31 [PATCH] lib,kprobes: objpool_try_add_slot merged into objpool_push wuqiang.matt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).