From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail137.messagelabs.com (mail137.messagelabs.com [216.82.249.19]) by kanga.kvack.org (Postfix) with SMTP id D293C6B0069 for ; Fri, 18 Nov 2011 04:53:53 -0500 (EST) Message-ID: <4EC62AEA.2030602@cn.fujitsu.com> Date: Fri, 18 Nov 2011 17:52:42 +0800 From: Miao Xie Reply-To: miaox@cn.fujitsu.com MIME-Version: 1.0 Subject: Re: [patch for-3.2-rc3] cpusets: stall when updating mems_allowed for mempolicy or disjoint nodemask References: <4EC4C603.8050704@cn.fujitsu.com> In-Reply-To: Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1 Sender: owner-linux-mm@kvack.org List-ID: To: David Rientjes Cc: Andrew Morton , Linus Torvalds , KOSAKI Motohiro , Paul Menage , linux-kernel@vger.kernel.org, linux-mm@kvack.org On Thu, 17 Nov 2011 13:33:14 -0800 (pst), David Rientjes wrote: > On Thu, 17 Nov 2011, Miao Xie wrote: > >> Oh~, David >> >> I find these is another problem, please take account of the following case: >> >> 2-3 -> 1-2 -> 0-1 >> >> the user change mems_allowed twice continuously, the task may see the empty >> mems_allowed. >> >> So, it is still dangerous. >> > > With this patch, we're protected by task_lock(tsk) to determine whether we > want to take the exception, i.e. whether need_loop is false, and the > setting of tsk->mems_allowed. So this would see the nodemask change at > the individual steps from 2-3 -> 1-2 -> 0-1, not some inconsistent state > in between or directly from 2-3 -> 0-1. The only time we don't hold > task_lock(tsk) to change tsk->mems_allowed is when tsk == current and in > that case we're not concerned about intermediate reads to its own nodemask > while storing to a mask where MAX_NUMNODES > BITS_PER_LONG. > > Thus, there's no problem here with regard to such behavior if we exclude > mempolicies, which this patch does. > No. When the task does memory allocation, it access its mems_allowed without task_lock(tsk), and it may be blocked after it check 0-1 bits. And then, the user changes mems_allowed twice continuously(2-3(initial state) -> 1-2 -> 0-1), After that, the task is woke up and it see the empty mems_allowed. -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757200Ab1KRJxw (ORCPT ); Fri, 18 Nov 2011 04:53:52 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:52163 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751867Ab1KRJxv (ORCPT ); Fri, 18 Nov 2011 04:53:51 -0500 Message-ID: <4EC62AEA.2030602@cn.fujitsu.com> Date: Fri, 18 Nov 2011 17:52:42 +0800 From: Miao Xie Reply-To: miaox@cn.fujitsu.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0 MIME-Version: 1.0 To: David Rientjes CC: Andrew Morton , Linus Torvalds , KOSAKI Motohiro , Paul Menage , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [patch for-3.2-rc3] cpusets: stall when updating mems_allowed for mempolicy or disjoint nodemask References: <4EC4C603.8050704@cn.fujitsu.com> In-Reply-To: X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-11-18 17:53:32, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-11-18 17:53:36, Serialize complete at 2011-11-18 17:53:36 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 17 Nov 2011 13:33:14 -0800 (pst), David Rientjes wrote: > On Thu, 17 Nov 2011, Miao Xie wrote: > >> Oh~, David >> >> I find these is another problem, please take account of the following case: >> >> 2-3 -> 1-2 -> 0-1 >> >> the user change mems_allowed twice continuously, the task may see the empty >> mems_allowed. >> >> So, it is still dangerous. >> > > With this patch, we're protected by task_lock(tsk) to determine whether we > want to take the exception, i.e. whether need_loop is false, and the > setting of tsk->mems_allowed. So this would see the nodemask change at > the individual steps from 2-3 -> 1-2 -> 0-1, not some inconsistent state > in between or directly from 2-3 -> 0-1. The only time we don't hold > task_lock(tsk) to change tsk->mems_allowed is when tsk == current and in > that case we're not concerned about intermediate reads to its own nodemask > while storing to a mask where MAX_NUMNODES > BITS_PER_LONG. > > Thus, there's no problem here with regard to such behavior if we exclude > mempolicies, which this patch does. > No. When the task does memory allocation, it access its mems_allowed without task_lock(tsk), and it may be blocked after it check 0-1 bits. And then, the user changes mems_allowed twice continuously(2-3(initial state) -> 1-2 -> 0-1), After that, the task is woke up and it see the empty mems_allowed.