8000 show commit id; use KBUILD_MODNAME · EdOmor1/Linux-Kernel-Programming@4c68dfb · GitHub
[go: up one dir, main page]

Skip to content

Commit 4c68dfb

Browse files
committed
show commit id; use KBUILD_MODNAME
1 parent fc61781 commit 4c68dfb

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

ch13/2_percpu/percpu_var.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
* From: Ch 13 : Kernel Synchronization, Part 2
1212
****************************************************************
1313
* Brief Description:
14+
* FYI: we use a very hack-y approach to accessing the unexported symbol
15+
* sched_setaffinity(); details follow. We get away with it here, but
16+
* DON'T use this approach in production.
1417
*
1518
* For details, please refer the book, Ch 13.
1619
*/
@@ -28,8 +31,6 @@
2831
#include <linux/delay.h>
2932
#include "../../convenient.h"
3033

31-
#define OURMODNAME "percpu_var"
32-
3334
MODULE_AUTHOR("Kaiwan N Billimoria");
3435
MODULE_DESCRIPTION("LKP book:ch13/2_percpu: demo of using percpu variables");
3536
MODULE_LICENSE("Dual MIT/GPL");
@@ -213,16 +214,17 @@ static int __init init_percpu_var(void)
213214
* pointer, and subsequently call the function via it's pointer (with 'C'
214215
* what you do is only limited by your imagination :).
215216
* b) From 5.7 on, the kernel devs unexported the kallsyms_lookup_name()!
216-
* (Rationale: https://lwn.net/Articles/813350/). With it gone, we now
217-
* simply use this approach: a helper script greps the kallsyms_lookup_name()
218-
* address and passes it to this module! We equate it to the exepcted
219-
* function signature - that of sched_setaffinity() - and use it.
217+
* (Commit id 0bd476e6c671. Rationale: https://lwn.net/Articles/813350/).
218+
* With it gone, we now simply use this approach: a helper script greps
219+
* the kallsyms_lookup_name() address and passes it to this module! We
220+
* equate it to the exepcted function signature - that of
221+
* sched_setaffinity() - and use it.
220222
* *Not* pedantically right, but hey, it works. Don't do this in production.
221223
*/
222224
ret = -ENOSYS;
223225
if (!func_ptr) {
224226
pr_warn("%s: couldn't obtain sched_setaffinity() addr via "
225-
"module param, aborting ...\n", OURMODNAME);
227+
"module param, aborting ...\n", KBUILD_MODNAME);
226228
return ret;
227229
}
228230
schedsa_ptr = (unsigned long (*)(pid_t pid, const struct cpumask *in_mask))func_ptr;

0 commit comments

Comments
 (0)
0