From: Will Deacon <will.deacon@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, john.johansen@canonical.com,
paulmck@linux.vnet.ibm.com
Subject: Re: [PATCH 1/2] security/apparmor: Replace homebrew use of write_can_lock with lockdep
Date: Tue, 3 Oct 2017 17:58:48 +0100 [thread overview]
Message-ID: <20171003165848.GA12696@arm.com> (raw)
In-Reply-To: <20171003150709.53fz7daydyomfuly@hirez.programming.kicks-ass.net>
On Tue, Oct 03, 2017 at 05:07:09PM +0200, Peter Zijlstra wrote:
> On Tue, Oct 03, 2017 at 03:32:45PM +0100, Will Deacon wrote:
> > The lockdep subsystem provides a robust way to assert that a lock is
> > held, so use that instead of write_can_lock, which can give incorrect
> > results for qrwlocks.
> >
> > Cc: John Johansen <john.johansen@canonical.com>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Signed-off-by: Will Deacon <will.deacon@arm.com>
>
> Thanks Will, good to be able to finally remove that API.
Yup, but my grep-fu missed these guys in kernel/locking/spinlock.c:
while (!raw_##op##_can_lock(lock) && (lock)->break_lock
so diff below to catch those and remove spin_can_lock too.
Let me spin a v2...
Will
--->8
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 69e079c5ff98..1e3e48041800 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -278,12 +278,6 @@ static inline void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock)
1 : ({ local_irq_restore(flags); 0; }); \
})
-/**
- * raw_spin_can_lock - would raw_spin_trylock() succeed?
- * @lock: the spinlock in question.
- */
-#define raw_spin_can_lock(lock) (!raw_spin_is_locked(lock))
-
/* Include rwlock functions */
#include <linux/rwlock.h>
@@ -396,11 +390,6 @@ static __always_inline int spin_is_contended(spinlock_t *lock)
return raw_spin_is_contended(&lock->rlock);
}
-static __always_inline int spin_can_lock(spinlock_t *lock)
-{
- return raw_spin_can_lock(&lock->rlock);
-}
-
#define assert_spin_locked(lock) assert_raw_spin_locked(&(lock)->rlock)
/*
diff --git a/kernel/locking/spinlock.c b/kernel/locking/spinlock.c
index 42ee9d0a1ea4..8fd48b5552a7 100644
--- a/kernel/locking/spinlock.c
+++ b/kernel/locking/spinlock.c
@@ -66,7 +66,7 @@ void __lockfunc __raw_##op##_lock(locktype##_t *lock) \
\
if (!(lock)->break_lock) \
(lock)->break_lock = 1; \
- while (!raw_##op##_can_lock(lock) && (lock)->break_lock)\
+ while ((lock)->break_lock) \
arch_##op##_relax(&lock->raw_lock); \
} \
(lock)->break_lock = 0; \
@@ -86,7 +86,7 @@ unsigned long __lockfunc __raw_##op##_lock_irqsave(locktype##_t *lock) \
\
if (!(lock)->break_lock) \
(lock)->break_lock = 1; \
- while (!raw_##op##_can_lock(lock) && (lock)->break_lock)\
+ while ((lock)->break_lock) \
arch_##op##_relax(&lock->raw_lock); \
} \
(lock)->break_lock = 0; \
next prev parent reply other threads:[~2017-10-03 16:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-03 14:32 [PATCH 1/2] security/apparmor: Replace homebrew use of write_can_lock with lockdep Will Deacon
2017-10-03 14:32 ` [PATCH 2/2] locking: Remove {read,write}_can_lock Will Deacon
2017-10-03 15:07 ` [PATCH 1/2] security/apparmor: Replace homebrew use of write_can_lock with lockdep Peter Zijlstra
2017-10-03 16:58 ` Will Deacon [this message]
2017-10-03 15:33 ` John Johansen
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=20171003165848.GA12696@arm.com \
--to=will.deacon@arm.com \
--cc=john.johansen@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.