Re: [patch 1/7] cpusets: add dirty map to struct address_space

David Rientjes
2008-10-29T02:25:00Z

On Tue, 28 Oct 2008, David Rientjes wrote:

> diff --git a/kernel/cpuset.c b/kernel/cpuset.c
> --- a/kernel/cpuset.c
> +++ b/kernel/cpuset.c
> @@ -2413,10 +2413,7 @@ EXPORT_SYMBOL_GPL(cpuset_mem_spread_node);
> #if MAX_NUMNODES > BITS_PER_LONG
> /*
> * Special functions for NUMA systems with a large number of nodes. The
> - * nodemask is pointed to from the address_space structure. The attachment of
> - * the dirty_nodes nodemask is protected by the tree_lock. The nodemask is
> - * freed only when the inode is cleared (and therefore unused, thus no locking
> - * is necessary).
> + * nodemask is pointed to from the address_space structure.
> */
> void cpuset_update_dirty_nodes(struct address_space *mapping,
> struct page *page)
> @@ -2424,14 +2421,18 @@ void cpuset_update_dirty_nodes(struct address_space *mapping,
> nodemask_t *nodes = mapping->dirty_nodes;
> int node = page_to_nid(page);
>
> + spin_lock_irq(&mapping->dirty_nodes_lock);
> if (!nodes) {
> nodes = kmalloc(sizeof(nodemask_t), GFP_ATOMIC);
> - if (!nodes)
> + if (!nodes) {
> + spin_unlock_irq(&mapping->dirty_nodes_lock);
> return;
> + }
>
> *nodes = NODE_MASK_NONE;
> mapping->dirty_nodes = nodes;
> }
> + spin_unlock_irq(&mapping->dirty_nodes_lock);
> node_set(node, *nodes);
> }
>

Would need to be

spin_lock_irq(&mapping->dirty_nodes_lock);
nodes = mapping->dirty_nodes;
if (!nodes) {
nodes = kmalloc(sizeof(nodemask_t), GFP_ATOMIC);
if (!nodes) {
spin_unlock_irq(&mapping->dirty_nodes_lock);
return;
}
...
}
spin_unlock_irq(&mapping->dirty_nodes_lock);

but this shouldn't add much locking overhead without mapping->tree_lock.