From patchwork Fri Sep 15 18:38:40 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: 13387476 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 17AD6EED61F for ; Fri, 15 Sep 2023 18:39:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13B3E6B03CA; Fri, 15 Sep 2023 14:39:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 09D1C6B03CB; Fri, 15 Sep 2023 14:39:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE2296B03CC; Fri, 15 Sep 2023 14:39:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C42FA6B03CA for ; Fri, 15 Sep 2023 14:39:38 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9258A12069D for ; Fri, 15 Sep 2023 18:39:38 +0000 (UTC) X-FDA: 81239695236.07.895AB00 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) by imf26.hostedemail.com (Postfix) with ESMTP id D01BF140010 for ; Fri, 15 Sep 2023 18:39:36 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b="fhFmL/xO"; spf=pass (imf26.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.151 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694803177; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yxVtlX4JC4EQtNnH6RIJ+6iaeftg/wvFMQDW4McP7fo=; b=5VP4FvIPFs9WJwzPMsscApKqjv/Fb0W5/9sL+PfYpRp9k5nfwqESsD3VUEWWBYBztZSstI Y7klF/S51KvwblIhHFr87i6M9WCHVoSnd8cmc8m3hXelWtc+B61g7/LkICR2gyo7Edt8qg cRjhc+N9qf3UuqyGmoa/HAmq3HfsIr4= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b="fhFmL/xO"; spf=pass (imf26.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.151 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803177; a=rsa-sha256; cv=none; b=5VLxN8UHnuAVEzPi/QiLcJ9DbI3Lwr1NIkD2XgUWA9vfgp4m0cRA09KHBhXHtckToTeSKx 4ekRmLWRlNghHgagoCz07eQcTgJQZ0bnOgO8grBrWJV7zEzO4fW8Be50H1qoh51X/noHd6 weWgLZEj6vSQG+dj34k7mvE0P4BaCzQ= Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (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-101.mailbox.org (Postfix) with ESMTPS id 4RnNJj5YhYz9spC; Fri, 15 Sep 2023 20:39:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803173; 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=yxVtlX4JC4EQtNnH6RIJ+6iaeftg/wvFMQDW4McP7fo=; b=fhFmL/xOdq9mWLRpb+jiRZQGXQH+v9Jn5su2cxMbr34SSR2VWXkAgjIRsLKaW4gQu44flC ac99JAjExWoh/6PTq9AGdXvJTewS4mWWjcU8AwxzTqTqhvOnuPZcZ5HgczOylODoRurLAS dBOKCG5FBvoZxsnu9YkS7LcQp0YemfRvv5zpGUolR7hVqtYLEuI+LrAh7OmYZQmhFgbnSd cNe8R2/Kte9KfMu0Vz5bUpVjB4o6PFg6ddvgFTssdCPEm9woE0ZYBLMWscLd5hZFJV0luH kv6+9jNXZ5NWVNUcbSomGZ/kPoUmVQTyJIYr4I4QDmrpyENc7FzrWcm3inttmA== 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 15/23] readahead: align with mapping_min_order in force_page_cache_ra() Date: Fri, 15 Sep 2023 20:38:40 +0200 Message-Id: <20230915183848.1018717-16-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: D01BF140010 X-Rspam-User: X-Stat-Signature: es9sra4r7dq46orf16twek1s4g4ofrzq X-Rspamd-Server: rspam01 X-HE-Tag: 1694803176-317029 X-HE-Meta: U2FsdGVkX18GZrgxdVM7HWV2r2xoBafr72d/h7Onz2Hb+UJ/rRq1JNyrQ69D/PnfcQvjwYDPdoYbM+Gs1rx+E64OAVCrZY8RNn8fdyKmupMDGUZoimZny2p1QWxhVBfiwLVMjGOfG1it5XQhJBr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kcPuHhKmi+nkd5X6d2KLMTBTlbX2c+VhM/SOJAV4hlpx4o4dtITVnOtp15Wzvru332Zh4ay1EB6dDKw6YK9KoW8KYOX3d4781LBrw4/xsZSZhuAv6TfuRUZAY4EA8TCbV7UejDvQRBUWeKfLqc2HZ 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: From: Pankaj Raghav Align the index to mapping_min_order in force_page_cache_ra(). This will ensure that the folios allocated for readahead that are added to the page cache are aligned to mapping_min_order. Signed-off-by: Pankaj Raghav --- mm/readahead.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/readahead.c b/mm/readahead.c index 2a9e9020b7cf..838dd9ca8dad 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -318,6 +318,8 @@ void force_page_cache_ra(struct readahead_control *ractl, struct file_ra_state *ra = ractl->ra; struct backing_dev_info *bdi = inode_to_bdi(mapping->host); unsigned long max_pages, index; + unsigned int folio_order = mapping_min_folio_order(mapping); + unsigned int nr_of_pages = (1 << folio_order); if (unlikely(!mapping->a_ops->read_folio && !mapping->a_ops->readahead)) return; @@ -327,6 +329,13 @@ void force_page_cache_ra(struct readahead_control *ractl, * be up to the optimal hardware IO size */ index = readahead_index(ractl); + if (folio_order && (index & (nr_of_pages - 1))) { + unsigned long old_index = index; + + index = round_down(index, nr_of_pages); + nr_to_read += (old_index - index); + } + max_pages = max_t(unsigned long, bdi->io_pages, ra->ra_pages); nr_to_read = min_t(unsigned long, nr_to_read, max_pages); while (nr_to_read) { @@ -335,6 +344,7 @@ void force_page_cache_ra(struct readahead_control *ractl, if (this_chunk > nr_to_read) this_chunk = nr_to_read; ractl->_index = index; + VM_BUG_ON(index & (nr_of_pages - 1)); do_page_cache_ra(ractl, this_chunk, 0); index += this_chunk;