From patchwork Tue Jun 25 09:06:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 13710788 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 89693C2BBCA for ; Tue, 25 Jun 2024 09:07:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DD626B02FA; Tue, 25 Jun 2024 05:07:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 18E2E6B02FB; Tue, 25 Jun 2024 05:07:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 055016B02FD; Tue, 25 Jun 2024 05:07:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id DBDC26B02FA for ; Tue, 25 Jun 2024 05:07:43 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 618A41616F9 for ; Tue, 25 Jun 2024 09:07:43 +0000 (UTC) X-FDA: 82268833206.24.C1DB8D0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id A735F100008 for ; Tue, 25 Jun 2024 09:07:41 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EWOtKHMe; spf=pass (imf14.hostedemail.com: domain of gshan@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=gshan@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719306454; a=rsa-sha256; cv=none; b=r8IbpiOPwQp1574KMH7keywgdC5oXtEj52QCoNcFLNBvRLrhsB27645gWeIAujQDKfMrCU M7sXOWjUQ1gzwxvm8hA0RNBml/5a7c3R4RnffC9dkGJTRkO7OGLOyagl1cwIfZwfur4U6L hhClc3BZRufCiIR09e2sibp6xQCdlGA= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EWOtKHMe; spf=pass (imf14.hostedemail.com: domain of gshan@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=gshan@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719306454; 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=ptlUNcO5mIabfV9LABSh8DDvNkvRbhBbpL84ksizTYg=; b=ObSN2bYXiBxHeIdpGp5s/zPvm+bxqwJKSwchAxLwOJ1AnW8EnifDqUCekSEpSeVbKsPJmI o/5iFCfjGYsjQOBdT8DSkmPml+IsY+ULWl8Nn+R+rzo+d7choO/Bg3aUsov+zkBR6VcsPe L3Skg8CSd3Ap38tagTIKhs0i4HGdgy0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719306461; h=from:from: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; bh=ptlUNcO5mIabfV9LABSh8DDvNkvRbhBbpL84ksizTYg=; b=EWOtKHMeK0G21PUNyo/389w4El6r6jDAv+5a3EwLSZXfkKLUCtJO2QIgOAhkLNFh7ujBsC kizSgV5g6dvSnEiL/wCCDplrXcVE8Mow2da2s151wqLlMUnFhCAISytzdCz5HmYd1/wPPi mmayMvs3arQDynARvribTBy52a4vb2g= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-yOuNp3xGN_WdXUTuwYLdhg-1; Tue, 25 Jun 2024 05:07:35 -0400 X-MC-Unique: yOuNp3xGN_WdXUTuwYLdhg-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 397DE19560AD; Tue, 25 Jun 2024 09:07:33 +0000 (UTC) Received: from gshan-thinkpadx1nanogen2.remote.csb (unknown [10.67.24.180]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7A8801956087; Tue, 25 Jun 2024 09:07:25 +0000 (UTC) From: Gavin Shan To: linux-mm@kvack.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, david@redhat.com, djwong@kernel.org, willy@infradead.org, akpm@linux-foundation.org, hughd@google.com, torvalds@linux-foundation.org, zhenyzha@redhat.com, shan.gavin@gmail.com Subject: [PATCH 3/4] mm/readahead: Limit page cache size in page_cache_ra_order() Date: Tue, 25 Jun 2024 19:06:45 +1000 Message-ID: <20240625090646.1194644-4-gshan@redhat.com> In-Reply-To: <20240625090646.1194644-1-gshan@redhat.com> References: <20240625090646.1194644-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Stat-Signature: tkae6iuqoiqs95s8jooz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IYKylSGbxGdqM66ExpnTjuVs79PC0pTW7R0BW9GshpzVxlg/FNEM3OxHGrPf13uk86bbFmLeLJnH2ieremokbS1HDoOvNgB2e2s4BNQcNOhpaxFO09ipQL6umglgCwiDi5HohV6m6tUfb1QsWSpMPF/p6BdrGvtjXfYWGkH21e4JZVvIAwtPg4/OA5BtHYbvm0M2deGICBpnmhbkLxnMfEBTGbCkkqvdSAdDc1xllim2cE9I5C5IuO1laxy7HtzWdLUIu7IV+ioppgpWeuIyHY9F3dbMAiUh9jsip1Jd46n8lqNA/igeDSVRFAYPMCKTC6awUJzKJa7gKBS/ihfQba90zj5mHAl9CBxb8akxndNwEeAzlHnLyXu9qvwL+ku1902JpdPh0irhMMsI1XDatlOFf0+p7j2x0OJr8eIXTcVxl+s= 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: List-Subscribe: List-Unsubscribe: In page_cache_ra_order(), the maximal order of the page cache to be allocated shouldn't be larger than MAX_PAGECACHE_ORDER. Otherwise, it's possible the large page cache can't be supported by xarray when the corresponding xarray entry is split. For example, HPAGE_PMD_ORDER is 13 on ARM64 when the base page size is 64KB. The PMD-sized page cache can't be supported by xarray. Suggested-by: David Hildenbrand Signed-off-by: Gavin Shan Acked-by: David Hildenbrand --- mm/readahead.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index c1b23989d9ca..817b2a352d78 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -503,11 +503,11 @@ void page_cache_ra_order(struct readahead_control *ractl, limit = min(limit, index + ra->size - 1); - if (new_order < MAX_PAGECACHE_ORDER) { + if (new_order < MAX_PAGECACHE_ORDER) new_order += 2; - new_order = min_t(unsigned int, MAX_PAGECACHE_ORDER, new_order); - new_order = min_t(unsigned int, new_order, ilog2(ra->size)); - } + + new_order = min_t(unsigned int, MAX_PAGECACHE_ORDER, new_order); + new_order = min_t(unsigned int, new_order, ilog2(ra->size)); /* See comment in page_cache_ra_unbounded() */ nofs = memalloc_nofs_save();