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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C744CFA3740 for ; Thu, 27 Oct 2022 15:08:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F08EF8E0003; Thu, 27 Oct 2022 11:08:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EB8838E0001; Thu, 27 Oct 2022 11:08:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D809B8E0003; Thu, 27 Oct 2022 11:08:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C99E58E0001 for ; Thu, 27 Oct 2022 11:08:36 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A0E981402EF for ; Thu, 27 Oct 2022 15:08:36 +0000 (UTC) X-FDA: 80067061032.06.DBB73CA Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) by imf17.hostedemail.com (Postfix) with ESMTP id 78B744013B for ; Thu, 27 Oct 2022 15:07:57 +0000 (UTC) Received: by mail-qt1-f177.google.com with SMTP id cr19so1343639qtb.0 for ; Thu, 27 Oct 2022 08:07:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=IIQ4zBFEMq401B7LHco+BoD5rdpZ5Deu1R9Bn5hW7DQ=; b=7Ihsof3XsnlOurWNXvNfkJmwVJTfwnhJqhSKxV+DO+L6B3Tu/kqnAq9TVYZ0Duxf3M W6Td+3HG86QI9uHlG1WT4lBz7n5Hi+2LDaCPaMcqoAdOVJqEYcsJCUef4MylfmzhXlDc eC2w4CBAXy8ttJZMXMHJx6fxvJ1TbafKgtkk0pxH3GiPfyJeVocRes+egtLPyPkq31RO 4ktx9h4emk4aPCwALiSHRAUqNAQlnxAZnBy5kOi2CF8YvliiLajdG8mGMuNWxe1k70WB 2r9rJWDKgl0zVfELj6C2YoJAb0AiFdpBaFpHjB4HRcfS91KHRJsaVwXrlCAlTR4W9jN+ FUEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=IIQ4zBFEMq401B7LHco+BoD5rdpZ5Deu1R9Bn5hW7DQ=; b=UVYzwApkgrYLdYJ8dXOQNhAhVn85ffGyIbDJHOkJufkxwIFy7ceN4jrd5uJukUnXQx IYuo/u3+6X1KNKPvAnxBk7yPsnARdMlSaEkfKd2p/FSBbNJqJ/Y/3zdXJxXywSSC2R66 ows3LsCSmG0K4TsER5ew8X9fE37dc1tke/nVdJqkieqjSEz1yHXrIH0B3kCxpePENrGX SbOtjWGAN+qglfrhFVnu9M4KskHAQYz978FXpGsfNlPdv9ozpsLCKZrll/+teXk4IeVH tCwE7nxY3a4edS2PFMJgdvcHfZsSHpuDAbukXQRb0dcwiEu/kNhm/dVO5M7avU18DiPC kk6A== X-Gm-Message-State: ACrzQf0G3yBLJYocjy7Td2cP3MsAVKzna4Dp5TYeWo1Wky3p9j7X3mWY Ntuf8Z/B+/CTc7WsTC2KaME1XA== X-Google-Smtp-Source: AMsMyM41MUratBwSfmaBQZiJgUc6R+Z5LNxo3ebXzmvLT/wPQbTT7UxQqNW99RHZzOGPEn1wVa1fQw== X-Received: by 2002:a05:622a:50e:b0:3a4:e734:409e with SMTP id l14-20020a05622a050e00b003a4e734409emr10328431qtx.497.1666883276551; Thu, 27 Oct 2022 08:07:56 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::25f1]) by smtp.gmail.com with ESMTPSA id q68-20020a378e47000000b006b929a56a2bsm1163569qkd.3.2022.10.27.08.07.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 08:07:56 -0700 (PDT) Date: Thu, 27 Oct 2022 11:07:56 -0400 From: Johannes Weiner To: Mike Kravetz Cc: Rik van Riel , Chris Mason , David Hildenbrand , Axel Rasmussen , Peter Xu , James Houghton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, Andrew Morton Subject: Re: [BUG] hugetlbfs_no_page vs MADV_DONTNEED race leading to SIGBUS Message-ID: References: <215d225585ff3c5ea90c64e6c9bdff04ab548156.camel@surriel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=7Ihsof3X; spf=pass (imf17.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.177 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666883277; a=rsa-sha256; cv=none; b=fsdUPQ/xv0mO7M7zZcX/rjeSQAUO9HzjtHAZr3Y48Ue4whX8eAZXZF3wq+fbAYjNG4mMgw XuQDwo7kK+mRUmKyrQBHVcRyY+NDqaUDSR6oJPxFxkcn+gNn5daqx7DVewUmRL/WUoj8sl A3CWdNsKvwwo9xu0oZQOtaZyj34kvEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666883277; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IIQ4zBFEMq401B7LHco+BoD5rdpZ5Deu1R9Bn5hW7DQ=; b=Wj6QCLX0B5DXUgRUFUIaS0XaZSk9qv1bGKR1SJ8pdEU0SLmhsGkEK7sOKH1610rkZttnS0 blbBSTn6W2kJqP04x0OmIW+47xYr4ev2E13lFvvqiU38FAKMIb+nrvxUsle0NFFRl7pgCz Y+GwMwD4VrmVeHJ+NGAY0D3VZriaZRo= X-Rspam-User: X-Rspamd-Queue-Id: 78B744013B Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=7Ihsof3X; spf=pass (imf17.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.177 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org X-Stat-Signature: 7yf8a6urpj49u1wenud6nwxzngbb9mam X-Rspamd-Server: rspam10 X-HE-Tag: 1666883277-774860 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 Wed, Oct 26, 2022 at 12:38:43PM -0700, Mike Kravetz wrote: > On 10/25/22 16:37, Rik van Riel wrote: > > What are the reasonable alternatives here? > > > > Should we see if anybody can come up with a simple solution > > to the problem, or would it be better to just disable > > MADV_DONTNEED on hugetlbfs for now? > > Here is one thought (perhaps crazy). Do not allow MADV_DONTNEED on > hugetlb mappings. This would help with the library code passed hugetlb > mapping. For the use cases where MADV_DONTNEED on hugetlb is desirable, > create ?MADV_DONTNEED_HUGETLB? that only operates on hugetlb mappings. > In this way the caller must be aware they are operating on a hugetlb > mapping. What could also work is implementing mlock() for hugetlb, and having MADV_DONTNEED respect it. That would allow libraries/general-purpose allocators to continue using MADV_DONTNEED without being aware of the underlying memory situation. Whoever is responsible for setting up the memory pool could just mlock() - or not, if hugetlb overcommit is enabled - and the GP allocator would do the right thing in both scenarios. [ Our setup code is actually already calling mlock() on the hugetlb ranges. We never wanted DONTNEED to free hugetlb pages - it just happened to work so far because DONTNEED wasn't implemented for them. If both DONTNEED and mlock() were implemented, we'd be good. ] Johannes