From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755205AbdKHBjn (ORCPT ); Tue, 7 Nov 2017 20:39:43 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:9973 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753305AbdKHBjl (ORCPT ); Tue, 7 Nov 2017 20:39:41 -0500 Subject: Re: [PATCH RFC v2 4/4] mm/mempolicy: add nodes_empty check in SYSC_migrate_pages To: Christopher Lameter , Vlastimil Babka References: <1509099265-30868-1-git-send-email-xieyisheng1@huawei.com> <1509099265-30868-5-git-send-email-xieyisheng1@huawei.com> <04e4cb50-8cba-58af-1a5e-61e818cffa70@suse.cz> CC: , , , , , , , , , , Andi Kleen From: Yisheng Xie Message-ID: <4b08f1e9-5449-6ea2-e7da-65fe5f678683@huawei.com> Date: Wed, 8 Nov 2017 09:38:36 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.40] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.5A026022.003A,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 7833650ca11dd661885654e761560980 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Christopher, On 2017/11/7 23:55, Christopher Lameter wrote: > On Tue, 7 Nov 2017, Vlastimil Babka wrote: > >>> Migrate pages moves the pages of a single process there is no TARGET >>> process. >> >> migrate_pages(2) takes a pid argument >> >> "migrate_pages() attempts to move all pages of the process pid that >> are in memory nodes old_nodes to the memory nodes in new_nodes. " > > Ok missed that. Most use cases here are on the current process. Yeah, so most case current process is the same as target process. But maybe I still miss someting, see below: > > Fundamentally a process can have shared pages outside of the cpuset that > a process is restricted to. Thus I would think that migration to any of > the allowed nodes of the current process that is calling migrate pages > is ok. The caller wants this and the caller has a right to allocate on > these nodes. It would be strange if migrate_pages would allow allocation > outside of the current cpuset. > >>> Thus thehe *target* nodes need to be a subset of the current cpu set. > > And therefore the above still holds. Another case is current process is *not* the same as target process, and when current process try to migrate pages of target process from old_nodes to new_nodes, the new_nodes should be a subset of target process cpuset. CAP_SYS_NICE will insure that current process have the privilege, and will not overwrite the restriction of target process cpuset. However, for the current cpuset restriction, as manpage says : EINVAL... Or, _none_ of the node IDs specified by new_nodes are on-line and allowed by the process's current cpuset context, or none of the specified nodes contain memory. So for current cpuset restriction, an intersection check should be enough instead of subset? And it will also make sure migrate_pages will not allocate pages outside of the current cpuset. > > . >