[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250916044735.2316171-7-dolinux.peng@gmail.com>
Date: Tue, 16 Sep 2025 12:47:27 +0800
From: pengdonglin <dolinux.peng@...il.com>
To: tj@...nel.org,
tony.luck@...el.com,
jani.nikula@...ux.intel.com,
ap420073@...il.com,
jv@...sburgh.net,
freude@...ux.ibm.com,
bcrl@...ck.org,
trondmy@...nel.org,
longman@...hat.com,
kees@...nel.org
Cc: bigeasy@...utronix.de,
hdanton@...a.com,
paulmck@...nel.org,
linux-kernel@...r.kernel.org,
linux-rt-devel@...ts.linux.dev,
linux-nfs@...r.kernel.org,
linux-aio@...ck.org,
linux-fsdevel@...r.kernel.org,
linux-security-module@...r.kernel.org,
netdev@...r.kernel.org,
intel-gfx@...ts.freedesktop.org,
linux-wireless@...r.kernel.org,
linux-acpi@...r.kernel.org,
linux-s390@...r.kernel.org,
cgroups@...r.kernel.org,
pengdonglin <dolinux.peng@...il.com>,
pengdonglin <pengdonglin@...omi.com>
Subject: [PATCH v3 06/14] ipc: Remove redundant rcu_read_lock/unlock() in spin_lock
From: pengdonglin <pengdonglin@...omi.com>
Since commit a8bb74acd8efe ("rcu: Consolidate RCU-sched update-side function definitions")
there is no difference between rcu_read_lock(), rcu_read_lock_bh() and
rcu_read_lock_sched() in terms of RCU read section and the relevant grace
period. That means that spin_lock(), which implies rcu_read_lock_sched(),
also implies rcu_read_lock().
There is no need no explicitly start a RCU read section if one has already
been started implicitly by spin_lock().
Simplify the code and remove the inner rcu_read_lock() invocation.
Signed-off-by: pengdonglin <pengdonglin@...omi.com>
Signed-off-by: pengdonglin <dolinux.peng@...il.com>
---
ipc/msg.c | 1 -
ipc/sem.c | 1 -
ipc/shm.c | 1 -
ipc/util.c | 2 --
4 files changed, 5 deletions(-)
diff --git a/ipc/msg.c b/ipc/msg.c
index ee6af4fe52bf..1e579b57023f 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -179,7 +179,6 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params)
}
ipc_unlock_object(&msq->q_perm);
- rcu_read_unlock();
return msq->q_perm.id;
}
diff --git a/ipc/sem.c b/ipc/sem.c
index a39cdc7bf88f..38ad57b2b558 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -579,7 +579,6 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params)
ns->used_sems += nsems;
sem_unlock(sma, -1);
- rcu_read_unlock();
return sma->sem_perm.id;
}
diff --git a/ipc/shm.c b/ipc/shm.c
index a9310b6dbbc3..61fae1b6a18e 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -795,7 +795,6 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
error = shp->shm_perm.id;
ipc_unlock_object(&shp->shm_perm);
- rcu_read_unlock();
return error;
no_id:
diff --git a/ipc/util.c b/ipc/util.c
index cae60f11d9c2..1be691b5dcad 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -293,7 +293,6 @@ int ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int limit)
idr_preload(GFP_KERNEL);
spin_lock_init(&new->lock);
- rcu_read_lock();
spin_lock(&new->lock);
current_euid_egid(&euid, &egid);
@@ -316,7 +315,6 @@ int ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int limit)
if (idx < 0) {
new->deleted = true;
spin_unlock(&new->lock);
- rcu_read_unlock();
return idx;
}
--
2.34.1
Powered by blists - more mailing lists