From patchwork Mon Jan 13 15:37:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 11330473 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC7E01398 for ; Mon, 13 Jan 2020 15:38:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 88F882081E for ; Mon, 13 Jan 2020 15:38:19 +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 88F882081E 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) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F047C8E0012; Mon, 13 Jan 2020 10:37:56 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org 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-Original-To: linux-mm@kvack.org 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-Spam-Summary: 2,0,0,128bfadef79b3401,d41d8cd98f00b204,willy@infradead.org,:linux-xfs@vger.kernel.org:linux-fsdevel@vger.kernel.org::willy@infradead.org:jlayton@kernel.org:hch@infradead.org,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:2693:3138:3139:3140:3141:3142:3352:3865:3866:3868:3870:3874:4321:5007:6261:6653:7576:10004:11026:11658:11914:12291:12297:12555:12895:13069:13161:13229:13311:13357:13894:14181:14384:14394:14721:21080:21451:21627:21987:21990:30054,0,RBL:198.137.202.133:@infradead.org:.lbl8.mailshell.net-62.8.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none 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 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; 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 pagevec *pvec, static inline void pagevec_init(struct pagevec *pvec) { pvec->nr = 0; + pvec->first = 0; pvec->percpu_pvec_drained = false; } static inline void pagevec_reinit(struct pagevec *pvec) { pvec->nr = 0; + pvec->first = 0; } static inline unsigned pagevec_count(struct pagevec *pvec) @@ -88,4 +91,21 @@ static inline void pagevec_release(struct pagevec *pvec) __pagevec_release(pvec); } +static inline struct page *pagevec_last(struct pagevec *pvec) +{ + if (pvec->nr == 0) + return NULL; + return pvec->pages[pvec->nr - 1]; +} + +static inline struct page *pagevec_next(struct pagevec *pvec) +{ + if (pvec->first >= pvec->nr) + return NULL; + return pvec->pages[pvec->first++]; +} + +#define pagevec_for_each(pvec, page) \ + while ((page = pagevec_next(pvec))) + #endif /* _LINUX_PAGEVEC_H */