From nobody Fri Jun 12 20:18:24 2026 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B943E2EB5A6 for ; Tue, 12 May 2026 20:32:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778617950; cv=none; b=IDk8rzpa8jFxdf/lLBgzJ4AVmtIYNE2/MQqJHUDGPwdzxB3WTC6Gw0ipO0GRYWw0pSy7VaINXLe9FAAFoXzgWtegJiSgE/VxUiU9WtoRqLysJCph7jTWb3NwMZadwfhwxLrkTeN/QmR3rf0YUyW3UjHNjXTG2zLbs04uDpyIoVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778617950; c=relaxed/simple; bh=UYreWyiRU/oVctAqMN7crrT6Vxk3LLDPMzN27TYlxBk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: Cc:Content-Type; b=q27Wx2mbTW4j2GA2mmjdFl7FzpuBQBeQHfkGGEFGK/QZudfmQAYhCP9bnbdT9GFacD2xrKZiTtrKi55oJSMY42/d69JY8yLyYEGkheimQBg9vcwTiYDAAmui9VIID8MWEMJyouxJZq5w/OtinvYv5dEQrN3L9Phl6ikeQtTPiK8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--fmayle.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=hwN8cGIb; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--fmayle.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hwN8cGIb" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-82fa7c6699fso7607765b3a.1 for ; Tue, 12 May 2026 13:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778617948; x=1779222748; darn=vger.kernel.org; h=cc:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=GvqclSxC3Le+gG/fDpqgZ0WbLWL5hpox9DRtNNA0cQ0=; b=hwN8cGIb4ax6nR99Vx2OzzPe+3UBAojp3J0G/cLLdhqpvbLSZ0fmGv79oQ/JdO+DAD nQh/oZaTDw6QV4HA0yxUPUVzUUHXhHLpuAU2ad2u2uRxvQ0vnAV3VD+yR0Rh4HwHL5rC /FbBBiXPuVbD9eTY8GFpLoP2H6mYnTixKeVerV+zrMZVTN6zOPSV+BLuXkvvGfKtEofV vKfhBxBSeZoZ2oS8Zs/GDJx2ux5AVyeo36qnqCj2RIzdBzUR8avnUxjrQWA4oudcnghX k/ZDgZCojblfGFacKHV8eiFktcHQPwNm0a0GS92yOuryS90tlObV8amueDwKKkuQVTbS 0z9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778617948; x=1779222748; h=cc:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GvqclSxC3Le+gG/fDpqgZ0WbLWL5hpox9DRtNNA0cQ0=; b=IjqRywCfegtqSMMnraaZNuWfjpcz5/DI0BtQRWrd6iG8TINvhlnGfIfVuuhqUCcNvv kNIYbJrAcYOJ/y9+CX8Ad9jhkAxLv7OgyBW+vo+B/nc2mbFwOoTsSZCIqIRkwl/eYZPf 4EPieuJNVaTSMgkDrf8f4wMPgxNpZWFhyYi9evljdqa8fTeYWWfJVbKlHdIIxQHNYQe/ grRqIYL6E0ai3EWnmmE+Cp5C5eLCYt5Aq7EHR80xVbyT0+6b/RnCMMkE8fs/NO2mK64V qP58LM+xECYo7WYOwKo5Gd1IUcyinNoPpcaAO+qdtrYv2Mu9TB5J+UU1blsK5G9TRn4y wUvA== X-Forwarded-Encrypted: i=1; AFNElJ9oP/hYsUpe+W+QTl8Sp43XUX5M7ENquNUpZVK9QiARSL7Nq4KZiEG/yFuHaM9axZH76/deyZBbOAmFHIo=@vger.kernel.org X-Gm-Message-State: AOJu0YwSRBpMuNZtSZTE/oBTrH51T+mZUWX6V31qNOCn6TNefId6ZQQx GVXe880lrmp8UiRYNcilmXkMMIa5yDi/tLhW3c8MCftPv0EhO/1+yf7X1v/db2wDoKTNbgaRmnp ZAEE4IQ== X-Received: from pfhh2.prod.google.com ([2002:a05:6a00:2302:b0:82f:7163:35c4]) (user=fmayle job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:21d1:b0:827:447f:7dbd with SMTP id d2e1a72fcca58-83f042dd3admr190592b3a.46.1778617947724; Tue, 12 May 2026 13:32:27 -0700 (PDT) Date: Tue, 12 May 2026 13:31:35 -0700 In-Reply-To: <20260512203154.754075-1-fmayle@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260512203154.754075-1-fmayle@google.com> X-Mailer: git-send-email 2.54.0.563.g4f69b47b94-goog Message-ID: <20260512203154.754075-2-fmayle@google.com> Subject: [PATCH 1/2] mm/readahead: add kerneldoc for read_pages From: Frederick Mayle Cc: android-mm@google.com, kernel-team@android.com, Frederick Mayle , "Matthew Wilcox (Oracle)" , Jan Kara , Andrew Morton , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Formalize one of the invariants provided by the current implementation so that callers can depend on it, as discussed in [1]. Link: https://lore.kernel.org/all/20260501061146.6e61392d125cf1847d7cc181@l= inux-foundation.org/ [1] Signed-off-by: Frederick Mayle --- mm/readahead.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/readahead.c b/mm/readahead.c index 8c12b63ccd4a..23bec5497308 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -146,6 +146,17 @@ file_ra_state_init(struct file_ra_state *ra, struct ad= dress_space *mapping) } EXPORT_SYMBOL_GPL(file_ra_state_init); =20 +/** + * read_pages() - Start IO for a contiguous range of allocated folios in t= he + * page cache. + * @rac: Readahead control. + * + * When read_pages() returns, it is guaranteed that all of the folios will= have + * been processed or removed so that ``readahead_count(rac) =3D=3D 0``. Ho= wever, + * that does not imply that ``readahead_index(rac)`` will be updated to po= int + * to the end of the originally requested range because, for example, the + * filesystem may expand the range upwards. + */ static void read_pages(struct readahead_control *rac) { const struct address_space_operations *aops =3D rac->mapping->a_ops; --=20 2.54.0.563.g4f69b47b94-goog From nobody Fri Jun 12 20:18:24 2026 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E02193C5DA1 for ; Tue, 12 May 2026 20:32:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778617955; cv=none; b=On4BydEDHon0eo1by94zYuBVfdb8doHr241NWUjSsIIZ33D2GX1FGTMoGaXw1KG/x3MILoTG694XbmPPiWKd6MUlpsups3kXrNNPWSNuHiBEYkrNU4Y7yX98C/dM7U5QDJSZdfkoTh/oY4Uy1ylMwyPQgS3SmyoZF6QMbmS0T74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778617955; c=relaxed/simple; bh=+8jlEft9WNgvjqTEBfN6erytdcvw5sxxN4Zw4GFtOJo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: Cc:Content-Type; b=dn9fJO47NbH/oLa3Dw7koeby1uZah3kL+souau5mvGQNo5uKtZUgOVOVI6q0FEYPcyAs2LaM7LiIfjNKTt+atKFfvYdkeOQ5tpCX0LKryEs1bglYFxMFcVlmbx1sJgv8I03+BGnOoR+bepN5LQY4GTggjN0gIlyathCkLoMEXvc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--fmayle.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ilBtKnwb; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--fmayle.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ilBtKnwb" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-82f74bcfb86so6136481b3a.0 for ; Tue, 12 May 2026 13:32:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778617953; x=1779222753; darn=vger.kernel.org; h=cc:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=Q6bLlWzsZHxTKwI8h2tfKnH8AsKS+KM39iZ5XG/RwLQ=; b=ilBtKnwbb70SE2XSDWEkVSFrLqlAbZb3i++/7g9LaboTX5vj11ODtjuTSMbtVfZ2yI c4t/vrPLLfdaOj79qGZTCTgU6J44NuaKC+ScUjYRA9SLH2Bx1Q2838p5tAfCUxgRHiYr dtgOPWhT8AMUIhuFNq4BiWUu1YG//0MXHoD7a6EAh34r+uSXuBElB4L42LggBEdcWitL 8VU9hp3NS/EdYFqNHHjOOwny7xTqb/dByoBJS3umTPq5JzF4jsEwf8/FdRZ68583V3b9 JfZ3kKCgEZF5C5SDwhI2dVWqh3cWnbBZF8779Emt6mEFXST6aXvMPrzO78clrcWFVz4H EkMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778617953; x=1779222753; h=cc:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Q6bLlWzsZHxTKwI8h2tfKnH8AsKS+KM39iZ5XG/RwLQ=; b=qDZpfOEwMy6JFmkBzOI7DKWsAwol+HMY8u7G8OpomUe4wipjUnLLVDby6rtEt6XFmd 6Lb9gjxrCsWZHFn6INcpWwssHqaGEmvnz7GfE+VTLHkhfZ9qLXO81qvUnKqk/DtQgsRl ewnVuCprmCzNvE+5PwJpEpv8/4Y7XsY1xgZleB/FPEEdposkDakeMVxTqtIUTh1Fvf3P UkwN+JpTesh68lGO33FKtXZt7htGfFGR199ag5zx3lq/yJK9pfI/4J1c4KnoysZ+S272 /eFUIY0Gb9XtXXYlN8wNwEBwoAvp5CUycT4CqlwVw3WDqUJ2ZDjfxqHgXJkSTfZNhJLz meXg== X-Forwarded-Encrypted: i=1; AFNElJ/c9TtohNo7LrbBR5QYC2nz2040dSa2KIHDxNzlKjW0DWpmUvdukZSnArOEQY4+j+aFxBEBByjIavUSw9c=@vger.kernel.org X-Gm-Message-State: AOJu0Yxi6c+UIInVdczvhcCFi6cdBGzMmxU1j7O31Jy3UvHfeUnfw55s ztGCUPXbwpUV38pIpYS0RHS7QcftLKdzMUfn+k2iVZP0/n7ETl3KkKmywMUCiCz2UEhXiagShNw Ibq6XPw== X-Received: from pfbg7.prod.google.com ([2002:a05:6a00:ae07:b0:837:c09c:9cce]) (user=fmayle job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:328c:b0:82f:2a78:6302 with SMTP id d2e1a72fcca58-83f042789d4mr222577b3a.26.1778617952888; Tue, 12 May 2026 13:32:32 -0700 (PDT) Date: Tue, 12 May 2026 13:31:36 -0700 In-Reply-To: <20260512203154.754075-1-fmayle@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260512203154.754075-1-fmayle@google.com> X-Mailer: git-send-email 2.54.0.563.g4f69b47b94-goog Message-ID: <20260512203154.754075-3-fmayle@google.com> Subject: [PATCH 2/2] mm/readahead: simplify page_cache_ra_unbounded loop counter reset From: Frederick Mayle Cc: android-mm@google.com, kernel-team@android.com, Frederick Mayle , "Matthew Wilcox (Oracle)" , Jan Kara , Andrew Morton , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Minor cleanup, no behavior change intended. `read_pages` ensures that `ractl->_nr_pages` is zero before it returns, so the `ractl->_nr_pages` term in these expressions contributes nothing. This seems to have been true since the statements were introduced in commit f615bd5c4725f ("mm/readahead: Handle ractl nr_pages being modified"). The new expression has an intuitive explanation. When filesystems perform readahead, they increment `ractl->_index` by the number of pages processed, so, after `read_pages` returns, `ractl->_index` points to the first page after those already processed. `index` points to the first page considered in the loop. So, `ractl->_index - index` is the number of pages processed by the loop so far. Signed-off-by: Frederick Mayle --- mm/readahead.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 23bec5497308..42f2f20633b0 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -281,7 +281,7 @@ void page_cache_ra_unbounded(struct readahead_control *= ractl, */ read_pages(ractl); ractl->_index +=3D min_nrpages; - i =3D ractl->_index + ractl->_nr_pages - index; + i =3D ractl->_index - index; continue; } =20 @@ -297,7 +297,7 @@ void page_cache_ra_unbounded(struct readahead_control *= ractl, break; read_pages(ractl); ractl->_index +=3D min_nrpages; - i =3D ractl->_index + ractl->_nr_pages - index; + i =3D ractl->_index - index; continue; } if (i =3D=3D mark) --=20 2.54.0.563.g4f69b47b94-goog