Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4026026pxv; Mon, 5 Jul 2021 11:37:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9h4Jq9xdCAiC7TiP+orZ0+teTEFf7CX7o/J7JCXbj25U71Fgd1L2sEoj7kDTTz3flIUEt X-Received: by 2002:a17:906:6acd:: with SMTP id q13mr8496778ejs.377.1625510266078; Mon, 05 Jul 2021 11:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625510266; cv=none; d=google.com; s=arc-20160816; b=awaGDVdWM4uRW7bXmClYjNZvpfCAnJT8TfutQJsGjw4ORbFTjrrpj11TAS0iQYIkXR /YBAd5+T/1XsS1UNwv5rSl0snrLyjjnWMjQyifUCEVsuSi0H8CeGf8aZ903vJh9Ph+ca bl9rqSWuiQyiWXTv6p10wa5SU7QJkXcWjC3ud6o1wVpNgKXn6a04GWuvQmfRIHgMzH1S jWKlmPCcP+y3NnDghgKFnqyGA58imQLXu5D+cbpWRSfck69G5JXGRsbz8TTlr21cfv4f lQcWC7vP/I8f8lhui/5Ib+Wl4MxrYSg4RarxFX9qTGgJqhsvxqQCJ16HivUlCtWRPd1D aT1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8sKWus+t87oruwBTmnP5dxwqE5lJHiDO+AS9eevSXiY=; b=QsRguvQUqgDbGCwlJQjLgBQA18HuYn5ltrIDNj7mZbRpIJ6j6BIiydNmrE5zFkhr1y VNF4jCOjQK+BbfrmzfnbzRZ1AMj3CdBBYKWhh9OZB958Ithj6J2xeeT+Ss0NUiSA8H7m mmrJTAbBGZmY6ED/xXsKjsJSqcdOXj1FLuLoGjlnvEhLU6937QOmfNSnMeVHXQJv1H2N DJNw5Z7Lku5hVPKruZ29HCuQC5z1T12LwSEgh3RULnKNcGifiXawJccMF1WA5ePNqdkJ XnWpWcI1pDZCEEcuLnKjlIOiaBdHJhhpAAIpZKOT+/IjNa6sEXpC80ga3PSW2E98JQWU FdXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cAvpDyZI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si11925633ede.189.2021.07.05.11.37.22; Mon, 05 Jul 2021 11:37:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cAvpDyZI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229770AbhGESga (ORCPT + 99 others); Mon, 5 Jul 2021 14:36:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:54024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbhGESga (ORCPT ); Mon, 5 Jul 2021 14:36:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5832261979; Mon, 5 Jul 2021 18:33:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625510032; bh=Nhk8oaNc/YSXElMkHHcyeooUYW+6uxxuUVYgdqIBHoU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cAvpDyZIG/mlWAa6w0lNWAp2QNd0gK45QNdNYann2xj1zik3T3HQU6l+6Zto76K1o J7qa+J077Aq69wMID1WI46LcNK++TU4PHwED8VNmyORtTCt1tpUo6IQ2aT0iDf6nn7 m5CYsjxKgoH3F13VF/vBgy1Vc/tP3FCgXlQE5o+9rJbI7r+R+e25ntyxGhW0632oy1 iFHrj2GLvnmGA4GH8oamJNeD5eb+w8zTT8FHUQY3e5Lcifi1IvJJSUAI6x6MJoGQW1 WU5WrhkWHY1zSEGfAUtecia1pW0DWzcdTDhCrPYPbdLdKKOEzxigaSS8zlB9uljxku 7CWdoEbbiAV3Q== From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: Matthew Wilcox , LKML , Gao Xiang Subject: [RFC PATCH 2/2] erofs: directly traverse pages in z_erofs_readahead() Date: Tue, 6 Jul 2021 02:32:53 +0800 Message-Id: <20210705183253.14833-2-xiang@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210705183253.14833-1-xiang@kernel.org> References: <20210705183253.14833-1-xiang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In that way, pages can be accessed directly with xarray. Cc: Matthew Wilcox Signed-off-by: Gao Xiang --- Just an open-coded PoC one, since that is what EROFS actually needs but without the iteration API (see [PATCH 1/2] as well.) fs/erofs/zdata.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index 054b9839e9db..210b2965ecc4 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -1416,7 +1416,8 @@ static void z_erofs_readahead(struct readahead_control *rac) bool sync = (sbi->ctx.readahead_sync_decompress && nr_pages <= sbi->ctx.max_sync_decompress_pages); struct z_erofs_decompress_frontend f = DECOMPRESS_FRONTEND_INIT(inode); - struct page *page, *head = NULL; + struct page *page; + pgoff_t index; LIST_HEAD(pagepool); trace_erofs_readpages(inode, readahead_index(rac), nr_pages, false); @@ -1434,26 +1435,19 @@ static void z_erofs_readahead(struct readahead_control *rac) * 2) submission chain can be then in the forward order since * pclusters are all inserted at head. */ - while ((page = readahead_page(rac))) { - prefetchw(&page->flags); - - /* - * A pure asynchronous readahead is indicated if - * a PG_readahead marked page is hitted at first. - * Let's also do asynchronous decompression for this case. - */ - sync &= !(PageReadahead(page) && !head); - - set_page_private(page, (unsigned long)head); - head = page; - } - - while (head) { - struct page *page = head; + index = rac->_index + rac->_nr_pages; + while (rac->_nr_pages) { + struct page *head; int err; - /* traversal in reverse order */ - head = (void *)page_private(page); + --rac->_nr_pages; + page = xa_load(&rac->mapping->i_pages, --index); + /* XXX: very incomplete thp support */ + head = thp_head(page); + if (head != page) { + index -= page->index - head->index; + page = head; + } err = z_erofs_do_read_page(&f, page, &pagepool); if (err) -- 2.20.1