Skip to content

Commit 375700b

Browse files
axboeakpm00
authored andcommitted
llist: make llist_add_batch() a static inline
The function is small enough that it should be, and it's a (very) hot path for io_uring. Doing this actually reduces my vmlinux text size for my standard build/test box. Before: axboe@r7625 ~/g/linux (test)> size vmlinux text data bss dec hex filename 19892174 5938310 2470432 28300916 1afd674 vmlinux After: axboe@r7625 ~/g/linux (test)> size vmlinux text data bss dec hex filename 19891878 5938310 2470436 28300624 1afd550 vmlinux Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 5ef2dcc commit 375700b

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

include/linux/llist.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,26 @@ static inline struct llist_node *llist_next(struct llist_node *node)
223223
return node->next;
224224
}
225225

226-
extern bool llist_add_batch(struct llist_node *new_first,
227-
struct llist_node *new_last,
228-
struct llist_head *head);
226+
/**
227+
* llist_add_batch - add several linked entries in batch
228+
* @new_first: first entry in batch to be added
229+
* @new_last: last entry in batch to be added
230+
* @head: the head for your lock-less list
231+
*
232+
* Return whether list is empty before adding.
233+
*/
234+
static inline bool llist_add_batch(struct llist_node *new_first,
235+
struct llist_node *new_last,
236+
struct llist_head *head)
237+
{
238+
struct llist_node *first = READ_ONCE(head->first);
239+
240+
do {
241+
new_last->next = first;
242+
} while (!try_cmpxchg(&head->first, &first, new_first));
243+
244+
return !first;
245+
}
229246

230247
static inline bool __llist_add_batch(struct llist_node *new_first,
231248
struct llist_node *new_last,

lib/llist.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,6 @@
1414
#include <linux/export.h>
1515
#include <linux/llist.h>
1616

17-
18-
/**
19-
* llist_add_batch - add several linked entries in batch
20-
* @new_first: first entry in batch to be added
21-
* @new_last: last entry in batch to be added
22-
* @head: the head for your lock-less list
23-
*
24-
* Return whether list is empty before adding.
25-
*/
26-
bool llist_add_batch(struct llist_node *new_first, struct llist_node *new_last,
27-
struct llist_head *head)
28-
{
29-
struct llist_node *first = READ_ONCE(head->first);
30-
31-
do {
32-
new_last->next = first;
33-
} while (!try_cmpxchg(&head->first, &first, new_first));
34-
35-
return !first;
36-
}
37-
EXPORT_SYMBOL_GPL(llist_add_batch);
38-
3917
/**
4018
* llist_del_first - delete the first entry of lock-less list
4119
* @head: the head for your lock-less list

0 commit comments

Comments
 (0)