* [PATCH] audit: use atomic_t to simplify audit_serial()
@ 2014-06-16 19:56 Richard Guy Briggs
0 siblings, 0 replies; only message in thread
From: Richard Guy Briggs @ 2014-06-16 19:56 UTC (permalink / raw)
To: linux-audit, linux-kernel; +Cc: Richard Guy Briggs
Since there is already a primitive to do this operation in the atomic_t, use it
to simplify audit_serial().
Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
---
kernel/audit.c | 14 ++------------
1 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/kernel/audit.c b/kernel/audit.c
index 218899b..d41266c 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1257,19 +1257,9 @@ err:
*/
unsigned int audit_serial(void)
{
- static DEFINE_SPINLOCK(serial_lock);
- static unsigned int serial = 0;
+ static atomic_t serial = ATOMIC_INIT(0);
- unsigned long flags;
- unsigned int ret;
-
- spin_lock_irqsave(&serial_lock, flags);
- do {
- ret = ++serial;
- } while (unlikely(!ret));
- spin_unlock_irqrestore(&serial_lock, flags);
-
- return ret;
+ return atomic_add_return(1, &serial);
}
static inline void audit_get_stamp(struct audit_context *ctx,
--
1.7.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-06-16 20:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-16 19:56 [PATCH] audit: use atomic_t to simplify audit_serial() Richard Guy Briggs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).