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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D634CC4829A for ; Tue, 13 Feb 2024 21:14:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 357226B009A; Tue, 13 Feb 2024 16:14:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 305776B009B; Tue, 13 Feb 2024 16:14:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1CD8C6B009C; Tue, 13 Feb 2024 16:14:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0C5F96B009A for ; Tue, 13 Feb 2024 16:14:08 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D22AA160D3A for ; Tue, 13 Feb 2024 21:14:07 +0000 (UTC) X-FDA: 81788033334.23.1A9A95D Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by imf06.hostedemail.com (Postfix) with ESMTP id 1F410180020 for ; Tue, 13 Feb 2024 21:14:04 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=hoqQbHuA; spf=pass (imf06.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707858845; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=d7WJh0rY7t1tbG5MUYD8H9w1/4ApsTlZUgX2ME/dH1Y=; b=Ctru5WJDAjL0KOgbzCVAJMJh7FLfBYcM4JSWlXrqn0KM3xT/TlADyJCHWfyoXUmRNfmSRC FT5gGL9mek1S66gWhDEZ09hLAGps0LJoH2cAFXUe6le3tegCTzSg9b9qSYjcweYRhBjc34 uj6nFJAhJ3C8DFY81qxSrapNtHpup1U= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707858845; a=rsa-sha256; cv=none; b=3kDDtaikjRb9J/dMOVvaZ/mzygaob53kQSAUqiFebkff+wsGNujh2ai96oL3S2NjjNxhYN De5DIGhThJ8l5S1Jy4Y+v9uwqqTY+ONo/oSQ2O1MmWkcDL8qc7hCiF3ZVsKj2HddGaBYG4 4qCd6H+K6eRoDNqD0K52F8oi1I2ChTM= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=hoqQbHuA; spf=pass (imf06.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=none Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4TZDbD1XLsz9sry; Tue, 13 Feb 2024 22:14:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1707858840; 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: in-reply-to:in-reply-to:references:references; bh=d7WJh0rY7t1tbG5MUYD8H9w1/4ApsTlZUgX2ME/dH1Y=; b=hoqQbHuAL4jYct8W27o1LnWQ0j8Bg2L77QM4d+lI4Ry+gTZPVmghVfNwrPrCgeKp0It+ln eb04OK1cPcA24Sp7MWGRn43NG5Z+mkpXR8ukVkUpvletGY/cz8lmDyuchOOClG/uxSnXmW S33hsmE1DT7ZreOeHefKvnS3TU83ZkGfO1X2KyO1ojvWsB0DztnLQ97sPrke+C2rb+6anj 4y5B+VTiWLrZbHGgs29GINx4gxZbHO2tIufvamfknes1YTq0PqDictJAAgZJaE6BS7TV9t 7juGWY9R4bfVEtAiNm/uxz93WuaYh4L0AipK9UNYSS6Q6+flML0WXqD1T41GkQ== Date: Tue, 13 Feb 2024 22:13:55 +0100 From: "Pankaj Raghav (Samsung)" To: Hannes Reinecke Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, mcgrof@kernel.org, gost.dev@samsung.com, akpm@linux-foundation.org, kbusch@kernel.org, djwong@kernel.org, chandan.babu@oracle.com, p.raghav@samsung.com, linux-kernel@vger.kernel.org, willy@infradead.org, linux-mm@kvack.org, david@fromorbit.com Subject: Re: [RFC v2 02/14] filemap: align the index to mapping_min_order in the page cache Message-ID: References: <20240213093713.1753368-1-kernel@pankajraghav.com> <20240213093713.1753368-3-kernel@pankajraghav.com> <487c0bec-4229-4add-bec4-1711f0b9bbee@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <487c0bec-4229-4add-bec4-1711f0b9bbee@suse.de> X-Rspamd-Queue-Id: 1F410180020 X-Rspam-User: X-Stat-Signature: cko7cq8hcf83ddsneojzgk46wwwixowz X-Rspamd-Server: rspam03 X-HE-Tag: 1707858844-9977 X-HE-Meta: U2FsdGVkX18VbLZ2fmsAMAgihSMYJHTUEMtUOiHuOU3W1YPQO9V1z857EzHxCipw5wTeAtp54wXH3hhfrd+HkIkZ2JG3AoDewEIts2eYcLi6OzdKip9FWLyvqyzlzBZKPjhFXUnSYt6MQ8fTHjK5n70iqx3NDBs7r7kZlRkzJ44B7NPXDtlArcKJ8vn3FwNC1Cf4VLjxQkwd8/eMPAT6dZv2steSt9I1IIj/FXRaf31qEFQQolNt+TJLPxgArIosqX45CKWdVeKOneebKZTts9Vx1oTe7nVxT+175lhivCZhDuVkr70XujPtVWb6daw8QpzfpHD97pPmdtrHv043ZS6iRdhsrDixvqnEgq7kQH9mdjih01bvRLq5+jlyCJJGFuZ8R8gQe0cljN6ZV3Yym2OW/eHZxwVvO4W68eZ6W+MZpCAXEj/LXErS/bVZiGqbrY831KZYZAjV7HSkoalzhnpsY+CVT56vczQOOjwLglSIgkPpCoQjze1z20AMEbu675is1EJaWPKOsNIBcGuM3ENxYaAKRksy40T/tCUPKF3Z3werrk1Q1XrAjSDCQu6IqodcRWYVg2cA4ArBFCXV1Dbfd6p7Uwj88MOTr6ilXnaksSOAJwgImcwHfnz7V6iHpqfrblbTYvKtW8i+hZRFjr6zxUpvQP7CJ7i5s65g544ZqO6+IAkeyT5c+JZ29l+u+E+PbSnX54/WelUGTI3MspO8xkRfXKDEENwm+uSpzOkgJsiKZ1JjEgAxZui+hdGiEcKxRppGKg8QgjEAWMPLyqVVD7768RdGq76wvObkmRiq7jlfpAzyuagWi/cawmqGn9/6iflVxTbaijwqKnwMG45EeMLVMzBQ4KVSFcf2NH497Y+xGKX2u1r7Au5f6xdZAIj505xxMHc= 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: > > diff --git a/mm/filemap.c b/mm/filemap.c > > index 750e779c23db..323a8e169581 100644 > > --- a/mm/filemap.c > > +++ b/mm/filemap.c > > @@ -2479,14 +2479,16 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count, > > { > > struct file *filp = iocb->ki_filp; > > struct address_space *mapping = filp->f_mapping; > > + unsigned int min_nrpages = mapping_min_folio_nrpages(mapping); > > struct file_ra_state *ra = &filp->f_ra; > > - pgoff_t index = iocb->ki_pos >> PAGE_SHIFT; > > + pgoff_t index = round_down(iocb->ki_pos >> PAGE_SHIFT, min_nrpages); > > pgoff_t last_index; > > struct folio *folio; > > int err = 0; > > /* "last_index" is the index of the page beyond the end of the read */ > > last_index = DIV_ROUND_UP(iocb->ki_pos + count, PAGE_SIZE); > > + last_index = round_up(last_index, min_nrpages); > > Huh? 'last_index' is unset here; sure you mean 'iocb->ki_pos + count' ? > > And what's the rationale to replace 'DIV_ROUND_UP' with 'round_up' ? Actually we are not replacing DIV_ROUND_UP, we are just adding another round_up operation to min_nrpages pages after we get the last_index by converting the bytes to page count. The main idea is to align the last_index to min_order, if it is set. AFAIK, there is no one helper that can do both lines in one shot. > > > retry: > > if (fatal_signal_pending(current)) > > return -EINTR;