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=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 2D0DEC43457 for ; Wed, 14 Oct 2020 17:17:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 63E8622227 for ; Wed, 14 Oct 2020 17:17:05 +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="kO7907DG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 63E8622227 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 696B46B005C; Wed, 14 Oct 2020 13:17:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 645C96B0062; Wed, 14 Oct 2020 13:17:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 535376B0068; Wed, 14 Oct 2020 13:17:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0212.hostedemail.com [216.40.44.212]) by kanga.kvack.org (Postfix) with ESMTP id 282C96B005C for ; Wed, 14 Oct 2020 13:17:04 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B8FB1181AC9CC for ; Wed, 14 Oct 2020 17:17:03 +0000 (UTC) X-FDA: 77371186326.16.match82_470917a2720d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 958FD1008191B for ; Wed, 14 Oct 2020 17:17:03 +0000 (UTC) X-HE-Tag: match82_470917a2720d X-Filterd-Recvd-Size: 3447 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Wed, 14 Oct 2020 17:17:03 +0000 (UTC) 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=JKdSRRpfNq89jLLxix/6a/bIeQwXlNzL7+kPc2YPR8I=; b=kO7907DGs2rDxMdhsiNKzXLEKQ oAgh7btZFkwpTBrbb2YuVotH6KkzSqhIDQit0yAlgDaGlEtDqjFQj+rHej8DMeUGzGkG9T2yfxnPL EmvG//DB4dEoLxC21g5US6G/PJRaq9UmzQyJrmFDM20z6LukP0hIOms+dJjNFnNlrDTI3YdFIKw6O iYMmkXQFfR5KrbXCm8T9m4rBdFVdBsDIWUAHtKJKdJxCsCfmlV2haVJuqrQ8mNbh9BkcpDIfiVB+c AuXkQC37FbqDR47edGh/7ncgeP6caYk6jFJsXpMqzRpV7vtvfjtzBpSfAKyGSaU2NiL9tTILB5hbn YF6vLcPQ==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSkOY-0004Id-92; Wed, 14 Oct 2020 17:16:58 +0000 Date: Wed, 14 Oct 2020 18:16:58 +0100 From: Matthew Wilcox To: "Darrick J. Wong" Cc: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 01/14] fs: Support THPs in vfs_dedupe_file_range Message-ID: <20201014171658.GN20115@casper.infradead.org> References: <20201014030357.21898-1-willy@infradead.org> <20201014030357.21898-2-willy@infradead.org> <20201014161216.GE9832@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201014161216.GE9832@magnolia> 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 Wed, Oct 14, 2020 at 09:12:16AM -0700, Darrick J. Wong wrote: > On Wed, Oct 14, 2020 at 04:03:44AM +0100, Matthew Wilcox (Oracle) wrote: > > We may get tail pages returned from vfs_dedupe_get_page(). If we do, > > we have to call page_mapping() instead of dereferencing page->mapping > > directly. We may also deadlock trying to lock the page twice if they're > > subpages of the same THP, so compare the head pages instead. > > static void vfs_lock_two_pages(struct page *page1, struct page *page2) > > { > > + page1 = thp_head(page1); > > + page2 = thp_head(page2); > > Hmm, is this usage (calling thp_head() to extract the head page from an > arbitrary page reference) a common enough idiom that it doesn't need a > comment saying why we need the head page? It's pretty common. Lots of times it gets hidden inside macros, and sometimes it gets spelled as 'compound_head' instead of thp_head. The advantage of thp_head() is that it compiles away if CONFIG_TRANSPARENT_HUGEPAGE is disabled, while compound pages always exist. > I'm asking that genuinely-- thp_head() is new to me but maybe it's super > obvious to everyone else? Or at least the mm developers? I suspect > that might be the case....? thp_head is indeed new. It was merged in August this year, partly in response to Dave Chinner getting annoyed at the mixing of metaphors -- some things were thp_*, some were hpage_* and some were compound_*. Now everything is in the thp_* namespace if it refers to THPs. > Also, I was sort of thinking about sending a patch to Linus at the end > of the merge window moving all the remap/clone/dedupe common code to a > separate file to declutter fs/read_write.c and mm/filemap.c. Does that > sound ok? I don't think that would bother me at all.