Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp909730rwi; Thu, 27 Oct 2022 08:54:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM788kShUy1n3lSW8DINDHsPTvchI4UhvOUZQR/gZWS5x57yK3H/jpAYS9OOk88r9sJZ2JPN X-Received: by 2002:a17:907:728a:b0:78d:2b4b:e7f7 with SMTP id dt10-20020a170907728a00b0078d2b4be7f7mr42477277ejc.269.1666886073500; Thu, 27 Oct 2022 08:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666886073; cv=none; d=google.com; s=arc-20160816; b=jOZJdaMktjwbpM6uXep2V8FC0D5YibxhxCBxbbV03/b2+KHpyKiWeBxaRd00TkfCJf V0T1UoXHnwWoA1ceSesWol8Qwm0m+lVFoGUBCVT2oA/SQhOUqi0FzfdDh74275/WcJzk i6lNL2pNsFOXSIJ/8HqGRm8CdtNrJJrQ9EMNRgZqx1FBnrwy17fslOvXBn6lBsLte1Ys mzXZFDipXG2YOfslucOtf0M2LjEYr4hGiFq+Lo/inSW7qKHtmKOeG2Nr2dWIjO7YM/W4 /7etfbZ134HxcFr0kVD+PR2oCKdXAhDcQe9ngV+OnoDG9h+v7FgqmzXNsjg7y5G+fPl3 Q2sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IIQ4zBFEMq401B7LHco+BoD5rdpZ5Deu1R9Bn5hW7DQ=; b=QlwKiNq40dh8PRP64w4dO9bN+xHKUcuUPg5aNKMzNtQ0ke0aTdqpJzyrgnH9dGEOPg TfvwAa+5PD0Ozqg7lUHTnFCOk1NY7vNSKDNb4g+ubyClBbnVfByGZTpegLIqQnhqIy7o oxMwT9Qogqk5r/7C59z8hhiFAZ9jXdSnvwU9XWmqmeR7g9ahKlvS1GwnEydDsTWNVrA0 uZO0LooZGQGiqWAM042IXiU5S3xLFP455DhF9APPMW54nbxtPSUCB76vAlQ7uhnnk6XE /MgrRQR6AbZITmWs954lfFt/9tg61xhHK56Wqn2D6NaPGJrJg8lnT1rxOGZuqvfuNC9r 9a5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=7Ihsof3X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg32-20020a170907a42000b00791a3dd01b6si1691553ejc.864.2022.10.27.08.54.07; Thu, 27 Oct 2022 08:54:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=7Ihsof3X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235254AbiJ0PID (ORCPT + 99 others); Thu, 27 Oct 2022 11:08:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235132AbiJ0PIC (ORCPT ); Thu, 27 Oct 2022 11:08:02 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 671841849BD for ; Thu, 27 Oct 2022 08:07:57 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id ay12so658133qtb.12 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=sr5yPMEwC1pSq5+9N0gx+1kpNT5AwIvz4x660eQ5vMhVCNDTYHgJ7On23wnZqudYU0 Pfv0PaWi2iBSuVVVhUsetUNuuY7gNuximMwUWFvVi/hBo2CDtVnu0dUPHDGL91U53Hv6 hBAfiuDiE7S2Mj3oRO7PVYT6l85Drv80N4EYigAEup22faYNuPZHjzHtU+sUnZGfPESR lm61AlTJ+JithSFpqoom8p2P6lWGMAWatxKdmYwr2lZ1esDkBPMDVUgduhDA3NPiUw6O wjm6NGMPGtGps64dygLMq+/4lUSH/b68Ajann8MNpMaYCrjKDGe+n9b+OPWqh4n1J4hV 3+WQ== X-Gm-Message-State: ACrzQf3bCRX7MxdtPDeuGTHrbD/I2qz/dvSXwTq1Hr9J2FLPRezViIWM B0YoeIHRlhqaqkegByfacelX0g== 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: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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