diff mbox series

lib,kprobes: objpool_try_add_slot merged into objpool_push

Message ID 20231025053133.343923-1-wuqiang.matt@bytedance.com (mailing list archive)
State New, archived
Headers show
Series lib,kprobes: objpool_try_add_slot merged into objpool_push | expand

Commit Message

wuqiang.matt Oct. 25, 2023, 5:31 a.m. UTC
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 mbox series

Patch

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);