Skip to contentSkip to conversation

GFS2: Don't waste time locking lru_lock for non-lru glocks

PATCH New Bob Peterson 2 participants 2 messages Jul 26, 2017 1 message not in the archive GFS2 file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 GFS2: Don't waste time locking lru_lock for non-lru glocks

Hi,

Before this patch, glock_dq would call gfs2_glock_remove_from_lru. For glocks that are never put on the LRU, such as the transaction glock, this just takes the spin_lock, determines there's nothing to be done because the list is empty, then unlocks again. This was causing unnecessary lock contention on the lru_lock spin_lock. This patch adds a check for GLOF_LRU in the glops before taking the spin_lock, thus reducing lru_lock contention.

---

fs/gfs2/glock.c +3 -0
index c38ab6c81898..1029340fc8ba 100644
@@ -150,6 +150,9 @@ void gfs2_glock_add_to_lru(struct gfs2_glock *gl)
 
 static void gfs2_glock_remove_from_lru(struct gfs2_glock *gl)
 {
+	if (!(gl->gl_ops->go_flags & GLOF_LRU))
+		return;
+
 	spin_lock(&lru_lock);
 	if (!list_empty(&gl->gl_lru)) {
 		list_del_init(&gl->gl_lru);
#2 lore raw

PATCH 1/1 GFS2: Don't waste time locking lru_lock for non-lru glocks

Hi,

Looks good.

Steve.

Quoted 27 lines · Bob Peterson

Hi,

Before this patch, glock_dq would call gfs2_glock_remove_from_lru. For glocks that are never put on the LRU, such as the transaction glock, this just takes the spin_lock, determines there's nothing to be done because the list is empty, then unlocks again. This was causing unnecessary lock contention on the lru_lock spin_lock. This patch adds a check for GLOF_LRU in the glops before taking the spin_lock, thus reducing lru_lock contention.

---

fs/gfs2/glock.c +3 -0
index c38ab6c81898..1029340fc8ba 100644
@@ -150,6 +150,9 @@ void gfs2_glock_add_to_lru(struct gfs2_glock *gl)
 
  static void gfs2_glock_remove_from_lru(struct gfs2_glock *gl)
  {
+	if (!(gl->gl_ops->go_flags & GLOF_LRU))
+		return;
+
  	spin_lock(&lru_lock);
  	if (!list_empty(&gl->gl_lru)) {
  		list_del_init(&gl->gl_lru);