lkml.org 
[lkml]   [2013]   [Dec]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[fs] inode_lru_isolate(): Move counter increment into spinlock section
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;
}


\
 
 \ /
  Last update: 2013-12-18 21:01    [W:0.067 / U:0.828 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site