Skip to contentSkip to conversation

locking fixes

GIT PULL Merged Ingo Molnar 3 participants 4 messages Apr 20, 2019 – Apr 21, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Linus,

Please pull the latest locking-urgent-for-linus git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking-urgent-for-linus

# HEAD: b50776ae011cfd26df3cc2b4af8b2dc3b683e553 locking/atomics: Don't assume that scripts are executable

A lockdep warning fix and a script execution fix when atomics are generated.

Thanks,

Ingo

------------------>
Andrew Morton (1):
locking/atomics: Don't assume that scripts are executable

Bart Van Assche (1):
locking/lockdep: Make lockdep_unregister_key() honor 'debug_locks' again

 kernel/locking/lockdep.c      | 9 +++++----
 scripts/atomic/gen-atomics.sh | 2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)
kernel/locking/lockdep.c +5 -4
index e16766ff184b..e221be724fe8 100644
@@ -4907,8 +4907,9 @@ void lockdep_unregister_key(struct lock_class_key *key)
 		return;
 
 	raw_local_irq_save(flags);
-	arch_spin_lock(&lockdep_lock);
-	current->lockdep_recursion = 1;
+	if (!graph_lock())
+		goto out_irq;
+
 	pf = get_pending_free();
 	hlist_for_each_entry_rcu(k, hash_head, hash_entry) {
 		if (k == key) {
@@ -4920,8 +4921,8 @@ void lockdep_unregister_key(struct lock_class_key *key)
 	WARN_ON_ONCE(!found);
 	__lockdep_free_key_range(pf, key, 1);
 	call_rcu_zapped(pf);
-	current->lockdep_recursion = 0;
-	arch_spin_unlock(&lockdep_lock);
+	graph_unlock();
+out_irq:
 	raw_local_irq_restore(flags);
 
 	/* Wait until is_dynamic_key() has finished accessing k->hash_entry. */
scripts/atomic/gen-atomics.sh +1 -1
index 27400b0cd732..000dc6437893 100644
@@ -13,7 +13,7 @@ gen-atomic-long.sh              asm-generic/atomic-long.h
 gen-atomic-fallback.sh          linux/atomic-fallback.h
 EOF
 while read script header; do
-	${ATOMICDIR}/${script} ${ATOMICTBL} > ${LINUXDIR}/include/${header}
+	/bin/sh ${ATOMICDIR}/${script} ${ATOMICTBL} > ${LINUXDIR}/include/${header}
 	HASH="$(sha1sum ${LINUXDIR}/include/${header})"
 	HASH="${HASH%% *}"
 	printf "// %s\n" "${HASH}" >> ${LINUXDIR}/include/${header}
#1 lore raw
Quoted 3 lines · Ingo Molnar

A lockdep warning fix and a script execution fix when atomics are generated.

Hmm. I've pulled this, but looking at it, I think it's worth noting something...

scripts/atomic/gen-atomics.sh gen-atomic-long.sh asm-generic/atomic-long.h · line 16

Quoted 6 lines
scripts/atomic/gen-atomics.sh +1 -1
index 27400b0cd732..000dc6437893 100644
-       ${ATOMICDIR}/${script} ${ATOMICTBL} > ${LINUXDIR}/include/${header}
+       /bin/sh ${ATOMICDIR}/${script} ${ATOMICTBL} > ${LINUXDIR}/include/${header}

/bin/sh ?

Yes, that's what the hash-bang line says in the scripts themselves, and thus what we used to do with the whole direct execution thing, so it's clearly not _wrong_, but every single time when we manually do the "run with shell" normally, we use $(CONFIG_SHELL)".

So I get the feeling that we should likely do that here too.

Of course, the gen-atomics script is (now) outside the normal build, so maybe people just go "this is special, doesn't go through the normal build process anyway, and thus might as well not follow the common rules".

Linus

#2 lore raw
Quoted 21 lines · Linus Torvalds
Quoted 3 lines · Ingo Molnar

A lockdep warning fix and a script execution fix when atomics are generated.

Hmm. I've pulled this, but looking at it, I think it's worth noting something...

scripts/atomic/gen-atomics.sh gen-atomic-long.sh asm-generic/atomic-long.h · line 16

Quoted 6 lines
scripts/atomic/gen-atomics.sh +1 -1
index 27400b0cd732..000dc6437893 100644
-       ${ATOMICDIR}/${script} ${ATOMICTBL} > ${LINUXDIR}/include/${header}
+       /bin/sh ${ATOMICDIR}/${script} ${ATOMICTBL} > ${LINUXDIR}/include/${header}

/bin/sh ?

Yes, that's what the hash-bang line says in the scripts themselves, and thus what we used to do with the whole direct execution thing, so it's clearly not _wrong_, but every single time when we manually do the "run with shell" normally, we use $(CONFIG_SHELL)".

Quoted 6 lines

So I get the feeling that we should likely do that here too.

Of course, the gen-atomics script is (now) outside the normal build, so maybe people just go "this is special, doesn't go through the normal build process anyway, and thus might as well not follow the common rules".

Yeah, agreed that this is all a bit weird. The status quo right now is:

- scripts/atomic/gen-atomics.sh is a completely standalone, external script which isn't even tied into any Makefile mechanism to build the kernel.

- To generate the headers one has to explicitly call scripts/atomic/gen-atomics.sh, and it's not even executable, so the incantation is even more weird:

         $ . scripts/atomic/gen-atomics.sh

So I agree that the UI of all this should be improved, I suspect we should do the following improvements:

- make gen-atomics.sh executable

- add a "make headers_gen_atomics" target to the main Makefile

- call gen-atomics.sh via the build system and thus have access to $CONFIG_SHELL and such and don't have assumptions about the shell environment.

Arguably /bin/sh tends to exist during the build, everywhere. What usually results in the use of CONFIG_SHELL isn't /bin/sh per se but specific shell variant assumptions such as /bin/bash and the resulting occasional Bashism in the scripts - there are systems with non-bash shells by default and so.

Thanks,

Ingo

merge bot Merged
#3 lore raw
In reply to Ingo Molnar
The pull request you sent on Sat, 20 Apr 2019 09:30:18 +0200:

The pull request you sent on Sat, 20 Apr 2019 09:30:18 +0200:

Quoted 1 line

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking-urgent-for-linus

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/de3af9a99013fdb0358bb990e9bed0172c65bba9

Thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker