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=-11.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 13A7EC4346E for ; Tue, 29 Sep 2020 08:59:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 50853206DC for ; Tue, 29 Sep 2020 08:58:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 50853206DC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C3E3D6B005D; Tue, 29 Sep 2020 04:58:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BED756B0062; Tue, 29 Sep 2020 04:58:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8FAA8E0001; Tue, 29 Sep 2020 04:58:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0244.hostedemail.com [216.40.44.244]) by kanga.kvack.org (Postfix) with ESMTP id 90F7E6B005D for ; Tue, 29 Sep 2020 04:58:57 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 4FF4B813F for ; Tue, 29 Sep 2020 08:58:57 +0000 (UTC) X-FDA: 77315499114.25.cover12_3412cea27188 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 3315418093AAA for ; Tue, 29 Sep 2020 08:58:57 +0000 (UTC) X-HE-Tag: cover12_3412cea27188 X-Filterd-Recvd-Size: 3425 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Tue, 29 Sep 2020 08:58:56 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 713EDACA3; Tue, 29 Sep 2020 08:58:55 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 252501E12E9; Tue, 29 Sep 2020 10:58:55 +0200 (CEST) Date: Tue, 29 Sep 2020 10:58:55 +0200 From: Jan Kara To: "Matthew Wilcox (Oracle)" Cc: linux-mm@kvack.org, Andrew Morton , Hugh Dickins , William Kucharski , Johannes Weiner , Jan Kara , Yang Shi , Dave Chinner , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 05/12] mm: Add and use find_lock_entries Message-ID: <20200929085855.GD10896@quack2.suse.cz> References: <20200914130042.11442-1-willy@infradead.org> <20200914130042.11442-6-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200914130042.11442-6-willy@infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) 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: On Mon 14-09-20 14:00:35, Matthew Wilcox (Oracle) wrote: > We have three functions (shmem_undo_range(), truncate_inode_pages_range() > and invalidate_mapping_pages()) which want exactly this function, so > add it to filemap.c. > > Signed-off-by: Matthew Wilcox (Oracle) > diff --git a/mm/shmem.c b/mm/shmem.c ... > index b65263d9bb67..a73ce8ce28e3 100644 > --- a/mm/shmem.c > +++ b/mm/shmem.c > @@ -905,12 +905,8 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, > > pagevec_init(&pvec); > index = start; > - while (index < end) { > - pvec.nr = find_get_entries(mapping, index, > - min(end - index, (pgoff_t)PAGEVEC_SIZE), > - pvec.pages, indices); > - if (!pvec.nr) > - break; > + while (index < end && find_lock_entries(mapping, index, end - 1, > + &pvec, indices)) { > for (i = 0; i < pagevec_count(&pvec); i++) { > struct page *page = pvec.pages[i]; > > @@ -925,18 +921,10 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, > index, page); > continue; > } > + index += thp_nr_pages(page) - 1; > > - VM_BUG_ON_PAGE(page_to_pgoff(page) != index, page); > - > - if (!trylock_page(page)) > - continue; > - > - if ((!unfalloc || !PageUptodate(page)) && > - page_mapping(page) == mapping) { > - VM_BUG_ON_PAGE(PageWriteback(page), page); > - if (shmem_punch_compound(page, start, end)) > - truncate_inode_page(mapping, page); > - } > + if (!unfalloc || !PageUptodate(page)) > + truncate_inode_page(mapping, page); Is dropping shmem_punch_compound() really safe? AFAICS it can also call split_huge_page() which will try to split THP to be able to truncate it. That being said there's another loop in shmem_undo_range() which will try again so what you did might make a difference with performance but not much else. But still it would be good to at least comment about this in the changelog... Honza -- Jan Kara SUSE Labs, CR