linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Nicholas Mc Guire <der.herr@hofr.at>
Cc: linux-rt-users@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Andreas Platschek <platschek@ict.tuwien.ac.at>
Subject: Re: [PATCH] drop recursive migrate_disable in rt_write_trylock_irqsave
Date: Fri, 22 Nov 2013 18:15:55 +0100	[thread overview]
Message-ID: <20131122171555.GH8698@linutronix.de> (raw)
In-Reply-To: <20131122044439.GC31849@opentech.at>

* Nicholas Mc Guire | 2013-11-22 05:44:39 [+0100]:

> rt_write_trylock_irqsave unconditionally calls rt_write_trylock which will
> disable migration if the lock was sucessfully acquired.
> This patch drops the recursive migrate_disable/enable in
> rt_write_trylock_irqsave and rt_write_unlock_irq respecttively
>
> No change of functionality

I think you change functionality because you remove code. If you would
cut a big function into two small functions then I would agree that the
functionality has not been changed. But…

>index 9a5fe26..f6c7612 100644
>--- a/include/linux/rwlock_rt.h
>+++ b/include/linux/rwlock_rt.h
>@@ -105,7 +105,6 @@ extern void __rt_rwlock_init(rwlock_t *rwlock, char *name, struct lock_class_key
> 		typecheck(unsigned long, flags);	\
> 		(void) flags;				\
> 		rt_read_unlock(lock);			\
>-		migrate_enable();			\
> 	} while (0)

You are removing that from read_unlock_irqrestore() instead of
write_unlock_irqrestore() which comes next:

> 
> #define write_unlock_irqrestore(lock, flags) \
>diff --git a/kernel/rt.c b/kernel/rt.c
>index 4b2c4a9..71d26a4 100644
>--- a/kernel/rt.c
>+++ b/kernel/rt.c
>@@ -196,10 +196,8 @@ int __lockfunc rt_write_trylock_irqsave(rwlock_t *rwlock, unsigned long *flags)
> 	int ret;
> 
> 	*flags = 0;
>-	migrate_disable();
> 	ret = rt_write_trylock(rwlock);
>-	if (!ret)
>-		migrate_enable();
>+

The amount of users of rt_write_trylock_irqsave() is so small that
nobody noticed this bug:

 write_trylock_irqsave()
  ->rt_write_trylock_irqsave()
  -> m_d()
    -> rt_write_trylock()
    -> m_d()

That means we called migrate_disable() twice. Now comes the unlock path:
 write_unlock_irqrestore()
  -> rt_write_unlock()
  -> m_e()

That means migrations still needs to be enabled.

I would however prefer your optimisation where you remove the pointless
m_e() in rt_write_trylock_irqsave();

> 	return ret;
> }
> EXPORT_SYMBOL(rt_write_trylock_irqsave);

Sebastian
--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2013-11-22 17:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-20 10:21 [PATCH 1/2] remove recursive call to migrate_disable in read_lock_bh Nicholas Mc Guire
2013-11-21 10:22 ` Peter Zijlstra
2013-11-21 11:14   ` Nicholas Mc Guire
2013-11-21 23:58   ` Nicholas Mc Guire
2013-11-22  4:42 ` [PATCH] condition migration_disable on lock acquisition Nicholas Mc Guire
2013-11-22 18:39   ` Sebastian Andrzej Siewior
2013-11-27  0:26   ` Thomas Gleixner
2013-11-22  4:44 ` [PATCH] drop recursive migrate_disable in rt_write_trylock_irqsave Nicholas Mc Guire
2013-11-22 17:15   ` Sebastian Andrzej Siewior [this message]
2013-11-22  5:09 ` [PATCH] drop recursive migrate_disable in rt_write_trylock_irqsave - the right one this time Nicholas Mc Guire
2013-11-22 17:17   ` Sebastian Andrzej Siewior
2013-11-22 16:12 ` [PATCH 1/2] remove recursive call to migrate_disable in read_lock_bh Sebastian Andrzej Siewior
2013-11-22 23:39   ` Nicholas Mc Guire
2013-11-29 14:54     ` Sebastian Andrzej Siewior
2013-11-30  1:58       ` Nicholas Mc Guire

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=20131122171555.GH8698@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=der.herr@hofr.at \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=platschek@ict.tuwien.ac.at \
    --cc=rostedt@goodmis.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 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).