From: Nick Piggin <npiggin@suse.de>
To: Miao Xie <miaox@cn.fujitsu.com>
Cc: David Rientjes <rientjes@google.com>,
Lee Schermerhorn <lee.schermerhorn@hp.com>,
Paul Menage <menage@google.com>,
Linux-Kernel <linux-kernel@vger.kernel.org>,
Linux-MM <linux-mm@kvack.org>
Subject: Re: [PATCH 4/4] cpuset,mm: use rwlock to protect task->mempolicy and mems_allowed
Date: Thu, 4 Mar 2010 15:53:15 +1100 [thread overview]
Message-ID: <20100304045315.GP8653@laptop> (raw)
In-Reply-To: <4B8E3F77.6070201@cn.fujitsu.com>
On Wed, Mar 03, 2010 at 06:52:39PM +0800, Miao Xie wrote:
> if MAX_NUMNODES > BITS_PER_LONG, loading/storing task->mems_allowed or mems_allowed in
> task->mempolicy are not atomic operations, and the kernel page allocator gets an empty
> mems_allowed when updating task->mems_allowed or mems_allowed in task->mempolicy. So we
> use a rwlock to protect them to fix this probelm.
Oh, and something else I'm also concerned about:
If MAX_NUMNODES <= BITS_PER_LONG then these locks are a noop.
> +#define read_mem_lock_irqsave(p, flags) do { (void)(flags); } while (0)
> +
> +#define read_mem_unlock_irqrestore(p, flags) do { (void)(flags); } while (0)
> +
> +/* Be used to protect task->mempolicy and mems_allowed when user reads them */
However you are appearing to use them for more than just atomically
loading of the nodemasks.
> @@ -2447,11 +2503,14 @@ void cpuset_unlock(void)
> int cpuset_mem_spread_node(void)
> {
> int node;
> + unsigned long flags;
>
> + read_mem_lock_irqsave(current, flags);
> node = next_node(current->cpuset_mem_spread_rotor, current->mems_allowed);
> if (node == MAX_NUMNODES)
> node = first_node(current->mems_allowed);
> current->cpuset_mem_spread_rotor = node;
> + read_mem_unlock_irqrestore(current, flags);
> return node;
> }
> EXPORT_SYMBOL_GPL(cpuset_mem_spread_node);
If you are worried about doing this kind of atomic RMW on the mask, then
you cannot make the lock a noop. So if you're nooping the lock in this
way then you really need to cuddle it neatly around loading of the mask.
Once you do that, it would be trivial to use a seqlock.
...
> @@ -1381,8 +1434,16 @@ static struct mempolicy *get_vma_policy(struct task_struct *task,
> } else if (vma->vm_policy)
> pol = vma->vm_policy;
> }
> + if (!pol) {
> + read_mem_lock_irqsave(task, irqflags);
> + pol = task->mempolicy;
> + mpol_get(pol);
> + read_mem_unlock_irqrestore(task, irqflags);
> + }
> +
> if (!pol)
> pol = &default_policy;
> +
> return pol;
> }
And a couple of others. It looks like you're using it here to guarantee
existence of the mempolicy.... Did you mean read_mempolicy_lock? Or do
you have another problem (there seems to be several cases of this).
WARNING: multiple messages have this Message-ID (diff)
From: Nick Piggin <npiggin@suse.de>
To: Miao Xie <miaox@cn.fujitsu.com>
Cc: David Rientjes <rientjes@google.com>,
Lee Schermerhorn <lee.schermerhorn@hp.com>,
Paul Menage <menage@google.com>,
Linux-Kernel <linux-kernel@vger.kernel.org>,
Linux-MM <linux-mm@kvack.org>
Subject: Re: [PATCH 4/4] cpuset,mm: use rwlock to protect task->mempolicy and mems_allowed
Date: Thu, 4 Mar 2010 15:53:15 +1100 [thread overview]
Message-ID: <20100304045315.GP8653@laptop> (raw)
In-Reply-To: <4B8E3F77.6070201@cn.fujitsu.com>
On Wed, Mar 03, 2010 at 06:52:39PM +0800, Miao Xie wrote:
> if MAX_NUMNODES > BITS_PER_LONG, loading/storing task->mems_allowed or mems_allowed in
> task->mempolicy are not atomic operations, and the kernel page allocator gets an empty
> mems_allowed when updating task->mems_allowed or mems_allowed in task->mempolicy. So we
> use a rwlock to protect them to fix this probelm.
Oh, and something else I'm also concerned about:
If MAX_NUMNODES <= BITS_PER_LONG then these locks are a noop.
> +#define read_mem_lock_irqsave(p, flags) do { (void)(flags); } while (0)
> +
> +#define read_mem_unlock_irqrestore(p, flags) do { (void)(flags); } while (0)
> +
> +/* Be used to protect task->mempolicy and mems_allowed when user reads them */
However you are appearing to use them for more than just atomically
loading of the nodemasks.
> @@ -2447,11 +2503,14 @@ void cpuset_unlock(void)
> int cpuset_mem_spread_node(void)
> {
> int node;
> + unsigned long flags;
>
> + read_mem_lock_irqsave(current, flags);
> node = next_node(current->cpuset_mem_spread_rotor, current->mems_allowed);
> if (node == MAX_NUMNODES)
> node = first_node(current->mems_allowed);
> current->cpuset_mem_spread_rotor = node;
> + read_mem_unlock_irqrestore(current, flags);
> return node;
> }
> EXPORT_SYMBOL_GPL(cpuset_mem_spread_node);
If you are worried about doing this kind of atomic RMW on the mask, then
you cannot make the lock a noop. So if you're nooping the lock in this
way then you really need to cuddle it neatly around loading of the mask.
Once you do that, it would be trivial to use a seqlock.
...
> @@ -1381,8 +1434,16 @@ static struct mempolicy *get_vma_policy(struct task_struct *task,
> } else if (vma->vm_policy)
> pol = vma->vm_policy;
> }
> + if (!pol) {
> + read_mem_lock_irqsave(task, irqflags);
> + pol = task->mempolicy;
> + mpol_get(pol);
> + read_mem_unlock_irqrestore(task, irqflags);
> + }
> +
> if (!pol)
> pol = &default_policy;
> +
> return pol;
> }
And a couple of others. It looks like you're using it here to guarantee
existence of the mempolicy.... Did you mean read_mempolicy_lock? Or do
you have another problem (there seems to be several cases of this).
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2010-03-04 4:53 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-03 10:52 [PATCH 4/4] cpuset,mm: use rwlock to protect task->mempolicy and mems_allowed Miao Xie
2010-03-03 10:52 ` Miao Xie
2010-03-03 23:50 ` Andrew Morton
2010-03-03 23:50 ` Andrew Morton
2010-03-04 9:03 ` Miao Xie
2010-03-04 9:03 ` Miao Xie
2010-03-04 3:30 ` Nick Piggin
2010-03-04 3:30 ` Nick Piggin
2010-03-04 9:36 ` Miao Xie
2010-03-04 9:36 ` Miao Xie
2010-03-04 14:58 ` Peter Zijlstra
2010-03-04 14:58 ` Peter Zijlstra
2010-03-04 16:34 ` Nick Piggin
2010-03-04 16:34 ` Nick Piggin
2010-03-04 4:53 ` Nick Piggin [this message]
2010-03-04 4:53 ` Nick Piggin
2010-03-04 14:31 ` Lee Schermerhorn
2010-03-04 14:31 ` Lee Schermerhorn
2010-03-05 13:05 ` Lee Schermerhorn
2010-03-05 13:05 ` Lee Schermerhorn
2010-03-05 12:03 ` Paul Menage
2010-03-05 12:03 ` Paul Menage
2010-03-07 2:33 ` Miao Xie
2010-03-07 2:33 ` Miao Xie
2010-03-09 19:42 ` Paul Menage
2010-03-09 19:42 ` Paul Menage
2010-03-11 5:04 ` Miao Xie
2010-03-11 5:04 ` Miao Xie
2010-03-11 5:30 ` Nick Piggin
2010-03-11 5:30 ` Nick Piggin
2010-03-11 7:57 ` Miao Xie
2010-03-11 7:57 ` Miao Xie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100304045315.GP8653@laptop \
--to=npiggin@suse.de \
--cc=lee.schermerhorn@hp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=menage@google.com \
--cc=miaox@cn.fujitsu.com \
--cc=rientjes@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.