Skip to contentSkip to conversation

Allocate kprobe_table at runtime

PATCH Superseded Jeff Sipek 2 participants 2 messages Jun 26, 2005 – Jun 27, 2005 kprobes

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jeff Sipek

author
#0 lore raw

PATCH 1/1 Allocate kprobe_table at runtime

Allocates kprobe_table at runtime.

kernel/kprobes.c +5 -2
@@ -40,7 +40,7 @@
 #define KPROBE_HASH_BITS 6
 #define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS)
 
-static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE];
+static struct hlist_head *kprobe_table;
 
 unsigned int kprobe_cpu = NR_CPUS;
 static DEFINE_SPINLOCK(kprobe_lock);
@@ -261,7 +261,10 @@ static int __init init_kprobes(void)
 {
 	int i, err = 0;
 
-	/* FIXME allocate the probe table, currently defined statically */
+	kprobe_table = kmalloc(sizeof(struct hlist_head)*KPROBE_TABLE_SIZE, GFP_ATOMIC);
+	if (!kprobe_table)
+		return -ENOMEM;
+
 	/* initialize all list heads */
 	for (i = 0; i < KPROBE_TABLE_SIZE; i++)
 		INIT_HLIST_HEAD(&kprobe_table[i]);
#1 lore raw

Jeff,

kernel/kprobes.c static int __init init_kprobes(void) · line 264

Quoted 3 lines · Jeff Sipek

Allocates kprobe_table at runtime.

kernel/kprobes.c +1 -1
-	/* FIXME allocate the probe table, currently defined statically */
+	kprobe_table = kmalloc(sizeof(struct hlist_head)*KPROBE_TABLE_SIZE, GFP_ATOMIC);

Memory allocation using GFP_KERNEL has more chances of success as compared to GFP_ATOMIC. Why can't we use GFP_KERNEL here?

Thanks
Prasanna

Signature · 5 lines
Prasanna S Panchamukhi
Linux Technology Center
India Software Labs, IBM Bangalore
Ph: 91-80-25044636
<[email protected]>