From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7142AC31E40 for ; Wed, 7 Aug 2019 00:58:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4EED9208C3 for ; Wed, 7 Aug 2019 00:58:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727617AbfHGA6K (ORCPT ); Tue, 6 Aug 2019 20:58:10 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4181 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726340AbfHGA6J (ORCPT ); Tue, 6 Aug 2019 20:58:09 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 91ABC144364FA1DEF3CB; Wed, 7 Aug 2019 08:58:07 +0800 (CST) Received: from [127.0.0.1] (10.133.217.137) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Wed, 7 Aug 2019 08:58:03 +0800 Subject: Re: [PATCH] mm/mempolicy.c: Remove unnecessary nodemask check in kernel_migrate_pages() To: Vlastimil Babka , Andrew Morton , CC: Andrea Arcangeli , Dan Williams , Michal Hocko , Oscar Salvador , , Linux API , "linux-man@vger.kernel.org" References: <20190806023634.55356-1-wangkefeng.wang@huawei.com> <80f8da83-f425-1aab-f47e-8da41ec6dcbf@suse.cz> From: Kefeng Wang Message-ID: <34880869-49a1-86c6-9345-2a01da7fbb9b@huawei.com> Date: Wed, 7 Aug 2019 08:58:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <80f8da83-f425-1aab-f47e-8da41ec6dcbf@suse.cz> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.133.217.137] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/8/6 16:36, Vlastimil Babka wrote: > On 8/6/19 4:36 AM, Kefeng Wang wrote: [...] >> >> [QUESTION] >> >> SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode, >> const unsigned long __user *, old_nodes, >> const unsigned long __user *, new_nodes) >> { >> return kernel_migrate_pages(pid, maxnode, old_nodes, new_nodes); >> } >> >> The migrate_pages() takes pid argument, witch is the ID of the process >> whose pages are to be moved. should the cpuset_mems_allowed(current) be >> cpuset_mems_allowed(task)? > > The check for cpuset_mems_allowed(task) is just above the code you change, so > the new nodes have to be subset of the target task's cpuset. > But they also have to be allowed by the calling task's cpuset. In manpage of > migrate_pages(2), this is hinted by the NOTES "Use get_mempolicy(2) with the > MPOL_F_MEMS_ALLOWED flag to obtain the set of nodes that are allowed by the > calling process's cpuset..." > > But perhaps the manpage should be better clarified: > > - the EINVAL case includes "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." - this should probably say "calling process" to > disambiguate > - the EPERM case should mention that new_nodes have to be subset of the target > process' cpuset context. The caller should also have CAP_SYS_NICE and > ptrace_may_access() Get it, thanks for your detail explanation. >