linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: kernel test robot <fengguang.wu@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>, LKP <lkp@01.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>,
	wfg@linux.intel.com
Subject: Re: [locking/lockdep] 383776fa75:  INFO: trying to register non-static key.
Date: Fri, 17 Mar 2017 14:41:09 +0100	[thread overview]
Message-ID: <20170317134109.e7qmjwpryelpbgz2@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <58cad449.RTO+aYLdogbZs5Le%fengguang.wu@intel.com>

On Fri, Mar 17, 2017 at 02:07:05AM +0800, kernel test robot wrote:

>     locking/lockdep: Handle statically initialized PER_CPU locks properly

> [   11.712266] INFO: trying to register non-static key.

Blergh; so the problem is that when we assign can_addr to lock->key, we
can, upon using a different subclass, reach static_obj(lock->key), which
will fail on the can_addr.

One way to fix this would be to redefine the canonical address as the
per-cpu address for a specific cpu; the below hard codes cpu0, but I'm
not sure we want to rely on cpu0 being a valid cpu.


---
diff --git a/kernel/module.c b/kernel/module.c
index 5ef618133849..bdd9d62ce08c 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -682,8 +682,10 @@ bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr)
 			void *va = (void *)addr;
 
 			if (va >= start && va < start + mod->percpu_size) {
-				if (can_addr)
+				if (can_addr) {
 					*can_addr = (unsigned long) (va - start);
+					*can_addr += (unsigned long)per_cpu_ptr(mod->percpu, 0);
+				}
 				preempt_enable();
 				return true;
 			}
diff --git a/mm/percpu.c b/mm/percpu.c
index e30c995f2b7b..a5d7b7477888 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1296,8 +1296,10 @@ bool __is_kernel_percpu_address(unsigned long addr, unsigned long *can_addr)
 		void *va = (void *)addr;
 
 		if (va >= start && va < start + static_size) {
-			if (can_addr)
+			if (can_addr) {
 				*can_addr = (unsigned long) (va - start);
+				*can_addr += (unsigned long)per_cpu_ptr(base, 0);
+			}
 			return true;
 		}
 	}

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2017-03-17 13:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-16 18:07 kernel test robot
2017-03-17 13:41 ` Peter Zijlstra [this message]
2017-03-17 14:41   ` Sebastian Andrzej Siewior
2017-03-20 11:41     ` Peter Zijlstra
2017-03-25 18:13       ` Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170317134109.e7qmjwpryelpbgz2@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=bigeasy@linutronix.de \
    --cc=fengguang.wu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@01.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wfg@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox