Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753403AbdDLILY (ORCPT ); Wed, 12 Apr 2017 04:11:24 -0400 Received: from out0-235.mail.aliyun.com ([140.205.0.235]:40452 "EHLO out0-235.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752546AbdDLILV (ORCPT ); Wed, 12 Apr 2017 04:11:21 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R341e4;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e02c03292;MF=hillf.zj@alibaba-inc.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---.7wYpd3v_1491984653; Reply-To: "Hillf Danton" From: "Hillf Danton" To: "'Vlastimil Babka'" , Cc: , , "'Li Zefan'" , "'Michal Hocko'" , "'Mel Gorman'" , "'David Rientjes'" , "'Christoph Lameter'" , "'Hugh Dickins'" , "'Andrea Arcangeli'" , "'Anshuman Khandual'" , "'Kirill A. Shutemov'" References: <20170411140609.3787-1-vbabka@suse.cz> <20170411140609.3787-6-vbabka@suse.cz> In-Reply-To: <20170411140609.3787-6-vbabka@suse.cz> Subject: Re: [RFC 5/6] mm, cpuset: always use seqlock when changing task's nodemask Date: Wed, 12 Apr 2017 16:10:53 +0800 Message-ID: <0c2d01d2b364$4eaba920$ec02fb60$@alibaba-inc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQJtLy3m/Y60YWA/wm1EMsuqAudnAgF3egqcoICteDA= Content-Language: zh-cn Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1133 Lines: 40 On April 11, 2017 10:06 PM Vlastimil Babka wrote: > > static void cpuset_change_task_nodemask(struct task_struct *tsk, > nodemask_t *newmems) > { > - bool need_loop; > - > task_lock(tsk); > - /* > - * Determine if a loop is necessary if another thread is doing > - * read_mems_allowed_begin(). If at least one node remains unchanged and > - * tsk does not have a mempolicy, then an empty nodemask will not be > - * possible when mems_allowed is larger than a word. > - */ > - need_loop = task_has_mempolicy(tsk) || > - !nodes_intersects(*newmems, tsk->mems_allowed); > > - if (need_loop) { > - local_irq_disable(); > - write_seqcount_begin(&tsk->mems_allowed_seq); > - } > + local_irq_disable(); > + write_seqcount_begin(&tsk->mems_allowed_seq); > > - nodes_or(tsk->mems_allowed, tsk->mems_allowed, *newmems); > mpol_rebind_task(tsk, newmems); > tsk->mems_allowed = *newmems; > > - if (need_loop) { > - write_seqcount_end(&tsk->mems_allowed_seq); > - local_irq_enable(); > - } > + write_seqcount_end(&tsk->mems_allowed_seq); > Doubt if we'd listen irq again. > task_unlock(tsk); > } > -- > 2.12.2