[PATCH v3 4/4] idr: Add might_alloc() annotation

From: Michał Winiarski
Date: Tue Sep 06 2022 - 10:46:13 EST


Using might_alloc() lets us catch problems in a deterministic manner,
even if we end up not allocating anything.

Signed-off-by: Michał Winiarski <michal.winiarski@xxxxxxxxx>
---
lib/radix-tree.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 3c78e1e8b2ad..787ab01001de 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -23,6 +23,7 @@
#include <linux/preempt.h> /* in_interrupt() */
#include <linux/radix-tree.h>
#include <linux/rcupdate.h>
+#include <linux/sched/mm.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/xarray.h>
@@ -1481,6 +1482,8 @@ void __rcu **idr_get_free(struct radix_tree_root *root,
unsigned long maxindex, start = iter->next_index;
unsigned int shift, offset = 0;

+ might_alloc(gfp);
+
grow:
shift = radix_tree_load_root(root, &child, &maxindex);
if (!radix_tree_tagged(root, IDR_FREE))
--
2.37.3