From patchwork Sun Jan 16 12:18:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12714556 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 34054C433EF for ; Sun, 16 Jan 2022 12:38:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D363E6B007D; Sun, 16 Jan 2022 07:38:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C94896B007E; Sun, 16 Jan 2022 07:38:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B38266B0080; Sun, 16 Jan 2022 07:38:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0025.hostedemail.com [216.40.44.25]) by kanga.kvack.org (Postfix) with ESMTP id A49216B007D for ; Sun, 16 Jan 2022 07:38:10 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5ACE918210E84 for ; Sun, 16 Jan 2022 12:38:10 +0000 (UTC) X-FDA: 79036102740.14.63F8580 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id F1BB080004 for ; Sun, 16 Jan 2022 12:38:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=N9+b+qRj01tgXtfzT98WhdYz3W5Hnc+VP1/gS5QLC2A=; b=VHAVkzo/Ow57u7iZ+eMc5A5UVU oK9KEC5BirQhQqk0WgFmvGP0cW5qPgAI3u0rTZUbWIKy4GReRWXhYE6qAF5YGsnFyTnVtTU1CPQvW sMuigGT1W6w172hqhpOrtb8RP3JqhazxOsbc3RLche6LofYifVwENLX67RLinReTxXLBM7ikaks+h tq6Cfd/XYn/7dsOOjdJwynyLFIm51cdaVFnOTT7+MuEly0ckH8fJg23pMHYWyMPXLanbVBX0X/W9v N8aDt/KVCxjTCp3t3UPcuL49tk+Sa1+0Pmz2Ue6hgH6TOXhl4GC12ky4FCFgnWyq2IX9dKqZvkosR 0SMZC/YQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1n94UN-007FUp-2K; Sun, 16 Jan 2022 12:18:27 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 11/12] mm/filemap: Support VM_HUGEPAGE for file mappings Date: Sun, 16 Jan 2022 12:18:21 +0000 Message-Id: <20220116121822.1727633-12-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220116121822.1727633-1-willy@infradead.org> References: <20220116121822.1727633-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: F1BB080004 X-Stat-Signature: 3bi9ck7mr66d18fuiw55zsn14msym4p3 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="VHAVkzo/"; dmarc=none; spf=none (imf30.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam08 X-HE-Tag: 1642336689-566593 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: If the VM_HUGEPAGE flag is set, attempt to allocate PMD-sized folios during readahead, even if we have no history of readahead being successful. Signed-off-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index 8f076f0fd94f..da190fc4e186 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2915,6 +2915,24 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf) struct file *fpin = NULL; unsigned int mmap_miss; +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + /* Use the readahead code, even if readahead is disabled */ + if (vmf->vma->vm_flags & VM_HUGEPAGE) { + fpin = maybe_unlock_mmap_for_io(vmf, fpin); + ractl._index &= ~((unsigned long)HPAGE_PMD_NR - 1); + ra->size = HPAGE_PMD_NR; + /* + * Fetch two PMD folios, so we get the chance to actually + * readahead, unless we've been told not to. + */ + if (!(vmf->vma->vm_flags & VM_RAND_READ)) + ra->size *= 2; + ra->async_size = HPAGE_PMD_NR; + page_cache_ra_order(&ractl, ra, HPAGE_PMD_ORDER); + return fpin; + } +#endif + /* If we don't want any read-ahead, don't bother */ if (vmf->vma->vm_flags & VM_RAND_READ) return fpin;