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=-6.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS 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 A805FC352A4 for ; Wed, 12 Feb 2020 07:41:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 649F220658 for ; Wed, 12 Feb 2020 07:41:08 +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="EZkB30n5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 649F220658 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 ED2B86B03EC; Wed, 12 Feb 2020 02:41:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E824A6B03ED; Wed, 12 Feb 2020 02:41:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D987A6B03EE; Wed, 12 Feb 2020 02:41:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BF7366B03EC for ; Wed, 12 Feb 2020 02:41:07 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5D8EC2C89 for ; Wed, 12 Feb 2020 07:41:07 +0000 (UTC) X-FDA: 76480678974.28.magic02_26ddc9c95e22d X-HE-Tag: magic02_26ddc9c95e22d X-Filterd-Recvd-Size: 2899 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Wed, 12 Feb 2020 07:41:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=k989yYEXmj70ZRBx8wkT7sfnvH6RVcXM9p5aAdTCTKk=; b=EZkB30n59fm83Nl+IMtCHrM0GQ YJ7UyPcfBVI5xAdxDqZbXwZItHSQ4zXBreG3TgnkDXI4uYy79zVx9su8fbKCUslAHxkSuwDiuwzNL F/i+O0A6L/DtiW+qY64KlmseNyy92gJ5uZtgBuF9RmOFq6EZcZ13iMOXyXCbw8LSQC3vDbv2ej+e8 8oXwRn7YbOdIH2/bRjkXDkycLL0M4TMgRUsT89Qq0BWGV8POAf4DpUGIweT51VxvI+qyBAmZwBX/j vcq6yytio93qhA3QdZ31OFmiRFyiCsxWytZXxZEoluu8rQqEhRivQT8+MLlQsd3M0HWkRFTBKfq3G UinBg7oQ==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1mdt-00089e-N6; Wed, 12 Feb 2020 07:41:05 +0000 Date: Tue, 11 Feb 2020 23:41:05 -0800 From: Christoph Hellwig To: Matthew Wilcox Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 02/25] mm: Optimise find_subpage for !THP Message-ID: <20200212074105.GE7068@infradead.org> References: <20200212041845.25879-1-willy@infradead.org> <20200212041845.25879-3-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200212041845.25879-3-willy@infradead.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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 Tue, Feb 11, 2020 at 08:18:22PM -0800, Matthew Wilcox wrote: > From: "Matthew Wilcox (Oracle)" > > If THP is disabled, find_subpage can become a no-op. > > Signed-off-by: Matthew Wilcox (Oracle) > --- > include/linux/pagemap.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h > index 75bdfec49710..0842622cca90 100644 > --- a/include/linux/pagemap.h > +++ b/include/linux/pagemap.h > @@ -340,7 +340,7 @@ static inline struct page *find_subpage(struct page *page, pgoff_t offset) > > VM_BUG_ON_PAGE(PageTail(page), page); > > - return page + (offset & (compound_nr(page) - 1)); > + return page + (offset & (hpage_nr_pages(page) - 1)); > } So just above the quoted code is a if (PageHuge(page)) return page; So how can we get into a compound page that is not a huge page, but only if THP is enabled? (Yes, maybe I'm a little rusty on VM internals). Can you add comments describing the use case of this function and why it does all these checks? It looks like black magic to me.