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=-4.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS 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 5595CC433E0 for ; Tue, 28 Jul 2020 00:19:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D6AE620809 for ; Tue, 28 Jul 2020 00:19:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="qJUt0jiT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6AE620809 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5E92B6B0002; Mon, 27 Jul 2020 20:19:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 59B276B0005; Mon, 27 Jul 2020 20:19:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AFBD6B0006; Mon, 27 Jul 2020 20:19:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id 36DC46B0002 for ; Mon, 27 Jul 2020 20:19:56 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 996EC181AC9B6 for ; Tue, 28 Jul 2020 00:19:55 +0000 (UTC) X-FDA: 77085576750.14.dime41_4f098ed26f65 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 6E40C18229837 for ; Tue, 28 Jul 2020 00:19:55 +0000 (UTC) X-HE-Tag: dime41_4f098ed26f65 X-Filterd-Recvd-Size: 2845 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Tue, 28 Jul 2020 00:19:54 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B889C20786; Tue, 28 Jul 2020 00:19:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595895594; bh=6o/MZ1z32u64khpK98VwBkgw43eYbDJxbrdLk66x9Rc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qJUt0jiTNItMcvuHyogiA2bKZVjg0T5jNVT2Do/aalnvH4F1MTME3XtnpNrg6IHJ4 zlCeQvgXPTV5rAG6Fw3ewHkLA4ebXbW8ncqUmkfOSIktqHN/3X+A+xCIjVHpoG94pL vx2NvVjPJpi80W4CxCl+v35SXCmm1yHwKvCS3VYQ= Date: Mon, 27 Jul 2020 17:19:53 -0700 From: Andrew Morton To: Muchun Song Cc: mike.kravetz@oracle.com, mhocko@kernel.org, rientjes@google.com, mgorman@suse.de, walken@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jianchao Guo Subject: Re: [PATCH v3] mm/hugetlb: add mempolicy check in the reservation routine Message-Id: <20200727171953.443afb897bb88261facf5512@linux-foundation.org> In-Reply-To: <20200725080749.70470-1-songmuchun@bytedance.com> References: <20200725080749.70470-1-songmuchun@bytedance.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 6E40C18229837 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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 Sat, 25 Jul 2020 16:07:49 +0800 Muchun Song wrote: > In the reservation routine, we only check whether the cpuset meets > the memory allocation requirements. But we ignore the mempolicy of > MPOL_BIND case. If someone mmap hugetlb succeeds, but the subsequent > memory allocation may fail due to mempolicy restrictions and receives > the SIGBUS signal. This can be reproduced by the follow steps. > > 1) Compile the test case. > cd tools/testing/selftests/vm/ > gcc map_hugetlb.c -o map_hugetlb > > 2) Pre-allocate huge pages. Suppose there are 2 numa nodes in the > system. Each node will pre-allocate one huge page. > echo 2 > /proc/sys/vm/nr_hugepages > > 3) Run test case(mmap 4MB). We receive the SIGBUS signal. > numactl --membind=0 ./map_hugetlb 4 > > With this patch applied, the mmap will fail in the step 3) and throw > "mmap: Cannot allocate memory". This doesn't compile with CONFIG_NUMA=n - ther eis no implementation of get_task_policy(). I think it needs more than a simple build fix - can we please rework the patch so that its impact (mainly code size) on non-NUMA machines is minimized?