All of lore.kernel.org
 help / color / mirror / Atom feed
* [fs] inode_lru_isolate(): Move counter increment into spinlock section
@ 2013-12-18 19:24 Christoph Lameter
  2013-12-19  4:23 ` Dave Chinner
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Lameter @ 2013-12-18 19:24 UTC (permalink / raw)
  To: Dave Chinner; +Cc: linux-kernel, Alexander Viro

The counter increment in inode_lru_isolate is happening after
spinlocks have been dropped with preemption on using __count_vm_events
making counter increment races possible.

Move the counter increments to be done when the spinlock is
reacquired later so that the counter can be safely incremented.

Signed-off-by: Christoph Lameter <cl@linux.com>

Index: linux/fs/inode.c
===================================================================
--- linux.orig/fs/inode.c	2013-12-18 13:14:43.211693438 -0600
+++ linux/fs/inode.c	2013-12-18 13:15:58.489266129 -0600
@@ -715,21 +715,21 @@ inode_lru_isolate(struct list_head *item
 	}

 	if (inode_has_buffers(inode) || inode->i_data.nrpages) {
+		unsigned long reap = 0;
 		__iget(inode);
 		spin_unlock(&inode->i_lock);
 		spin_unlock(lru_lock);
 		if (remove_inode_buffers(inode)) {
-			unsigned long reap;
 			reap = invalidate_mapping_pages(&inode->i_data, 0, -1);
-			if (current_is_kswapd())
-				__count_vm_events(KSWAPD_INODESTEAL, reap);
-			else
-				__count_vm_events(PGINODESTEAL, reap);
 			if (current->reclaim_state)
 				current->reclaim_state->reclaimed_slab += reap;
 		}
 		iput(inode);
 		spin_lock(lru_lock);
+		if (current_is_kswapd())
+			__count_vm_events(KSWAPD_INODESTEAL, reap);
+		else
+			__count_vm_events(PGINODESTEAL, reap);
 		return LRU_RETRY;
 	}


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-12-20 18:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-18 19:24 [fs] inode_lru_isolate(): Move counter increment into spinlock section Christoph Lameter
2013-12-19  4:23 ` Dave Chinner
2013-12-19 15:26   ` Christoph Lameter
2013-12-20  3:35     ` Dave Chinner
2013-12-20 17:52       ` Christoph Lameter
2013-12-20 18:05       ` Christoph Lameter

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.