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=-8.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 5D0DBC433DF for ; Fri, 7 Aug 2020 01:23:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2ABD12177B for ; Fri, 7 Aug 2020 01:23:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="g/x8BUWd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2ABD12177B 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 6D9F46B0002; Thu, 6 Aug 2020 21:22:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68B466B0003; Thu, 6 Aug 2020 21:22:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 579C96B0005; Thu, 6 Aug 2020 21:22:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0170.hostedemail.com [216.40.44.170]) by kanga.kvack.org (Postfix) with ESMTP id 3DEDC6B0002 for ; Thu, 6 Aug 2020 21:22:59 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A316D180AD801 for ; Fri, 7 Aug 2020 01:22:58 +0000 (UTC) X-FDA: 77122023636.30.van82_1c0ba8c26fbc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id 78D1D180B3AA7 for ; Fri, 7 Aug 2020 01:22:58 +0000 (UTC) X-HE-Tag: van82_1c0ba8c26fbc X-Filterd-Recvd-Size: 3988 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Fri, 7 Aug 2020 01:22:57 +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 AC31F206B5; Fri, 7 Aug 2020 01:22:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596763377; bh=taVUPcZZG/PWKJC217fUi0ps3ehP0TVRSPgn7VkId3c=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=g/x8BUWd+/8S2SPzeeZX0ZEBkmC/kgdEn44bpSuR6MN8Jpku6wnUXnriH85QTteDi nc584DAU+eZD+PYvvb7li6pPAlGLKaEvEJqpDBDhBQtglPSig6nadpIo7+OdYnDYgG rudNx0RnNOiKuEWiHCkson/aTL4X80TzTaE0G+/o= Date: Thu, 6 Aug 2020 18:22:56 -0700 From: Andrew Morton To: Muchun Song Cc: mike.kravetz@oracle.com, David Rientjes , mgorman@suse.de, Michel Lespinasse , Linux Memory Management List , Michal Hocko , LKML , Baoquan He Subject: Re: [PATCH v4] mm/hugetlb: add mempolicy check in the reservation routine Message-Id: <20200806182256.7aab51726cd91301d53cff2d@linux-foundation.org> In-Reply-To: References: <20200728034938.14993-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: 78D1D180B3AA7 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 Thu, 6 Aug 2020 15:45:14 +0800 Muchun Song wrote: > On Tue, Jul 28, 2020 at 11:49 AM 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". > > > > Signed-off-by: Muchun Song > > Reported-by: Jianchao Guo > > Suggested-by: Michal Hocko > > Reviewed-by: Mike Kravetz > > Hi Andrew, > > Any comments or forgot to add this to the queue for the > merge window? I think Baoquan He's comment threw me off. I worry about the use of `current' in mempolicy.h. It's the first time this header has referenced current and the patch forgot to include sched.h to get the definition. Presumably it works by accident. I could toss in the #include but sometimes that blows up. But it's unlikely that we'll be getting circular includes or other such nastiness between those two header files, so fingers crossed... --- a/include/linux/mempolicy.h~mm-hugetlb-add-mempolicy-check-in-the-reservation-routine-fix +++ a/include/linux/mempolicy.h @@ -6,7 +6,7 @@ #ifndef _LINUX_MEMPOLICY_H #define _LINUX_MEMPOLICY_H 1 - +#include #include #include #include _