[Devel] [PATCH RH7 1/3] modules: use raw_cpu_write for initialization of per cpu refcount.

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Mon Feb 26 13:01:42 MSK 2018


From: Christoph Lameter <cl at linux.com>

https://jira.sw.ru/browse/PSBM-80508

The initialization of a structure is not subject to synchronization.
The use of __this_cpu would trigger a false positive with the additional
preemption checks for __this_cpu ops.

So simply disable the check through the use of raw_cpu ops.

Trace:

  __this_cpu_write operation in preemptible [00000000] code: modprobe/286
  caller is __this_cpu_preempt_check+0x38/0x60
  CPU: 3 PID: 286 Comm: modprobe Tainted: GF            3.12.0-rc4+ #187
  Call Trace:
    dump_stack+0x4e/0x82
    check_preemption_disabled+0xec/0x110
    __this_cpu_preempt_check+0x38/0x60
    load_module+0xcfd/0x2650
    SyS_init_module+0xa6/0xd0
    tracesys+0xe1/0xe6

Signed-off-by: Christoph Lameter <cl at linux.com>
Acked-by: Ingo Molnar <mingo at kernel.org>
Acked-by: Rusty Russell <rusty at rustcorp.com.au>
Cc: Tejun Heo <tj at kernel.org>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 kernel/module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/module.c b/kernel/module.c
index a5ee99f0f7a0..3ed051300c5c 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -816,7 +816,7 @@ static int module_unload_init(struct module *mod)
 	INIT_LIST_HEAD(&mod->target_list);
 
 	/* Hold reference count during initialization. */
-	__this_cpu_write(mod->refptr->incs, 1);
+	raw_cpu_write(mod->refptr->incs, 1);
 
 	return 0;
 }
-- 
2.14.3



More information about the Devel mailing list