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 7C51EC27C7A for ; Thu, 17 Aug 2023 12:18:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A11F3940020; Thu, 17 Aug 2023 08:18:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C193940009; Thu, 17 Aug 2023 08:18:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 88943940020; Thu, 17 Aug 2023 08:18:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 79409940009 for ; Thu, 17 Aug 2023 08:18:43 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 48BBDB2A66 for ; Thu, 17 Aug 2023 12:18:43 +0000 (UTC) X-FDA: 81133500126.21.136E6EF Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 2486EA0010 for ; Thu, 17 Aug 2023 12:18:38 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eyMaKs5j; dmarc=none; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692274721; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+MuyupV+mEo0a8sy4kXCfy1lN0SMoP5voFKVS9XKlr0=; b=VhPqIwHC4ag+GLazgJTcDvOLRz7EOH8GFTJ4lMfBwcJ4M7juKZgk6WBruk+jNCdDTfFAqh fQi/PC9vTqarSelUSMlxKpxDfCOIjrAolV7KcZ8vn9oDOx38dEWDSlMM2BVzLtR1kBM+AJ GPX2kGeNCyjKvyfwlBVQeqEb+QGkKyM= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eyMaKs5j; dmarc=none; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692274721; a=rsa-sha256; cv=none; b=XaPxhddObGT94qIO0KfiJMkd+dqAAI3dR6pCqvh5j74sxQSxLkmBRdb52PTcuigKSXsVJZ EO9p85bR1pcMlQehURBQA+k9Aht39q+Dlk1zmuz2lqltj6jUjHOKyTC9O0/NJHfgMPfcpi fFtNa7oG0DT2rRDnQSx+oiAj7sRZB80= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=+MuyupV+mEo0a8sy4kXCfy1lN0SMoP5voFKVS9XKlr0=; b=eyMaKs5jzocpH7Imu9V+zeeKOE eYFowVnB5AbsXcFF2s8nHH46fLC7W1yPJXDie60Rsbes8bAoC5ODQgpuzG7a5guV3FBAUHjLUShag Vq8fWt5/2RLVoR345mT63PqPgNllkQFJu7t6QI2O8ud9i1KZ0IvawmdUTtCouSCr+nWJc1TT1TjWF II3H1UOkxaMe0UljaN08VPj6LNE2KDsCz+yueer4M7hBnQRWf2p+otlI9arzAMA9gsjYXbyvYwdJg +86YmG94ry+cS2HeWBbB4/Y5W2f+OCSYCD1CRZoj9P6h2ERFobUgr9bnfcn/OnOPZ7tYULDB3n/GV OCuiURGA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qWbxM-003Bnx-AV; Thu, 17 Aug 2023 12:18:28 +0000 Date: Thu, 17 Aug 2023 13:18:28 +0100 From: Matthew Wilcox To: Zach O'Keefe Cc: Saurabh Singh Sengar , Dan Williams , "linux-mm@kvack.org" , Yang Shi , "linux-kernel@vger.kernel.org" Subject: Re: [EXTERNAL] [PATCH] mm/thp: fix "mm: thp: kill __transhuge_page_enabled()" Message-ID: References: <20230812210053.2325091-1-zokeefe@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Queue-Id: 2486EA0010 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: s91d6bpfdhj485pqrhuzq7gf4myhntqg X-HE-Tag: 1692274718-788610 X-HE-Meta: U2FsdGVkX1+rofDNLTR6CmG15qhGkaH1kcHL5brK0B4g/P938lnABNhrTm4GOW60+cjpiDh2z2u2od4AQCzfGI0H4eJVieGmlaOQxzzkPjNtwj3gM4yErRyDJPqf7z6iCZBYAvusZJXQ9dCOg6XOdq/Sxj+AhqAis0M//rcvmKFOg4PA4Nvk3lnF5S4Z43H/k+3BU2kk7ihF8m7uUaJT4dxPaGlFbamAshWP5E/LGg5Anyj56jqmCW6X/lHg38wBk7JpocBTwVpeJQCouUwgwaBYWVdJcNEuiuCBJvTGN+rErOds5JN3+i6wmLr32PQGLcCFzlJ/kS+sEZMrooBRQPd+k4YqoXA5oGRjGgRnl+7+6oG08AYU4umPxMB3GFQvZQ1vj5f/XvIC06zNr+noSDSw5QCHKCSmvDPWCzGeoPzfiDSnQo5UogMdd+MVM5Oc5hLLeJQE1xjwTKhenp5Iz4b8qFLlUNx3aD+Ndb60bcuuxb8TgcKmytrKQ00ncvQ9TVlLgQ4PagLEeB5P/3v4bluTDEq8Z1B2MUNtvrHULAaoSFR6ckpkGBp3j3LOjulz0gt5UBoaUO23/nWTbnZLiJz6Ju18PJu0E3e3z+jXmn0flWUQVKC1rjL+MO9htzj+k7vH4w0fywTYO9lLxGtZpdE8/YVpral19Db7UxTGo7+6AprE4bZWEDnbM311jonCPFiqRcIiVrVPS4S0nrkTFKD8AbgW1+WyHhMDqNzsLiOzqjaiIXsCps2qr0o7jFAWVcRqgecmzmfeWMcEbfaY9gUU95iA5hp9CsEPh8eKW0bfyV0iiyMG76eIljJ/zJi576edzYeRXLNT5gl9ljrSVYA0at37VkEbJPnx9TpJdGPGEX/RQjXlbE7SLc40CkKNmu2PlCLn12Bcpq0D3BpzrZG8PMpmJoGsrm/OhMt/Y0qqEm2IdZgJxShXRtBKY0A+DlV3njR1dHoehIQkDoW EK73oXFr U62rwORsIZFTgwshkbUrucptqL1mTM5U0cvBGadBIfueEL0zXlsuUABe04DUd61a0ShkM5kr2u+0SdRL8/u9CNRbqRsCht+p/QIYuOVyjFhFEQINRWRssd0uS9L5ualFMt7A+B1GpF9MGJ1WvXoE5r+Vlxd9MiFdnrewZz+MxHfQ/PVGzbcQ2ZulloAHoeV/nw8/eOSeX3ftUOQhaDUVACTXvc+qlwdMyYHVFa04qnn0/e79aulsJ7K3Q0ld181qXtpnemXGIojE4b6+iQffSS0Yn6w== 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, Aug 16, 2023 at 02:31:06PM -0700, Zach O'Keefe wrote: > On Mon, Aug 14, 2023 at 7:24 PM Matthew Wilcox wrote: > > So if we find a large folio that is PMD mappable, and there's nothing > > at vmf->pmd, we install a PMD-sized mapping at that spot. If that > > fails, we install the preallocated PTE table at vmf->pmd and continue to > > trying set one or more PTEs to satisfy this page fault. > > Aha! I see. I did not expect ->fault() to have this logic, as I had > incorrectly thought (aka assumed) the pmd vs pte-mapping logic split > at create_huge_pmd(); i.e. do_huge_pmd_anonymous_page(), or > ->huge_fault(), or fallback to pte-mapping. It seems very weird to me > that hugepage_vma_check() "artificially" says "no" to file and shmem > along the fault path, so they can go and do their own thing in > ->fault(). Wow, hugepage_vma_check() is a very complicated function. I'm glad I ignored it! > IIUC then, there is a bug in smaps THPeligible code when > CONFIG_READ_ONLY_THP_FOR_FS is not set. Not obvious, but apparently > this config is (according to it's Kconfig desc) khugepaged-only, so it > should be fine for it to be disabled, yet allow > do_sync_mmap_readahead() to install a pmd for file-backed memory. > hugepage_vma_check() will need to be patched to fix this. I guess so ... > But I have a larger question for you: should we care about > /sys/kernel/mm/transparent_hugepage/enabled for file-fault? We > currently don't. Seems weird that we can transparently get a hugepage > when THP="never". Also, if THP="always", we might as well skip the > VM_HUGEPAGE check, and try the final pmd install (and save khugepaged > the trouble of attempting it later). I deliberately ignored the humungous complexity of the THP options. They're overgrown and make my brain hurt. Instead, large folios are adaptive; they observe the behaviour of the user program and choose based on history what to do. This is far superior to having a sysadmin tell us what to do!