* [PATCH] ipc: change kern_ipc_perm.deleted type to bool
@ 2013-12-19 17:23 Rafael Aquini
2013-12-19 17:27 ` Rik van Riel
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Rafael Aquini @ 2013-12-19 17:23 UTC (permalink / raw)
To: linux-kernel
Cc: Andrew Morton, Davidlohr Bueso, Rik van Riel, Greg Thelen,
Manfred Spraul
struct kern_ipc_perm.deleted is meant to be used as a boolean toogle, and
the changes introduced by this patch are just to make the case explicit.
Signed-off-by: Rafael Aquini <aquini@redhat.com>
---
* a quick sidenote: this patch goes on top of the recently posted
[PATCH v3] ipc: introduce ipc_valid_object() helper to sort out IPC_RMID races
include/linux/ipc.h | 2 +-
ipc/sem.c | 2 +-
ipc/util.c | 6 +++---
ipc/util.h | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/linux/ipc.h b/include/linux/ipc.h
index 8d861b2..9d84942 100644
--- a/include/linux/ipc.h
+++ b/include/linux/ipc.h
@@ -11,7 +11,7 @@
struct kern_ipc_perm
{
spinlock_t lock;
- int deleted;
+ bool deleted;
int id;
key_t key;
kuid_t uid;
diff --git a/ipc/sem.c b/ipc/sem.c
index 5972e60..1659cd9 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -394,7 +394,7 @@ static inline struct sem_array *sem_obtain_lock(struct ipc_namespace *ns,
/* ipc_rmid() may have already freed the ID while sem_lock
* was spinning: verify that the structure is still valid
*/
- if (!ipcp->deleted)
+ if (ipc_valid_object(ipcp))
return container_of(ipcp, struct sem_array, sem_perm);
sem_unlock(sma, *locknum);
diff --git a/ipc/util.c b/ipc/util.c
index 3ae17a4..9dc67fa 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -286,7 +286,7 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
idr_preload(GFP_KERNEL);
spin_lock_init(&new->lock);
- new->deleted = 0;
+ new->deleted = false;
rcu_read_lock();
spin_lock(&new->lock);
@@ -447,7 +447,7 @@ void ipc_rmid(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
ids->in_use--;
- ipcp->deleted = 1;
+ ipcp->deleted = true;
return;
}
@@ -657,7 +657,7 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
/* ipc_rmid() may have already freed the ID while ipc_lock
* was spinning: here verify that the structure is still valid
*/
- if (!out->deleted)
+ if (ipc_valid_object(out))
return out;
spin_unlock(&out->lock);
diff --git a/ipc/util.h b/ipc/util.h
index d05b708..a1cbc3a 100644
--- a/ipc/util.h
+++ b/ipc/util.h
@@ -195,7 +195,7 @@ static inline void ipc_unlock(struct kern_ipc_perm *perm)
*/
static inline bool ipc_valid_object(struct kern_ipc_perm *perm)
{
- return perm->deleted == 0;
+ return !perm->deleted;
}
struct kern_ipc_perm *ipc_obtain_object_check(struct ipc_ids *ids, int id);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ipc: change kern_ipc_perm.deleted type to bool
2013-12-19 17:23 [PATCH] ipc: change kern_ipc_perm.deleted type to bool Rafael Aquini
@ 2013-12-19 17:27 ` Rik van Riel
2013-12-19 17:28 ` Rafael Aquini
2013-12-19 17:29 ` Davidlohr Bueso
2 siblings, 0 replies; 4+ messages in thread
From: Rik van Riel @ 2013-12-19 17:27 UTC (permalink / raw)
To: Rafael Aquini, linux-kernel
Cc: Andrew Morton, Davidlohr Bueso, Greg Thelen, Manfred Spraul
On 12/19/2013 12:23 PM, Rafael Aquini wrote:
> struct kern_ipc_perm.deleted is meant to be used as a boolean toogle, and
> the changes introduced by this patch are just to make the case explicit.
>
> Signed-off-by: Rafael Aquini <aquini@redhat.com>
Reviewed-by: Rik van Riel <riel@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ipc: change kern_ipc_perm.deleted type to bool
2013-12-19 17:23 [PATCH] ipc: change kern_ipc_perm.deleted type to bool Rafael Aquini
2013-12-19 17:27 ` Rik van Riel
@ 2013-12-19 17:28 ` Rafael Aquini
2013-12-19 17:29 ` Davidlohr Bueso
2 siblings, 0 replies; 4+ messages in thread
From: Rafael Aquini @ 2013-12-19 17:28 UTC (permalink / raw)
To: linux-kernel
Cc: Andrew Morton, Davidlohr Bueso, Rik van Riel, Greg Thelen,
Manfred Spraul
On Thu, Dec 19, 2013 at 03:23:02PM -0200, Rafael Aquini wrote:
> struct kern_ipc_perm.deleted is meant to be used as a boolean toogle, and
> the changes introduced by this patch are just to make the case explicit.
>
> Signed-off-by: Rafael Aquini <aquini@redhat.com>
s/toogle/toggle
my bad, sorry. shall I resend, or it can be fixed before merging?
Thanks,
-- Rafael
> ---
> * a quick sidenote: this patch goes on top of the recently posted
> [PATCH v3] ipc: introduce ipc_valid_object() helper to sort out IPC_RMID races
>
> include/linux/ipc.h | 2 +-
> ipc/sem.c | 2 +-
> ipc/util.c | 6 +++---
> ipc/util.h | 2 +-
> 4 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/ipc.h b/include/linux/ipc.h
> index 8d861b2..9d84942 100644
> --- a/include/linux/ipc.h
> +++ b/include/linux/ipc.h
> @@ -11,7 +11,7 @@
> struct kern_ipc_perm
> {
> spinlock_t lock;
> - int deleted;
> + bool deleted;
> int id;
> key_t key;
> kuid_t uid;
> diff --git a/ipc/sem.c b/ipc/sem.c
> index 5972e60..1659cd9 100644
> --- a/ipc/sem.c
> +++ b/ipc/sem.c
> @@ -394,7 +394,7 @@ static inline struct sem_array *sem_obtain_lock(struct ipc_namespace *ns,
> /* ipc_rmid() may have already freed the ID while sem_lock
> * was spinning: verify that the structure is still valid
> */
> - if (!ipcp->deleted)
> + if (ipc_valid_object(ipcp))
> return container_of(ipcp, struct sem_array, sem_perm);
>
> sem_unlock(sma, *locknum);
> diff --git a/ipc/util.c b/ipc/util.c
> index 3ae17a4..9dc67fa 100644
> --- a/ipc/util.c
> +++ b/ipc/util.c
> @@ -286,7 +286,7 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
> idr_preload(GFP_KERNEL);
>
> spin_lock_init(&new->lock);
> - new->deleted = 0;
> + new->deleted = false;
> rcu_read_lock();
> spin_lock(&new->lock);
>
> @@ -447,7 +447,7 @@ void ipc_rmid(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
>
> ids->in_use--;
>
> - ipcp->deleted = 1;
> + ipcp->deleted = true;
>
> return;
> }
> @@ -657,7 +657,7 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
> /* ipc_rmid() may have already freed the ID while ipc_lock
> * was spinning: here verify that the structure is still valid
> */
> - if (!out->deleted)
> + if (ipc_valid_object(out))
> return out;
>
> spin_unlock(&out->lock);
> diff --git a/ipc/util.h b/ipc/util.h
> index d05b708..a1cbc3a 100644
> --- a/ipc/util.h
> +++ b/ipc/util.h
> @@ -195,7 +195,7 @@ static inline void ipc_unlock(struct kern_ipc_perm *perm)
> */
> static inline bool ipc_valid_object(struct kern_ipc_perm *perm)
> {
> - return perm->deleted == 0;
> + return !perm->deleted;
> }
>
> struct kern_ipc_perm *ipc_obtain_object_check(struct ipc_ids *ids, int id);
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ipc: change kern_ipc_perm.deleted type to bool
2013-12-19 17:23 [PATCH] ipc: change kern_ipc_perm.deleted type to bool Rafael Aquini
2013-12-19 17:27 ` Rik van Riel
2013-12-19 17:28 ` Rafael Aquini
@ 2013-12-19 17:29 ` Davidlohr Bueso
2 siblings, 0 replies; 4+ messages in thread
From: Davidlohr Bueso @ 2013-12-19 17:29 UTC (permalink / raw)
To: Rafael Aquini
Cc: linux-kernel, Andrew Morton, Rik van Riel, Greg Thelen,
Manfred Spraul
On Thu, 2013-12-19 at 15:23 -0200, Rafael Aquini wrote:
> struct kern_ipc_perm.deleted is meant to be used as a boolean toogle, and
> the changes introduced by this patch are just to make the case explicit.
>
> Signed-off-by: Rafael Aquini <aquini@redhat.com>
Acked-by: Davidlohr Bueso <davidlohr@hp.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-12-19 17:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-19 17:23 [PATCH] ipc: change kern_ipc_perm.deleted type to bool Rafael Aquini
2013-12-19 17:27 ` Rik van Riel
2013-12-19 17:28 ` Rafael Aquini
2013-12-19 17:29 ` Davidlohr Bueso
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.