From patchwork Fri Sep 15 18:38:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 140890 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1441357vqi; Fri, 15 Sep 2023 19:35:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAywQ3aIUI8n/nfihkLj61G6bMPOd6P6Msp+H7mkBxI6+O9kInut7ykMZddeZbIuxLx02j X-Received: by 2002:a05:6a20:dd9a:b0:14c:512c:c138 with SMTP id kw26-20020a056a20dd9a00b0014c512cc138mr3007399pzb.60.1694831712817; Fri, 15 Sep 2023 19:35:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694831712; cv=none; d=google.com; s=arc-20160816; b=ioP5ITx20oUl5IF9Iu1Psw3bu0EqQM+P9lPS2Z/2LADqTGugHRSD4zfXs25uHOdQzl AIIkEtDhpklSmXBK1EpFv41k+F3kjZrhw8d11LCiEvh32md7BnVPY09joWT6Q6b7Bejf 0h3e0qC2e25e0T2aff/Fg94ukaBPLgLxLCBhbdcoDFTq52zIb4ww2QAMDlJ9tdVM7huf kJa/iCeBArmVsu37ZKrfpl7oiBQiPkDt2vIRcUtAWqeK1kS5eVyTg/HKgDwzvzd/0y0q 6EwR3LCg4GnncqjzFkKebECJ7feBWuLmppHxN7SOL51xyL0bhlk9XhN8SuEGx0F2KZJT yDjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2MKZNT2C20PsiAht17s5oJnb138+SmsAPSOiRhddgUA=; fh=kl+S4GAUWD1kOeoqBopscteh2mu3DZslcHc01dOJ6TI=; b=slgpyHCx2cALiept9hPLn9gN7bHLbjRW+LzObr6+P3x/2/xvmb6hcKWXEzFeVlLkDo xdHp2uZe5kxCaFvtRgJolDOPu83jKBoOaoqu7jaSxOVBTlSLnBZ/hy7uQj5On/L87dku /EX7nwkjWInZzcvZzg8tMgXe6Na7zulXiTmFlZ7jEl0XFRzCNe9OG6LnpoEQRuQyvstH 8hFWhlnChX2ZNNJ9Wy7Z/eMge/YdUqiL6vkbDwWbTisAY6dlDotDIfIERU2T+o4xk46N UietGm/1zEpkqHuv0/132Xx+7d3+Ym9wZnEGff+SXAjAZgItAyoh4YCP4OOJXdl9q4H2 L4AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=OSDk9FFx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id mn12-20020a17090b188c00b0027482a0f548si2501463pjb.133.2023.09.15.19.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 19:35:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=OSDk9FFx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id AC5BF8582FCE; Fri, 15 Sep 2023 11:44:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236912AbjIOSoL (ORCPT + 30 others); Fri, 15 Sep 2023 14:44:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237078AbjIOSnh (ORCPT ); Fri, 15 Sep 2023 14:43:37 -0400 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [IPv6:2001:67c:2050:0:465::202]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA948449E; Fri, 15 Sep 2023 11:40:45 -0700 (PDT) Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4RnNJr2x9Tz9sbr; Fri, 15 Sep 2023 20:39:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803180; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2MKZNT2C20PsiAht17s5oJnb138+SmsAPSOiRhddgUA=; b=OSDk9FFxIdRoXpbbJK7NtCBBEbBqbJXSbQ07rvOBw++aALFk+mh/xxdarUdNR4FVlQRF17 67UxVmkLS2OLxkjk+Ll9RummAEi7HciYPbO9Z2cBpMGtt24csMF9mj/Hk7zipaGkJ6uh32 Ct8c4gPXLiSnOw01drlPlIaLlnRBVRgWowE8ZQbP6rTJbkllrV9wlYlk84VeHiSctXNOjP abj4O3zIc0YGlB/1ZOy/IwN/jtsEoCNZu2tkZ/e4qSfNNxLpodXBEK3pvwM6c9CuxXqvzD UdDGI/JtrIJGBBxolWDhZOsfoPzAosRAcphz0UPvnj346nrxjmRCHSmp2JtQ2w== From: Pankaj Raghav To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: p.raghav@samsung.com, david@fromorbit.com, da.gomez@samsung.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, willy@infradead.org, djwong@kernel.org, linux-mm@kvack.org, chandan.babu@oracle.com, mcgrof@kernel.org, gost.dev@samsung.com Subject: [RFC 17/23] readahead: set the minimum ra size in get_(init|next)_ra Date: Fri, 15 Sep 2023 20:38:42 +0200 Message-Id: <20230915183848.1018717-18-kernel@pankajraghav.com> In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com> References: <20230915183848.1018717-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4RnNJr2x9Tz9sbr X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Fri, 15 Sep 2023 11:44:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777159858269166414 X-GMAIL-MSGID: 1777159858269166414 From: Luis Chamberlain Make sure the minimum ra size is based on mapping_min_order in get_init_ra() and get_next_ra(). If request ra size is greater than mapping_min_order of pages, align it to mapping_min_order of pages. Signed-off-by: Luis Chamberlain --- mm/readahead.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index fb5ff180c39e..7c2660815a01 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -357,9 +357,17 @@ void force_page_cache_ra(struct readahead_control *ractl, * for small size, x 4 for medium, and x 2 for large * for 128k (32 page) max ra * 1-2 page = 16k, 3-4 page 32k, 5-8 page = 64k, > 8 page = 128k initial + * + * For higher order address space requirements we ensure no initial reads + * are ever less than the min number of pages required. + * + * We *always* cap the max io size allowed by the device. */ -static unsigned long get_init_ra_size(unsigned long size, unsigned long max) +static unsigned long get_init_ra_size(unsigned long size, + unsigned int min_order, + unsigned long max) { + unsigned int min_nrpages = 1UL << min_order; unsigned long newsize = roundup_pow_of_two(size); if (newsize <= max / 32) @@ -369,6 +377,15 @@ static unsigned long get_init_ra_size(unsigned long size, unsigned long max) else newsize = max; + if (newsize < min_nrpages) { + if (min_nrpages <= max) + newsize = min_nrpages; + else + newsize = round_up(max, min_nrpages); + } + + VM_BUG_ON(newsize & (min_nrpages - 1)); + return newsize; } @@ -377,14 +394,19 @@ static unsigned long get_init_ra_size(unsigned long size, unsigned long max) * return it as the new window size. */ static unsigned long get_next_ra_size(struct file_ra_state *ra, + unsigned int min_order, unsigned long max) { - unsigned long cur = ra->size; + unsigned int min_nrpages = 1UL << min_order; + unsigned long cur = max(ra->size, min_nrpages); + + cur = round_down(cur, min_nrpages); if (cur < max / 16) return 4 * cur; if (cur <= max / 2) return 2 * cur; + return max; }