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 X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96972C4363A for ; Tue, 20 Oct 2020 14:27:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B534722244 for ; Tue, 20 Oct 2020 14:26:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="GEOh84wv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B534722244 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 111DD6B006E; Tue, 20 Oct 2020 10:26:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 09C736B0070; Tue, 20 Oct 2020 10:26:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECD4E6B0071; Tue, 20 Oct 2020 10:26:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0065.hostedemail.com [216.40.44.65]) by kanga.kvack.org (Postfix) with ESMTP id BBC656B006E for ; Tue, 20 Oct 2020 10:26:58 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 50070180AD830 for ; Tue, 20 Oct 2020 14:26:58 +0000 (UTC) X-FDA: 77392530516.29.spoon90_0a0429327240 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 1D31F180868CA for ; Tue, 20 Oct 2020 14:26:58 +0000 (UTC) X-HE-Tag: spoon90_0a0429327240 X-Filterd-Recvd-Size: 2593 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Tue, 20 Oct 2020 14:26:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=2aLHtQDOdruUdSroCRCDtJfw/xvi97M7ZJVS89XU29o=; b=GEOh84wvtk8kt+7ZHCJ2SLd14k MDKN+W1Uo2yzQZd9iDWQyL7Q7YVdMvSrA3NOhaH6KCF5O+156BHFhWhJY7ZLUpywcPl6eUlKG/3Og F7aR6V7ihql/EpGK/i95/VJOhDTCv6B3wydBUHh0OWo8YvlUNYpuF3ziUDHT1CgyqDqBdnnvDJa6e SjVx42l2yGQe8xhw+nz/+5+TcBeKtCVmwT+9yduHxq//U6bMX3MKCKTvpI87EMY+fpkcr60wVbrmS ynJmRxIs32A2X0n05MFplEuag6/nGUza83h/g+WvUUndHSS/hGuB6Ff/VEWtxOIUxTo+S2z0pTMZW MZeC2v7A==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUsbF-00084P-86; Tue, 20 Oct 2020 14:26:53 +0000 Date: Tue, 20 Oct 2020 15:26:53 +0100 From: Matthew Wilcox To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: Re: Splitting a THP beyond EOF Message-ID: <20201020142653.GB20115@casper.infradead.org> References: <20201020014357.GW20115@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201020014357.GW20115@casper.infradead.org> 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 Tue, Oct 20, 2020 at 02:43:57AM +0100, Matthew Wilcox wrote: > I think the easiest way to fix this is to decline to allocate readahead > pages beyond EOF. That is, if we have a file which is, say, 61 pages > long, read the last 5 pages into an order-2 THP and an order-0 THP > instead of allocating an order-3 THP and zeroing the last three pages. Oh yeah, really easy. +++ b/mm/readahead.c @@ -481,6 +481,11 @@ void page_cache_ra_order(struct readahead_control *ractl, if (order == 1) order = 0; } + /* Don't allocate pages past EOF */ + while (index + (1UL << order) - 1 > limit) { + if (--order == 1) + order = 0; + } err = ra_alloc_page(ractl, index, mark, order, gfp); if (err) break; I've added that to an earlier patch and I've pushed out commit cd3fa4bc6516 as the head of http://git.infradead.org/users/willy/pagecache.git/shortlog