|
11 | 11 | * From: Ch 13 : Kernel Synchronization, Part 2
|
12 | 12 | ****************************************************************
|
13 | 13 | * 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. |
14 | 17 | *
|
15 | 18 | * For details, please refer the book, Ch 13.
|
16 | 19 | */
|
|
28 | 31 | #include <linux/delay.h>
|
29 | 32 | #include "../../convenient.h"
|
30 | 33 |
|
31 |
| -#define OURMODNAME "percpu_var" |
32 |
| - |
33 | 34 | MODULE_AUTHOR("Kaiwan N Billimoria");
|
34 | 35 | MODULE_DESCRIPTION("LKP book:ch13/2_percpu: demo of using percpu variables");
|
35 | 36 | MODULE_LICENSE("Dual MIT/GPL");
|
@@ -213,16 +214,17 @@ static int __init init_percpu_var(void)
|
213 | 214 | * pointer, and subsequently call the function via it's pointer (with 'C'
|
214 | 215 | * what you do is only limited by your imagination :).
|
215 | 216 | * 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. |
220 | 222 | * *Not* pedantically right, but hey, it works. Don't do this in production.
|
221 | 223 | */
|
222 | 224 | ret = -ENOSYS;
|
223 | 225 | if (!func_ptr) {
|
224 | 226 | pr_warn("%s: couldn't obtain sched_setaffinity() addr via "
|
225 |
| - "module param, aborting ...\n", OURMODNAME); |
| 227 | + "module param, aborting ...\n", KBUILD_MODNAME); |
226 | 228 | return ret;
|
227 | 229 | }
|
228 | 230 | schedsa_ptr = (unsigned long (*)(pid_t pid, const struct cpumask *in_mask))func_ptr;
|
|
0 commit comments