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=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 B7988ECE587 for ; Mon, 14 Oct 2019 13:49:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 82EEC20659 for ; Mon, 14 Oct 2019 13:49:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82EEC20659 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2FA098E0005; Mon, 14 Oct 2019 09:49:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A9BF8E0001; Mon, 14 Oct 2019 09:49:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19A148E0005; Mon, 14 Oct 2019 09:49:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0227.hostedemail.com [216.40.44.227]) by kanga.kvack.org (Postfix) with ESMTP id ECA6F8E0001 for ; Mon, 14 Oct 2019 09:49:07 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 828405830 for ; Mon, 14 Oct 2019 13:49:07 +0000 (UTC) X-FDA: 76042521534.02.fowl87_892da3dc98c3d X-HE-Tag: fowl87_892da3dc98c3d X-Filterd-Recvd-Size: 2818 Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Oct 2019 13:49:02 +0000 (UTC) Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 8970F3EC1D09AFA17FC1; Mon, 14 Oct 2019 21:48:52 +0800 (CST) Received: from huawei.com (10.175.127.16) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Mon, 14 Oct 2019 21:48:45 +0800 From: Pan Zhang To: , , , , , , , CC: , Subject: Re: Re: [PATCH] mm: mempolicy: fix the absence of the last bit of nodemask Date: Mon, 14 Oct 2019 21:49:25 +0800 Message-ID: <1571060965-17794-1-git-send-email-zhangpan26@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.127.16] X-CFilter-Loop: Reflected X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon 14-10:19 17:12:52, Michal Hocko wrote: >> When I want to use set_mempolicy to get the memory from each node on the numa machine, >> and the MPOL_INTERLEAVE flag seems to achieve this goal. >> However, during the test, it was found that the use result of node was unbalanced. >> The memory was allocated evenly from the nodes except the last node, >> which obviously did not match the expectations. >> >> You can test as follows: >> 1. Create a file that needs to be mmap ped: >> dd if=/dev/zero of=./test count=1024 bs=1M >This will already poppulate the page cache and if it fits into memory (which seems to be the case in your example output) then your mmap later will not allocate any new memory. > >I suspect that using numactl --interleave 0,1 dd if=/dev/zero of=./test count=1024 bs=1M > >will produce an output much closer to your expectation. Right? Yes, you are right. `dd` command will 'populate the page cache and if it fits into memory'. As a newcomer who is studying hard in this field, I am sorry for this and I don't know much about the mechanism of memory management. I used `malloc` again in my program to allocate memory and produced the same `confusing` result. But as you and Vlastimil Babka said, historical reasons have made the implementation of this interface less intuitive. Modifying manual may be a better option. Thank you both for your reply and explanation.