Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1145763pxu; Fri, 27 Nov 2020 00:22:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxsm/69+8vM1xnqlT2MVYvsPxNtkg0x/B216SIAc9hrOix9ta8KRvjgUUzNKGwJ7cPDrThf X-Received: by 2002:a17:906:489a:: with SMTP id v26mr6656947ejq.422.1606465326176; Fri, 27 Nov 2020 00:22:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606465326; cv=none; d=google.com; s=arc-20160816; b=MS+sUhcCQ95FmXU6QpS/XoeLiv7FPgTZ/75zG6l6sTprVwscGxtw1R86wnPMXYgHIg 4B2Rs4+7xj1CeYAbfxY9ANn3cDQ+GFvXcyOK4QktBex0BB1C8A0r6yqFZsfRgMqcPxXy VBjocVIlrMBrqOYBwFyOepV5OTprTFRz64GWfDM+sf5PPtB3cVuCISsWiu+DOVdo0ZLh PsjR1vlVuA2aH56ma7wSMKjYumF63nzzQFKHN3/zIu+ltdwOtnzZ1r186h/AC6O5+LdO Ym9YYAeTtE1NjGabci4mg30PPcytBTsQay4mxRlEisujF+XNG2Q6vHtNY522loVYV2Se 3y2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bwE3ntsWwlmjPInYkgT+nMI6emH/bLopsilbB9Xfo0k=; b=Co/mqR43vj77aqAXMweiDaB2X21ygxj8UHlsHsvlaMtM0hUuxTmS2Y1ChWoCDM4Kb8 d1IVnlphtjuSLVC7Os8b1ZPthrMKjy1gqAbssTy8nk2hR2Hw7154fGqFbqBYnIg3VwVR aUJAYz1etX/87L+8U341vg6meXYQElbBKq4l/8H/cRR3TX9Ci+ShoKY2vTY9PCLFj4NX Q24fNfZMsqSqbcTsAAlgftVdz8+BUvjD4sTQrhIPhs/FKv+M8wCzC7XHtbDqyWW9CKrR l4kaZfZyCcKwYln9WvjGwZ9ygE8ocBaabhsr7v9iyqhfGsiqRn3BDa8496nSCC6o7vd1 VuAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EW1Gywcf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z7si4774897ejw.347.2020.11.27.00.21.43; Fri, 27 Nov 2020 00:22:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EW1Gywcf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387502AbgKZMPw (ORCPT + 99 others); Thu, 26 Nov 2020 07:15:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728965AbgKZMPv (ORCPT ); Thu, 26 Nov 2020 07:15:51 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCCEDC0613D4; Thu, 26 Nov 2020 04:15:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=bwE3ntsWwlmjPInYkgT+nMI6emH/bLopsilbB9Xfo0k=; b=EW1GywcfwLEnGDTSbbRk3iX/fu vMLSY16+iniAcBp5/Q9wBUI/garKVHl2j6/XASpTq8Hry7PGTTJjIdm2tuekGe5cG9WBo2nzg8hr2 g2VpVUEwUR6NauZ8klKaQOD6Ha1+rjJtL4oN9NNQJeI/Wb2m4CJrabTAkEEKRfjuAk2SJNRYCbVcO 45UFPkNWFKhMt81CD4/KFoh3beaDayv+ifK+lhedpUjINOr04s3nl5J/7q1vHul/OvBQAY6kA3jik mEbbpmdNkhoZG6NY84MEDGiWFnvgtLjfFEgE4k8hS8kG/BOxB77tNrYYxMWfmDKNfsC55iCKshKYB V+YH1OhA==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiGBe-0000jE-QC; Thu, 26 Nov 2020 12:15:46 +0000 Date: Thu, 26 Nov 2020 12:15:46 +0000 From: Matthew Wilcox To: Hugh Dickins Cc: Andrew Morton , Jan Kara , William Kucharski , Linux-FSDevel , linux-mm , Christoph Hellwig , Johannes Weiner , Yang Shi , dchinner@redhat.com, linux-kernel Subject: Re: [PATCH v4 00/16] Overhaul multi-page lookups for THP Message-ID: <20201126121546.GN4327@casper.infradead.org> References: <20201112212641.27837-1-willy@infradead.org> <20201117153947.GL29991@casper.infradead.org> <20201117191513.GV29991@casper.infradead.org> <20201117234302.GC29991@casper.infradead.org> <20201125023234.GH4327@casper.infradead.org> <20201125150859.25adad8ff64db312681184bd@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 25, 2020 at 04:11:57PM -0800, Hugh Dickins wrote: > The little fix definitely needed was shown by generic/083: each > fsstress waiting for page lock, happens even without forcing huge > pages. See below... Huh ... I need to look into why my xfstests run is skipping generic/083: 0006 generic/083 3s ... run fstests generic/083 at 2020-11-26 12:11:52 0006 [not run] this test requires a valid $SCRATCH_MNT and unique 0006 Ran: generic/083 0006 Not run: generic/083 > > if (!unfalloc || !PageUptodate(page)) { > > if (page_mapping(page) != mapping) { > > /* Page was replaced by swap: retry */ > > unlock_page(page); > > - index--; > > + put_page(page); > > break; > > } > > VM_BUG_ON_PAGE(PageWriteback(page), page); > > - if (shmem_punch_compound(page, start, end)) > > - truncate_inode_page(mapping, page); > > - else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) { > > - /* Wipe the page and don't get stuck */ > > - clear_highpage(page); > > - flush_dcache_page(page); > > - set_page_dirty(page); > > - if (index < > > - round_up(start, HPAGE_PMD_NR)) > > - start = index + 1; > > - } > > + index = truncate_inode_partial_page(mapping, > > + page, lstart, lend); > > + if (index > end) > > + end = indices[i] - 1; > > } > > - unlock_page(page); > > The fix needed is here: instead of deleting that unlock_page(page) > line, it needs to be } else { unlock_page(page); } It also needs a put_page(page); That's now taken care of by truncate_inode_partial_page(), so if we're not calling that, we need to put the page as well. ie this: +++ b/mm/shmem.c @@ -954,6 +954,9 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, page, lstart, lend); if (index > end) end = indices[i] - 1; + } else { + unlock_page(page); + put_page(page); } } index = indices[i - 1] + 1; > > } > > + index = indices[i - 1] + 1; > > pagevec_remove_exceptionals(&pvec); > > - pagevec_release(&pvec); > > - index++; > > + pagevec_reinit(&pvec);