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 X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6CBDC33CA9 for ; Mon, 13 Jan 2020 15:38:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 682DA2081E for ; Mon, 13 Jan 2020 15:38:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="bVGbFhVM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 682DA2081E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 036D98E0016; Mon, 13 Jan 2020 10:37:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F047C8E0012; Mon, 13 Jan 2020 10:37:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF5898E0016; Mon, 13 Jan 2020 10:37:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id 9C51C8E0015 for ; Mon, 13 Jan 2020 10:37:56 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 5DFDD181AC9CB for ; Mon, 13 Jan 2020 15:37:56 +0000 (UTC) X-FDA: 76373016552.11.bells12_7f746f9721037 X-HE-Tag: bells12_7f746f9721037 X-Filterd-Recvd-Size: 3376 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Mon, 13 Jan 2020 15:37:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; 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:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vLB2jRQV91vKQomphjORNZkEWBxCp59XHq5vnywYunQ=; b=bVGbFhVMMT+7TVZGCO2aflgl8H O8Z4R/lI3cOpP/TzqMnwKTMOOkltgN2B5Vj2gd+AZqUmlOpANyZy/enEkr8308SQEZhXHi1PzN9uv eja1wuOO7oYjbUtnO29PI4gX+9j9P9fcbBGXBp35l2/NsL/H/Ila+Er32x4iGNBNdAkFuUqDKNppq 6JtacCHZo/d3EcmdCE4sVkRfmQTjYW91ywNs+Emooh4ZnU2s4kePsHhAOoLT6+8NYtLcNHfkK6K+h tBRVJivAofvygLZwAL+cWVvYkAbLi12vsApT4qx0DB3F5uFLeY0rS3NrJEM5+B42VuKSBzrjXLHRj BYkqKLng==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1ir1mr-00075a-1j; Mon, 13 Jan 2020 15:37:53 +0000 From: Matthew Wilcox To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , jlayton@kernel.org, hch@infradead.org Subject: [PATCH 1/8] pagevec: Add an iterator Date: Mon, 13 Jan 2020 07:37:39 -0800 Message-Id: <20200113153746.26654-2-willy@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200113153746.26654-1-willy@infradead.org> References: <20200113153746.26654-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: From: "Matthew Wilcox (Oracle)" There's plenty of space in the pagevec for a loop counter, and that will come in handy later. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagevec.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 081d934eda64..9b8c43661ab3 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -19,6 +19,7 @@ struct address_space; =20 struct pagevec { unsigned char nr; + unsigned char first; bool percpu_pvec_drained; struct page *pages[PAGEVEC_SIZE]; }; @@ -55,12 +56,14 @@ static inline unsigned pagevec_lookup_tag(struct page= vec *pvec, static inline void pagevec_init(struct pagevec *pvec) { pvec->nr =3D 0; + pvec->first =3D 0; pvec->percpu_pvec_drained =3D false; } =20 static inline void pagevec_reinit(struct pagevec *pvec) { pvec->nr =3D 0; + pvec->first =3D 0; } =20 static inline unsigned pagevec_count(struct pagevec *pvec) @@ -88,4 +91,21 @@ static inline void pagevec_release(struct pagevec *pve= c) __pagevec_release(pvec); } =20 +static inline struct page *pagevec_last(struct pagevec *pvec) +{ + if (pvec->nr =3D=3D 0) + return NULL; + return pvec->pages[pvec->nr - 1]; +} + +static inline struct page *pagevec_next(struct pagevec *pvec) +{ + if (pvec->first >=3D pvec->nr) + return NULL; + return pvec->pages[pvec->first++]; +} + +#define pagevec_for_each(pvec, page) \ + while ((page =3D pagevec_next(pvec))) + #endif /* _LINUX_PAGEVEC_H */ --=20 2.24.1