Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2305519rdb; Sun, 11 Feb 2024 23:18:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW36WhIRMl/yVuqkJc7Z2yieBgWvdc9XSE9ojT+lxzDDZExmi2PmA3sFzUVjPbPJNneHDuVS8lzUz7X+dkBH6sPE+aLFyMSjXSLrXXdCw== X-Google-Smtp-Source: AGHT+IH/eeZcaVNuB/pVdr3Q3yVhtEbVx11oYazmDuJsgtSf/yoo0TMLvDgDQqGR1XrTNBp/+zNU X-Received: by 2002:a1f:6603:0:b0:4c0:7041:77a9 with SMTP id a3-20020a1f6603000000b004c0704177a9mr2026439vkc.12.1707722292677; Sun, 11 Feb 2024 23:18:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707722292; cv=pass; d=google.com; s=arc-20160816; b=DTV7MLlIeHoivwAVaFFb0jwBjmkg+qQbgAmkiNIv6hBca1o3ZpPcTuZYFBsyrK2oJ8 biNf4IWwp/yuAOBc6NR35ID74JgglKXUzShXPeLrxkRzcn52awqyrhOCXMP0Vkc9hDEt 5ExVQLfT3PELpWr69AmQKElZK3DQBN4I/XCm2VX2z3HAImBs4R05GQ4yOb18UgT7Z9Pj n/ZpDyuDOCOkESMRIKQ99qrlKWQNrXWJA+NndqILsIkFmKSqS2STDy3m4o+VEBZF+3q+ iwY/BJP/EE8i2A6jK3oRtNGTFtPA9k7TzhBXFBJ6hc6NsVD0nvGutSaAUdvv8lACmhYR YiAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=+Lom8uD40NGvlqisQyOK8nFLP+lWD9RUXEqKKIbGSn4=; fh=b2rg5SJDhLR81Qtza18BMM5zI4/pqiVEhqfAoKXkKaM=; b=Lc2KjtcaulWtfKx1xWBX96+k1DrHLuLJX7+mAhMfWhcod3dVVGTODeONOMkrvZ3idj 8vK0TtVj1kMuMyEPmlBaB0++1HHKJL/lxyFryZqMYw3FFy9woMh/TKfLpq360A8COmuT nrUBy9QVqtm1S0lm+dzzEqD3P0YpFc73hKaHkVrKNN4Ip+/ZTgLToXYn5BmLXydd8A1t AS2WfWMUOCZo9dAcgakCFxbx8YAbjnyx+MmVoXvTm3iEdDRqgP61gagB2cTTouJPdqlT BzvuQXXDw2tfiI1ErIssBURW/Q8qluogOWsI2bRhwByK+OODwm33jtoWNRDAYw/tYd/j 2hxQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=PPFKGKFd; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-61138-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61138-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWtB2VXaSRBNZihvdvUpeRnclJ/8B88nkIoARcfsKtmUIniWKqrZevfeDEPKLfnIYz86bxitxjgrNUGRyRWAt7+dfe/RwjAEYGaOwP/bg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q2-20020ad45ca2000000b0068cbdb6c2b9si7986708qvh.134.2024.02.11.23.18.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 23:18:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61138-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=PPFKGKFd; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-61138-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61138-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6DDD31C22041 for ; Mon, 12 Feb 2024 07:18:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 097A61F5E6; Mon, 12 Feb 2024 07:14:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="PPFKGKFd" Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 E51611CABF; Mon, 12 Feb 2024 07:14:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707722072; cv=none; b=TzTtmngfftpbWB7aWJ1WQjR7NGgpq4X7jqvJPafekSrVIeb2+csyiIaBmdd37QHLpGyZXImY9L3FJDp2RU1RUfLmx0ZU0zMUvueDJEiD2Z/ebFZUvRFpgrD82euhjZsVYmIJgtpkdq0iVpgxpgNgvriVogCQbsVE0bDG1bEWftM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707722072; c=relaxed/simple; bh=2FNgx33uieAGGD7HB2Qd3F2JZ17pdGt3GQ4I7EQhx2k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EdwM1aeL5eeA9Joj36faTAXUhVnAwdnf5CjOA3SlivoBWtqaVfta6SXzWZyBIrOrF8t+agOsYkKlNXET9W7SJhSurMRIowzlqJJkMsJ1pI2laJpLUETVpRwkQ4gfCxh+Kp3spmEBkF+6qv61G2NZWPf3VHca2aEtbNITY+vQrSw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=PPFKGKFd; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=+Lom8uD40NGvlqisQyOK8nFLP+lWD9RUXEqKKIbGSn4=; b=PPFKGKFdog+pRhtnYVX3WRltrB ikV+4bwKtUpdsZ8JyPWOpR/eCx2IumzP/5BsTgIlB2axxAYRuMgIlbeJvtoS9crUEwioqaAVLIEy9 qe68HPx2+QSYY3d4+4EaLCUNFTjf6H5EsJ+Pf6Aic0UDbxShZgMHL2WP23oVmHjAD1RQyq5rOpy8j f90sfKpTzUAuob0zsJ8hcHxrSwQIiE9b6alk7Q0pmRALR7/PqiH3FBss+f4aY6y6jZnvQs41cJoJv PVW8Uvg/YNsq8/zUd6e/H02sDTt5aQbaw1r/Wu4Y+ATBQVVma61LebMzf/d0G6ueSwnLc0neemdyr lgavjWNQ==; Received: from [2001:4bb8:190:6eab:75e9:7295:a6e3:c35d] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZQWL-00000004T2h-0GbS; Mon, 12 Feb 2024 07:14:29 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: Matthew Wilcox , Jan Kara , David Howells , Brian Foster , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , Dave Chinner Subject: [PATCH 11/14] writeback: Use the folio_batch queue iterator Date: Mon, 12 Feb 2024 08:13:45 +0100 Message-Id: <20240212071348.1369918-12-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212071348.1369918-1-hch@lst.de> References: <20240212071348.1369918-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html From: "Matthew Wilcox (Oracle)" Instead of keeping our own local iterator variable, use the one just added to folio_batch. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Jan Kara Acked-by: Dave Chinner --- mm/page-writeback.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index a94a77b1805969..62b663debe713b 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2406,13 +2406,21 @@ static pgoff_t wbc_end(struct writeback_control *wbc) return wbc->range_end >> PAGE_SHIFT; } -static void writeback_get_batch(struct address_space *mapping, +static struct folio *writeback_get_folio(struct address_space *mapping, struct writeback_control *wbc) { - folio_batch_release(&wbc->fbatch); - cond_resched(); - filemap_get_folios_tag(mapping, &wbc->index, wbc_end(wbc), - wbc_to_tag(wbc), &wbc->fbatch); + struct folio *folio; + + folio = folio_batch_next(&wbc->fbatch); + if (!folio) { + folio_batch_release(&wbc->fbatch); + cond_resched(); + filemap_get_folios_tag(mapping, &wbc->index, wbc_end(wbc), + wbc_to_tag(wbc), &wbc->fbatch); + folio = folio_batch_next(&wbc->fbatch); + } + + return folio; } /** @@ -2454,7 +2462,6 @@ int write_cache_pages(struct address_space *mapping, int error; struct folio *folio; pgoff_t end; /* Inclusive */ - int i = 0; if (wbc->range_cyclic) { wbc->index = mapping->writeback_index; /* prev offset */ @@ -2469,15 +2476,10 @@ int write_cache_pages(struct address_space *mapping, folio_batch_init(&wbc->fbatch); for (;;) { - if (i == wbc->fbatch.nr) { - writeback_get_batch(mapping, wbc); - i = 0; - } - if (wbc->fbatch.nr == 0) + folio = writeback_get_folio(mapping, wbc); + if (!folio) break; - folio = wbc->fbatch.folios[i++]; - folio_lock(folio); if (!folio_prepare_writeback(mapping, wbc, folio)) { folio_unlock(folio); -- 2.39.2