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=-0.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, 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 56CE2C433E0 for ; Tue, 9 Mar 2021 09:33:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CE4E4650DF for ; Tue, 9 Mar 2021 09:33:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE4E4650DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ska.ac.za Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 675068D00D2; Tue, 9 Mar 2021 04:33:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 64B3F8D007F; Tue, 9 Mar 2021 04:33:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4EC328D00D2; Tue, 9 Mar 2021 04:33:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0159.hostedemail.com [216.40.44.159]) by kanga.kvack.org (Postfix) with ESMTP id 3437C8D007F for ; Tue, 9 Mar 2021 04:33:27 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E7CF6181AF5EA for ; Tue, 9 Mar 2021 09:33:26 +0000 (UTC) X-FDA: 77899822812.09.A627BC9 Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.180]) by imf26.hostedemail.com (Postfix) with ESMTP id DBDFF4080F4A for ; Tue, 9 Mar 2021 09:33:23 +0000 (UTC) Received: by mail-yb1-f180.google.com with SMTP id u75so13250121ybi.10 for ; Tue, 09 Mar 2021 01:33:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ska-ac-za.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=nMz2SE6yK8NuuSN2O76i5PWLuXA3DClMM0SI5bWTeTs=; b=pQZJIkhJIrTlQ5xuJKq91zU0iv1mA3c/J2cDXMBFFGq7TPIgVarzToktvB8469Va7l 5AY/bJciTWetdsLSnSKCmRc4d8oIp+TxyMOahmdbCc4zrMK3oCmyP4f2YbbYHsbCSKZP n6oynnVR7EwsbrSAdS/s+GRwCsDXpii3SqdEoaTU8xUjNLQJhhCKab1Zd+i5FdTXXeyo sxhnsxg8YmkLzVQdTDt6JVIL6LHfchpUNWIgc1+V2rmqRIk05E6WOpTQErOgmwlTF0Om MkFGaJQkB9Hqm8pRYPt4kAik8O306E4wnW9hRBoPFuGBFbmmugZiv7+0ihHd+H/OlLlV k74A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=nMz2SE6yK8NuuSN2O76i5PWLuXA3DClMM0SI5bWTeTs=; b=MNtJQht8hkOlIbKpakmM8AopaHF7FQY4fqGkgLr6dLorKadDgkUKqhEgW2O65Wj7D1 cGaRw841xN0VdbCNgkEiRuwUhe3udDV4NjNM4OgtKv+2q6nLAaIr3gqeO6FXriR7xHRD e7NmAptfC8i05eRvils5XM+WbX+jT7wFqqeJZzMVR024OeSXplDLlS20wYam60tPWPim dJPM+g1qFXHOVzYfV5wr75nexHPicAWLF0vn3HL6dE8FMv8u9I4Rrbu0uaZkzTXDzcrC xcC1jzKAY1CgjUK0o6HKqIJP2X9AZUHku7jESjIM94KhPvI/r/qPj4/FLmFu6yE27ihH FD5w== X-Gm-Message-State: AOAM532jwQ2l4cDjH9npoTPnIZrDZlXtcJ2MEqyIkc9UZ9z+SaRN4690 d2j0oGiUAAqCp+GAMoplg+bjLvxUYdmPUi2Ityb7RNWXIXLY/n9q X-Google-Smtp-Source: ABdhPJw9QyFhcwH37W9qY+wNNZ6wdP1hdD4t3hwOpyZ6o8T7zYGze3q7hZn+ilMsqUpJtgeRxgX9EbO+wNqDX92TxlI= X-Received: by 2002:a25:d449:: with SMTP id m70mr41282233ybf.101.1615282404772; Tue, 09 Mar 2021 01:33:24 -0800 (PST) MIME-Version: 1.0 From: Bruce Merry Date: Tue, 9 Mar 2021 11:33:13 +0200 Message-ID: Subject: Is MAP_POPULATE supposed to fail silently? To: Linux MM Content-Type: multipart/alternative; boundary="000000000000f2fb3605bd173d10" X-Stat-Signature: cqrmri9qzycfjyymif1kpgmt5gaoqkk3 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: DBDFF4080F4A Received-SPF: none (ska.ac.za>: No applicable sender policy available) receiver=imf26; identity=mailfrom; envelope-from=""; helo=mail-yb1-f180.google.com; client-ip=209.85.219.180 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615282403-856041 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: --000000000000f2fb3605bd173d10 Content-Type: text/plain; charset="UTF-8" Hi I've run into a problem with using mmap(..., MAP_ANONYMOUS | MAP_POPULATE | MAP_HUGETLB). If there are no huge pages available due to vm.nr_hugepages (or hugetlb.2MB.rsvd.limit_in_bytes cgroup setting) then the mmap call fails and I can gracefully fall back to 4KB pages. However, if neither of the above apply but hugetlb.2MB.limit_in_bytes prevents pages being mapped, then it appears that MAP_POPULATE is silently ignored (according to mincore), and rather than being able to gracefully fall back, attempting to use the memory results in SIGBUS. Is that expected behaviour? I don't see anything in the mmap(2) man page about it being best-effort (in contrast to MAP_LOCKED, which explicitly says the call won't fail if it can't lock the memory). This is on Linux 5.8 on Ubuntu 20.04. I can provide sample code if it's of interest, or test on a newer kernel if it'll help. Thanks Bruce -- Bruce Merry Senior Science Processing Developer SARAO --000000000000f2fb3605bd173d10 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

I've run into a problem with using mmap(..., MAP_ANONYMOUS | M= AP_POPULATE | MAP_HUGETLB). If there are no huge pages available due to vm.= nr_hugepages (or hugetlb.2MB.rsvd.limit_in_bytes cgroup setting) then the m= map call fails and I can gracefully fall back to 4KB pages. However, if nei= ther of the above apply but hugetlb.2MB.limit_in_bytes prevents pages being= mapped, then it appears that MAP_POPULATE is silently ignored (according t= o mincore), and rather than being able to gracefully fall back, attempting = to use the memory results in SIGBUS.

Is that e= xpected behaviour? I don't see anything in the mmap(2) man page about i= t being best-effort (in contrast to MAP_LOCKED, which explicitly says the c= all won't fail if it can't lock the memory).

This is on Linux 5.8 on Ubuntu 20.04. I can provide sample code if it= 9;s of interest, or test on a newer kernel if it'll help.

Thanks
Bruce
--
Bruce Me= rry
Senior Science Processing Developer
SARAO
--000000000000f2fb3605bd173d10--