Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2175886rdb; Tue, 3 Oct 2023 12:36:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzXGeiBMH+5x2k7TrepV+awXSapSa7PrFBd5JuHgcw3t+k59rv6tbZ9ID3EKQBv9IGmYOZ X-Received: by 2002:a54:4087:0:b0:3a4:1f0f:d108 with SMTP id i7-20020a544087000000b003a41f0fd108mr507033oii.46.1696361767398; Tue, 03 Oct 2023 12:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696361767; cv=none; d=google.com; s=arc-20160816; b=Q/zreKJ3eeTn/+TR4E+zIZoYx9kuUpp//YaGWu5A2VZbT0RVCBJ742BbugqbMfD9XT D4/0tEddvTve2ecpASLgl5N2uFnOxbYfEpEH21F0S58eW3p4N/XFpGCmwjXZ4MHOE4DL kgCiniaXTE5wu55EPKsYI1qD6Wq2RKnm563SWS5n1I3ywlHaka75HRYSpLIty5b5AFOD fRfLZW3Owmt3p021ZXFhFrcJ3Bw9J+/fN0ULzyVSdbg9AlMGyvtmfBnXBQiw8rAIdoGe JmEVS2PJ3fx9MLQr0J8/NOrgKx96Vf7MmiPtfsGiZwisJW7Oe8PttDUq9u7mbo+tBsb9 prww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=qX2Lzr/YV4S1SfS2ZnJXoRJQW8oKVtONsoXilGgy/7E=; fh=hOaN1/HlXWrx/vHluPQdqKKg6VbIVLaMJV2uvguRs3c=; b=ayyXKUfzG6FUCJwoXTKOqK7qOEUC5qq2VywadtM63Qkeq8oJew7yk2D0GBbKXBttXb IGJdrB79iu+uPnKdKHEn3YNsIfoFo95Wn8E6fKXGDqF3jc+el6VfEa6pAjRG0/rhtKkd b5x3ObpFWaD6Mwen7oXeorWjG4PNMS6mueNghW+nuXSxWGKavmbW7netGtHhH2QIsuoW QBvdrEKWEuxBbqnKj6/UM5noF91INzOK2MOY2pss/aHAOJ/e48FyZeSmqs3Z42MGNea2 zB9KPwvm7CQLFBR+pPI+tDS+/tx/I4fZKmVtgMh4E8JKuTh81gCPM9M+KAi1KwZSocRv uCOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id t23-20020a656097000000b0057771e49c25si2011528pgu.693.2023.10.03.12.36.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 12:36:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 8256D80AC45E; Tue, 3 Oct 2023 12:35:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240878AbjJCTfw convert rfc822-to-8bit (ORCPT + 99 others); Tue, 3 Oct 2023 15:35:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240785AbjJCTfu (ORCPT ); Tue, 3 Oct 2023 15:35:50 -0400 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BF7D93 for ; Tue, 3 Oct 2023 12:35:47 -0700 (PDT) Received: from imladris.home.surriel.com ([10.0.13.28] helo=imladris.surriel.com) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qnlAz-0000RR-1g; Tue, 03 Oct 2023 15:35:25 -0400 Message-ID: <8d19b6d092b7b5d9b1d0829e0d99c9915db3ed61.camel@surriel.com> Subject: Re: [PATCH 2/3] hugetlbfs: close race between MADV_DONTNEED and page fault From: Rik van Riel To: Mike Kravetz Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, linux-mm@kvack.org, akpm@linux-foundation.org, muchun.song@linux.dev, leit@meta.com, willy@infradead.org Date: Tue, 03 Oct 2023 15:35:25 -0400 In-Reply-To: <20231002043958.GB11194@monkey> References: <20231001005659.2185316-1-riel@surriel.com> <20231001005659.2185316-3-riel@surriel.com> <20231002043958.GB11194@monkey> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 Sender: riel@surriel.com X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 03 Oct 2023 12:35:59 -0700 (PDT) On Sun, 2023-10-01 at 21:39 -0700, Mike Kravetz wrote: > > Something is not right here.  I have not looked closely at the patch, > but running libhugetlbfs test suite hits this NULL deref in misalign > (2M: 32). Hi Mike, fixing the null dereference was easy, but I continued running into a test case failure with linkhuge_rw. After tweaking the code in my patches quite a few times, I finally ran out of ideas and tried it on a tree without my patches. I still see the test failure on upstream 2cf0f7156238 ("Merge tag 'nfs-for-6.6-2' of git://git.linux- nfs.org/projects/anna/linux-nfs") This is with a modern glibc, and the __morecore assignments in libhugetlbfs/morecore.c commented out. HUGETLB_ELFMAP=R HUGETLB_SHARE=1 linkhuge_rw (2M: 32): Pool state: (('hugepages-2048kB', (('free_hugepages', 1), ('resv_hugepages', 0), ('surplus_hugepages', 0), ('nr_hugepages_mempolicy', 1), ('nr_hugepages', 1), ('nr_overcommit_hugepages', 0))),) Hugepage pool state not preserved! BEFORE: (('hugepages-2048kB', (('free_hugepages', 1), ('resv_hugepages', 0), ('surplus_hugepages', 0), ('nr_hugepages_mempolicy', 1), ('nr_hugepages', 1), ('nr_overcommit_hugepages', 0))),) AFTER: (('hugepages-2048kB', (('free_hugepages', 0), ('resv_hugepages', 0), ('surplus_hugepages', 0), ('nr_hugepages_mempolicy', 1), ('nr_hugepages', 1), ('nr_overcommit_hugepages', 0))),) It may take a little while to figure this one out. I did some bpftracing, but don't have a real smoking gun yet. The trace certainly shows the last user of the leaked huge page going into __unmap_hugepage_range. -- All Rights Reversed.