From: Pranith Kumar <pranith@gatech.edu>
To: peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, xfs@oss.sgi.com, mingo@redhat.com,
davidlohr@hp.com, tim.c.chen@linux.intel.com
Subject: Re: [RFC PATCH 1/1] cleanup: use bool as return type for rwsem_is_locked
Date: Fri, 06 Jun 2014 14:11:18 -0400 [thread overview]
Message-ID: <53920446.7060505@gatech.edu> (raw)
In-Reply-To: <5391FFFD.1060901@gatech.edu>
On 06/06/2014 01:53 PM, Pranith Kumar wrote:
> On Fri, Jun 6, 2014 at 3:35 AM, Peter Zijlstra <peterz@infradead.org> wrote:
>>
>> Now in general, I don't particularly like such superfluous changes, so
>> unless you can show that GCC actually generates better code, I'd prefer
>> to keep things as they are.
>
> Fixed and checked the assembly. It saves us 2 bytes of code, not much. I am not sure if that is worth it :(
>
> use bool as the return type for rwsem_is_locked() instead of int
>
> Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
> ---
> include/linux/rwsem-spinlock.h | 2 +-
> include/linux/rwsem.h | 2 +-
> kernel/locking/rwsem-spinlock.c | 4 ++--
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/rwsem-spinlock.h b/include/linux/rwsem-spinlock.h
> index d5b13bc..9026d2a 100644
> --- a/include/linux/rwsem-spinlock.h
> +++ b/include/linux/rwsem-spinlock.h
> @@ -39,7 +39,7 @@ extern int __down_write_trylock(struct rw_semaphore *sem);
> extern void __up_read(struct rw_semaphore *sem);
> extern void __up_write(struct rw_semaphore *sem);
> extern void __downgrade_write(struct rw_semaphore *sem);
> -extern int rwsem_is_locked(struct rw_semaphore *sem);
> +extern bool rwsem_is_locked(struct rw_semaphore *sem);
>
> #endif /* __KERNEL__ */
> #endif /* _LINUX_RWSEM_SPINLOCK_H */
> diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h
> index 03f3b05..b056780 100644
> --- a/include/linux/rwsem.h
> +++ b/include/linux/rwsem.h
> @@ -40,7 +40,7 @@ extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
> #include <asm/rwsem.h>
>
> /* In all implementations count != 0 means locked */
> -static inline int rwsem_is_locked(struct rw_semaphore *sem)
> +static inline bool rwsem_is_locked(struct rw_semaphore *sem)
> {
> return sem->count != 0;
> }
> diff --git a/kernel/locking/rwsem-spinlock.c b/kernel/locking/rwsem-spinlock.c
> index 9be8a91..3f8adf8 100644
> --- a/kernel/locking/rwsem-spinlock.c
> +++ b/kernel/locking/rwsem-spinlock.c
> @@ -20,9 +20,9 @@ struct rwsem_waiter {
> enum rwsem_waiter_type type;
> };
>
> -int rwsem_is_locked(struct rw_semaphore *sem)
> +bool rwsem_is_locked(struct rw_semaphore *sem)
> {
> - int ret = 1;
> + bool ret = true;
> unsigned long flags;
>
> if (raw_spin_trylock_irqsave(&sem->wait_lock, flags)) {
>
I observed one other user of rwsem_is_locked() in xfs, change accordingly
Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
fs/xfs/xfs_inode.c | 2 +-
fs/xfs/xfs_inode.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 768087b..9047eda 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -285,7 +285,7 @@ xfs_ilock_demote(
}
#if defined(DEBUG) || defined(XFS_WARN)
-int
+bool
xfs_isilocked(
xfs_inode_t *ip,
uint lock_flags)
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index f2fcde5..80649a1 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -348,7 +348,7 @@ void xfs_ilock(xfs_inode_t *, uint);
int xfs_ilock_nowait(xfs_inode_t *, uint);
void xfs_iunlock(xfs_inode_t *, uint);
void xfs_ilock_demote(xfs_inode_t *, uint);
-int xfs_isilocked(xfs_inode_t *, uint);
+bool xfs_isilocked(xfs_inode_t *, uint);
uint xfs_ilock_data_map_shared(struct xfs_inode *);
uint xfs_ilock_attr_map_shared(struct xfs_inode *);
int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, umode_t,
--
1.7.9.5
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
WARNING: multiple messages have this Message-ID (diff)
From: Pranith Kumar <pranith@gatech.edu>
To: peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, tim.c.chen@linux.intel.com,
davidlohr@hp.com, mingo@redhat.com, david@fromorbit.com,
xfs@oss.sgi.com
Subject: Re: [RFC PATCH 1/1] cleanup: use bool as return type for rwsem_is_locked
Date: Fri, 06 Jun 2014 14:11:18 -0400 [thread overview]
Message-ID: <53920446.7060505@gatech.edu> (raw)
In-Reply-To: <5391FFFD.1060901@gatech.edu>
On 06/06/2014 01:53 PM, Pranith Kumar wrote:
> On Fri, Jun 6, 2014 at 3:35 AM, Peter Zijlstra <peterz@infradead.org> wrote:
>>
>> Now in general, I don't particularly like such superfluous changes, so
>> unless you can show that GCC actually generates better code, I'd prefer
>> to keep things as they are.
>
> Fixed and checked the assembly. It saves us 2 bytes of code, not much. I am not sure if that is worth it :(
>
> use bool as the return type for rwsem_is_locked() instead of int
>
> Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
> ---
> include/linux/rwsem-spinlock.h | 2 +-
> include/linux/rwsem.h | 2 +-
> kernel/locking/rwsem-spinlock.c | 4 ++--
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/rwsem-spinlock.h b/include/linux/rwsem-spinlock.h
> index d5b13bc..9026d2a 100644
> --- a/include/linux/rwsem-spinlock.h
> +++ b/include/linux/rwsem-spinlock.h
> @@ -39,7 +39,7 @@ extern int __down_write_trylock(struct rw_semaphore *sem);
> extern void __up_read(struct rw_semaphore *sem);
> extern void __up_write(struct rw_semaphore *sem);
> extern void __downgrade_write(struct rw_semaphore *sem);
> -extern int rwsem_is_locked(struct rw_semaphore *sem);
> +extern bool rwsem_is_locked(struct rw_semaphore *sem);
>
> #endif /* __KERNEL__ */
> #endif /* _LINUX_RWSEM_SPINLOCK_H */
> diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h
> index 03f3b05..b056780 100644
> --- a/include/linux/rwsem.h
> +++ b/include/linux/rwsem.h
> @@ -40,7 +40,7 @@ extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
> #include <asm/rwsem.h>
>
> /* In all implementations count != 0 means locked */
> -static inline int rwsem_is_locked(struct rw_semaphore *sem)
> +static inline bool rwsem_is_locked(struct rw_semaphore *sem)
> {
> return sem->count != 0;
> }
> diff --git a/kernel/locking/rwsem-spinlock.c b/kernel/locking/rwsem-spinlock.c
> index 9be8a91..3f8adf8 100644
> --- a/kernel/locking/rwsem-spinlock.c
> +++ b/kernel/locking/rwsem-spinlock.c
> @@ -20,9 +20,9 @@ struct rwsem_waiter {
> enum rwsem_waiter_type type;
> };
>
> -int rwsem_is_locked(struct rw_semaphore *sem)
> +bool rwsem_is_locked(struct rw_semaphore *sem)
> {
> - int ret = 1;
> + bool ret = true;
> unsigned long flags;
>
> if (raw_spin_trylock_irqsave(&sem->wait_lock, flags)) {
>
I observed one other user of rwsem_is_locked() in xfs, change accordingly
Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
fs/xfs/xfs_inode.c | 2 +-
fs/xfs/xfs_inode.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 768087b..9047eda 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -285,7 +285,7 @@ xfs_ilock_demote(
}
#if defined(DEBUG) || defined(XFS_WARN)
-int
+bool
xfs_isilocked(
xfs_inode_t *ip,
uint lock_flags)
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index f2fcde5..80649a1 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -348,7 +348,7 @@ void xfs_ilock(xfs_inode_t *, uint);
int xfs_ilock_nowait(xfs_inode_t *, uint);
void xfs_iunlock(xfs_inode_t *, uint);
void xfs_ilock_demote(xfs_inode_t *, uint);
-int xfs_isilocked(xfs_inode_t *, uint);
+bool xfs_isilocked(xfs_inode_t *, uint);
uint xfs_ilock_data_map_shared(struct xfs_inode *);
uint xfs_ilock_attr_map_shared(struct xfs_inode *);
int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, umode_t,
--
1.7.9.5
next prev parent reply other threads:[~2014-06-06 18:11 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-05 20:49 [RFC PATCH 1/1] cleanup: use bool as return type for rwsem_is_locked Pranith Kumar
2014-06-06 7:35 ` Peter Zijlstra
2014-06-06 17:53 ` Pranith Kumar
2014-06-06 17:56 ` Peter Zijlstra
2014-06-06 18:02 ` Pranith Kumar
2014-06-06 18:41 ` Davidlohr Bueso
2014-06-06 18:52 ` Pranith Kumar
2014-06-06 18:11 ` Pranith Kumar [this message]
2014-06-06 18:11 ` Pranith Kumar
2014-06-07 0:18 ` Dave Chinner
2014-06-07 0:18 ` Dave Chinner
2014-06-07 0:59 ` Pranith Kumar
2014-06-07 0:59 ` Pranith Kumar
2014-06-07 1:41 ` Pranith Kumar
2014-06-07 1:41 ` Pranith Kumar
2014-06-07 2:39 ` Joe Perches
2014-06-07 2:39 ` Joe Perches
2014-06-07 23:44 ` Dave Chinner
2014-06-07 23:44 ` Dave Chinner
2014-06-08 2:57 ` Pranith Kumar
2014-06-08 2:57 ` Pranith Kumar
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=53920446.7060505@gatech.edu \
--to=pranith@gatech.edu \
--cc=davidlohr@hp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tim.c.chen@linux.intel.com \
--cc=xfs@oss.sgi.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 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.