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=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 0FC40C433E1 for ; Wed, 19 Aug 2020 15:06:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E41EB208E4 for ; Wed, 19 Aug 2020 15:06:37 +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="XLM2t9DB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728780AbgHSPGg (ORCPT ); Wed, 19 Aug 2020 11:06:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728712AbgHSPGI (ORCPT ); Wed, 19 Aug 2020 11:06:08 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8631C061345 for ; Wed, 19 Aug 2020 08:06:07 -0700 (PDT) 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=8Ac+hT7fwM77lW8StYufY1iaNqm8kbkGSoi9urEaHU4=; b=XLM2t9DBfsy3J7NQMHTTOhs4ow ymCmUt3MVx3FwvRakBWs3v2ULTSiguK+Y2VmFcX+P5D02jQA0SlKgqtm2+DwqijXpoXmNHh+r7k2u oXHP2vlMLWMlJFC0yFNpWnMTbPGOTAp1w80ECNZEi7CzA8C4UCgBRYx0cCCGzgzSjK2eYXff3yS0z 14XishW8M5mp/EiDPoqshbzIKQ5diJc1LBZzPayvBkyuiV92IoCIme3Vl901AHapwHpCeM+ILSvmK f6joRZzhh8hTuO5MACG3scqkcHZoG0V8OjXGmVzJ0ucQF5FWTHG7CnkEyd3rXkgJHHZ6d9j2CZ2X/ Db4zEKNg==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8Pf4-0008Fa-7E; Wed, 19 Aug 2020 15:05:58 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Andrew Morton , Hugh Dickins , William Kucharski , Johannes Weiner , Jan Kara , linux-kernel@vger.kernel.org Subject: [PATCH 1/7] mm: Use pagevec_lookup in shmem_unlock_mapping Date: Wed, 19 Aug 2020 16:05:49 +0100 Message-Id: <20200819150555.31669-2-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200819150555.31669-1-willy@infradead.org> References: <20200819150555.31669-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) --- mm/shmem.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 271548ca20f3..a7bbc4ed9677 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -840,7 +840,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); @@ -848,16 +847,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(); -- 2.28.0