From nobody Thu Apr 2 23:53:32 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A3683DB652 for ; Thu, 26 Mar 2026 10:47:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774522054; cv=none; b=BVGxA6aSaALY1mGA5e6AdPKTew/KXQqY7KhV982FWSAtPyxpwnm0Lz+ObpFV9ZFsd87EH+K+I10h1kYw4DBZTx9nz7PjH8YGAFZ8VTKBYWBiziVcIskL4FzXqPtdXCOkxLst3CNOUo4u2gO4r9WbyWER80RMy2vW5HxCwQHo1Ek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774522054; c=relaxed/simple; bh=79cVFfhe8APwuHmLh1YDbiu67xjgpVYYFq2TxW3qNg8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FKeRqKm7UdUI0NJnbAr5mZ+FKH1CCGIFcqD72u90nievJObje+y0MhRDojIylgOs5AxjslJvHKz7OGes11x8ONNyE9zhskpAvu1ioi+2R6eVlzT/helnpupS1hIbMeXJ1+yZSPfbW0wXgQV25Gt+OQuezzPzkjcQOpivoE6Us1g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=I21oZA+v; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="I21oZA+v" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774522052; 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=vmw7T0PnOLgxIpELQ9rQpU7AHBZsSNPxjlfKpKQj97s=; b=I21oZA+vVTUcy/a+KAYMhYXdxaFFwx8VSKL1pAGMjPyMdGx0pc2sZahnZk5DPh4zHC+EB0 6m9GrpvA5BQ62x+WolFEvEWP2C+/HimDm0H4MEkhRdQBqj0vguxw2DNLl4XkLEUuIv8zys d3CN3j6pGFvg0ZXwajzbaiuAFI7RHsA= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-694-jGSoJECHMrekBUYeanVpuA-1; Thu, 26 Mar 2026 06:47:29 -0400 X-MC-Unique: jGSoJECHMrekBUYeanVpuA-1 X-Mimecast-MFC-AGG-ID: jGSoJECHMrekBUYeanVpuA_1774522046 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 483F218005B2; Thu, 26 Mar 2026 10:47:26 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.33.121]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8E95019560B1; Thu, 26 Mar 2026 10:47:19 +0000 (UTC) From: David Howells To: Christian Brauner , Matthew Wilcox , Christoph Hellwig Cc: David Howells , Paulo Alcantara , Jens Axboe , Leon Romanovsky , Steve French , ChenXiaoSong , Marc Dionne , Eric Van Hensbergen , Dominique Martinet , Ilya Dryomov , Trond Myklebust , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Paulo Alcantara , linux-mm@kvack.org Subject: [PATCH 09/26] mm: Make readahead store folio count in readahead_control Date: Thu, 26 Mar 2026 10:45:24 +0000 Message-ID: <20260326104544.509518-10-dhowells@redhat.com> In-Reply-To: <20260326104544.509518-1-dhowells@redhat.com> References: <20260326104544.509518-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" Make readahead store folio count in readahead_control so that the filesystem can know in advance how many folios it needs to keep track of. Signed-off-by: David Howells cc: Paulo Alcantara cc: Matthew Wilcox cc: netfs@lists.linux.dev cc: linux-mm@kvack.org cc: linux-fsdevel@vger.kernel.org Reviewed-by:: Paulo Alcantara (Red Hat) --- include/linux/pagemap.h | 1 + mm/readahead.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index ec442af3f886..3c3e34e5fe8a 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -1361,6 +1361,7 @@ struct readahead_control { struct file_ra_state *ra; /* private: use the readahead_* accessors instead */ pgoff_t _index; + unsigned int _nr_folios; unsigned int _nr_pages; unsigned int _batch_count; bool dropbehind; diff --git a/mm/readahead.c b/mm/readahead.c index 7b05082c89ea..53134c9d9fe9 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -292,6 +292,7 @@ void page_cache_ra_unbounded(struct readahead_control *= ractl, if (i =3D=3D mark) folio_set_readahead(folio); ractl->_workingset |=3D folio_test_workingset(folio); + ractl->_nr_folios++; ractl->_nr_pages +=3D min_nrpages; i +=3D min_nrpages; } @@ -459,6 +460,7 @@ static inline int ra_alloc_folio(struct readahead_contr= ol *ractl, pgoff_t index, return err; } =20 + ractl->_nr_folios++; ractl->_nr_pages +=3D 1UL << order; ractl->_workingset |=3D folio_test_workingset(folio); return 0; @@ -802,6 +804,7 @@ void readahead_expand(struct readahead_control *ractl, ractl->_workingset =3D true; psi_memstall_enter(&ractl->_pflags); } + ractl->_nr_folios++; ractl->_nr_pages +=3D min_nrpages; ractl->_index =3D folio->index; } @@ -831,6 +834,7 @@ void readahead_expand(struct readahead_control *ractl, ractl->_workingset =3D true; psi_memstall_enter(&ractl->_pflags); } + ractl->_nr_folios++; ractl->_nr_pages +=3D min_nrpages; if (ra) { ra->size +=3D min_nrpages;