From patchwork Thu Nov 12 21:26:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 11901665 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 51AB3697 for ; Thu, 12 Nov 2020 21:27:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F27292224B for ; Thu, 12 Nov 2020 21:27:29 +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="qUppFtXX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F27292224B 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 531FF6B0092; Thu, 12 Nov 2020 16:27:17 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 470906B0093; Thu, 12 Nov 2020 16:27:17 -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 337BE6B0095; Thu, 12 Nov 2020 16:27:17 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0190.hostedemail.com [216.40.44.190]) by kanga.kvack.org (Postfix) with ESMTP id F2AFA6B0092 for ; Thu, 12 Nov 2020 16:27:16 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8137733CD for ; Thu, 12 Nov 2020 21:27:16 +0000 (UTC) X-FDA: 77477052072.14.cord50_2d1657727309 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 624A918229818 for ; Thu, 12 Nov 2020 21:27:16 +0000 (UTC) X-Spam-Summary: 1,0,0,8df47bd66ca45ced,d41d8cd98f00b204,willy@infradead.org,,RULES_HIT:41:69:355:379:541:800:960:968:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:2393:2553:2559:2562:2691:2693:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3871:3872:3874:5007:6261:6653:7996:10004:11026:11658:11914:12043:12114:12294:12296:12297:12438:12555:12895:13069:13161:13229:13311:13357:13894:14181:14384:14394:14721:21080:21324:21451:21627:21987:21990:30054:30064:30090,0,RBL:90.155.50.34:@infradead.org:.lbl8.mailshell.net-64.201.201.201 62.8.15.100;04y8ncjsqyghzryfqygsbqetmq771opfzs3974d5tn51qmtagjx5i5djc6ctebc.riy5iib3qquofj4pcsnrjku4axrf66g6za896bgknqtenw6zxpzxwsfdh9rdqk6.a-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:69,LUA_SUMMARY:none X-HE-Tag: cord50_2d1657727309 X-Filterd-Recvd-Size: 3428 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Thu, 12 Nov 2020 21:27:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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; bh=8GEXd5Ze60X4OYh6xIrRSvS9O7QAElyk7+6nVS10XRE=; b=qUppFtXXjLIsyxqhhhTIba7+5w Wz92hzrfGGRzwRAeLh3ftv3GoXSbkbKixG9PlAzzo8RHr+48BjLLPV2cqKTpcGHjDRHJWI9KPAxOR SEdNM7FB/9MtDEW9c+VO65VkfocuiZ0iSWIUJ/32eluFYoBwX8SFu3eQsHx0chO8aLITlbt6aWmzY x661/+vIxCVUckb2/uLhoVv9etRyhuz9g0UzgSd7V6kUcGvBsK8gkYhjVYc4JRzyPFxC2uTOWWUxl iu4NbxDXobKwDbrv50FSUPdAKCNR3RT9A3iONUCYwDmMkloUYojo+/iT09hLQfH01+oANSz2eHsZn oWIQ82UA==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdK7A-0007G7-1Z; Thu, 12 Nov 2020 21:26:44 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , akpm@linux-foundation.org, hughd@google.com, hch@lst.de, hannes@cmpxchg.org, yang.shi@linux.alibaba.com, dchinner@redhat.com, linux-kernel@vger.kernel.org, Jan Kara , William Kucharski Subject: [PATCH v4 02/16] mm/shmem: Use pagevec_lookup in shmem_unlock_mapping Date: Thu, 12 Nov 2020 21:26:27 +0000 Message-Id: <20201112212641.27837-3-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201112212641.27837-1-willy@infradead.org> References: <20201112212641.27837-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: The comment shows that the reason for using find_get_entries() is now stale; find_get_pages() will not return 0 if it hits a consecutive run of swap entries, and I don't believe it has since 2011. pagevec_lookup() is a simpler function to use than find_get_pages(), so use it instead. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jan Kara Reviewed-by: William Kucharski Reviewed-by: Christoph Hellwig --- mm/shmem.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 028f4596fc16..8076c171731c 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -842,7 +842,6 @@ unsigned long shmem_swap_usage(struct vm_area_struct *vma) void shmem_unlock_mapping(struct address_space *mapping) { struct pagevec pvec; - pgoff_t indices[PAGEVEC_SIZE]; pgoff_t index = 0; pagevec_init(&pvec); @@ -850,16 +849,8 @@ void shmem_unlock_mapping(struct address_space *mapping) * Minor point, but we might as well stop if someone else SHM_LOCKs it. */ while (!mapping_unevictable(mapping)) { - /* - * Avoid pagevec_lookup(): find_get_pages() returns 0 as if it - * has finished, if it hits a row of PAGEVEC_SIZE swap entries. - */ - pvec.nr = find_get_entries(mapping, index, - PAGEVEC_SIZE, pvec.pages, indices); - if (!pvec.nr) + if (!pagevec_lookup(&pvec, mapping, &index)) break; - index = indices[pvec.nr - 1] + 1; - pagevec_remove_exceptionals(&pvec); check_move_unevictable_pages(&pvec); pagevec_release(&pvec); cond_resched();