Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2293578rdb; Tue, 3 Oct 2023 17:20:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0YbfHvjv4xOUY+XYyPc0zSKlLHYCr+NEYXL+ng3VRBNem2i+PA1Y+y2EgYWf/IwU+yYYB X-Received: by 2002:a05:6a20:158e:b0:15c:b7ba:1671 with SMTP id h14-20020a056a20158e00b0015cb7ba1671mr1158940pzj.2.1696378842842; Tue, 03 Oct 2023 17:20:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696378842; cv=none; d=google.com; s=arc-20160816; b=Cxnk03nbTSPcetaL+QE0JVW+d8ILlTX0Vl1umoQ/UR7WprLRVm49fLJBZCt+dVWJob I0HzW6Gq2hxJvMzrBCQIfxa1gP/zC1zvJ/WuUd1Ct78rgxxLjNY6+kj8HbS7zUm3hN9D a3Ku2UmRJUJ1iZon07Xqi7qEJPT1H+831ACiDGQu6UZoni7Hmds4Yc5FT0C7G5buanWo 9RQD6FlXJkMGgl0i9OuNaroxlxTac//fA9toFQ3iZ3LJto0vbzUT7gIA20b4P/Bbl1fu gyHg3dN3swlQodjMyt3SuS7zhIWr+FyHFyP9sn/j0VjObg/pvQelilNGe52eqHCnmusr s/vA== 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=XKE4O+sxAphAoekwPcr6sbmvDa8ppS2ywl79Gr6COyc=; fh=hOaN1/HlXWrx/vHluPQdqKKg6VbIVLaMJV2uvguRs3c=; b=ZSmBqDM92NMJn4WCdbpPw/PLrCa9PInVykv69qfyHQnvBdEHfxL1xXzzoswBGSGs+/ EzzLnma1P0+4QCjW+8dqeT7yHAtjSTN4Z8nt8DEEysrLv3jO0g1b+EPl8yO+3YAHPs6b yMvlDoz0GX8QC4MtmjrIOUO9J6DoxJSD+cEAXnlXmeO6D/dtvodHtNenuA0mvMTQmjhX A3IG0ZDqp089J3qXKn6AmHz19I7J6OMCx8GOwXHYsLm/ejXVfMXFS2JnbMc4wI2M0757 0NOX+YTnwWbFxdovb2iJVv6D3yGQ46TSpXFOhZdcgp8jAuoox9+DiNBDVQ7KDOBbZplY YvQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id fa20-20020a056a002d1400b0068fce6a86acsi2697162pfb.121.2023.10.03.17.20.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 17:20:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 8DCF3812670F; Tue, 3 Oct 2023 17:20:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238456AbjJDAUe convert rfc822-to-8bit (ORCPT + 99 others); Tue, 3 Oct 2023 20:20:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238406AbjJDAUc (ORCPT ); Tue, 3 Oct 2023 20:20:32 -0400 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44151B4 for ; Tue, 3 Oct 2023 17:20:26 -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 1qnpcQ-0003RO-2X; Tue, 03 Oct 2023 20:20:02 -0400 Message-ID: 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 20:20:02 -0400 In-Reply-To: <20231003201916.GD314430@monkey> References: <20231001005659.2185316-1-riel@surriel.com> <20231001005659.2185316-3-riel@surriel.com> <20231002043958.GB11194@monkey> <8d19b6d092b7b5d9b1d0829e0d99c9915db3ed61.camel@surriel.com> <20231003201916.GD314430@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.9 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLACK autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Tue, 03 Oct 2023 17:20:39 -0700 (PDT) On Tue, 2023-10-03 at 13:19 -0700, Mike Kravetz wrote: > On 10/03/23 15:35, Rik van Riel wrote: > > 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))),) > > > > Please consider the above failures normal and expected.  That have > been > this way for many years.  Sorry for any waste of your time. > > Of course, if you would like to look into these you are welcome. I'm not too worried about the test cases returning failure, but having free_hugepages not go back to 1 after linkhuge_rw exits looks bad. In this case it appears that linkhuge_rw simply left behind a file in /dev/hugepages when it died, and removing that file returns free_hugepages back to what it should be. I guess I'll go run the test cases without -c 1 :) -- All Rights Reversed.