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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 B0C6EC433FE for ; Wed, 9 Dec 2020 19:08:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 413C223A33 for ; Wed, 9 Dec 2020 19:08:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 413C223A33 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A6F798D004B; Wed, 9 Dec 2020 14:08:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A45318D0031; Wed, 9 Dec 2020 14:08:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 934448D004B; Wed, 9 Dec 2020 14:08:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0246.hostedemail.com [216.40.44.246]) by kanga.kvack.org (Postfix) with ESMTP id 7DB228D0031 for ; Wed, 9 Dec 2020 14:08:24 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2E7C43626 for ; Wed, 9 Dec 2020 19:08:24 +0000 (UTC) X-FDA: 77574679728.03.pigs39_4504def273f2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 9D3A828A240 for ; Wed, 9 Dec 2020 19:08:23 +0000 (UTC) X-HE-Tag: pigs39_4504def273f2 X-Filterd-Recvd-Size: 5527 Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Wed, 9 Dec 2020 19:08:23 +0000 (UTC) Received: by mail-qt1-f195.google.com with SMTP id z3so1758098qtw.9 for ; Wed, 09 Dec 2020 11:08:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=QDIyTPEnXV/+rzTsOg2vRiVn9Fodiyaui+GdMDJKHIw=; b=Jh+Qv9KUQHTGqlPoGI1oiQ7m3bqoxnFZS8IbnYRO5flP4UMpQBFTgzBvfOVd+eMatx bvm2vv8eNM8+Q2yAKYlHe3qalf2nDv5jaaROhUAU+CW1bMG65dyBeEtE8MUuy1mNdcIT oMgOd5S+H5YjBtGuXAKpe9e8uJo2ZQIi7u3CgxmF4ntjgjl9+9UpXTHSJUjtuSpr9LFQ OxnVVxzEaXP6LalQovBcvfVLaMf7GT0m6sfOz/LhOlkWQvKkhzykAjc65qRMg3+AS1fc 1xcnVG/b9qodYNSP7Xqm25yKn/o1HIPEuC0iIjFAWwRljLdBlyupitnHZZgdk89MCfew tsbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=QDIyTPEnXV/+rzTsOg2vRiVn9Fodiyaui+GdMDJKHIw=; b=dk84wZ8vfjcaUZwW33ppDqdP6ZUCwLFjApfXRDfawcZbKVGQUUGL1SGW8FSJkvSPWg 048ovBTehOUW8Y06giSO74Tk+AgrJA7fRcTDx1UpR3ezuI0pxfP/gs7oy34JYk0/gL/M YB69+n4+pyIlz5nQaZAEbMjoJCdekrJ7wD2qPopFgk0fzjhs2IkLkN/tQgIGqEnPAYlg bpP6ZrXC9yA6rT55tc50aeXA6aApiCXEkjC5BlXw/xcxbFrmAIclKiwOHD7BU9P/ueUL sc+f4aFlqTN0rw0gKPmK3XFgxZEEZhO2Ly9Kx94HNpuo5scEzZ1Kwl1/LFKxCjvvCIjc KrfA== X-Gm-Message-State: AOAM530gl3Qpgkq5zFVpqN4e4KEbBipG7JgOvzxQU4jBz2bOMHbqRB8B mjj6nc9aGt6fraN9DKhlOo7/3w== X-Google-Smtp-Source: ABdhPJzVQ1YAJCpHgCIsYZFapCPln9vpo/dpeP22CYEXZmR3J+34Yfw2hcg0nvMHiNxEil8WAqZfBw== X-Received: by 2002:a05:622a:109:: with SMTP id u9mr4585213qtw.213.1607540902358; Wed, 09 Dec 2020 11:08:22 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-115-133.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.115.133]) by smtp.gmail.com with ESMTPSA id t30sm1762467qkj.29.2020.12.09.11.08.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 11:08:21 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kn4p2-008LKD-83; Wed, 09 Dec 2020 15:08:20 -0400 Date: Wed, 9 Dec 2020 15:08:20 -0400 From: Jason Gunthorpe To: Matthew Wilcox Cc: Joao Martins , linux-mm@kvack.org, Dan Williams , Ira Weiny , linux-nvdimm@lists.01.org, Jane Chu , Muchun Song , Mike Kravetz , Andrew Morton Subject: Re: [PATCH RFC 6/9] mm/gup: Grab head page refcount once for group of subpages Message-ID: <20201209190820.GA1985874@ziepe.ca> References: <20201208172901.17384-1-joao.m.martins@oracle.com> <20201208172901.17384-8-joao.m.martins@oracle.com> <20201208194905.GQ5487@ziepe.ca> <20201209151505.GV5487@ziepe.ca> <20201209162438.GW5487@ziepe.ca> <20201209181406.GQ7338@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201209181406.GQ7338@casper.infradead.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.001725, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Dec 09, 2020 at 06:14:06PM +0000, Matthew Wilcox wrote: > > Still, I think it would be easier to teach record_subpages() that a > > PMD doesn't necessarily point to a high order page, eg do something > > like I suggested for the SGL where it extracts the page order and > > iterates over the contiguous range of pfns. > > But we also see good performance improvements from doing all reference > counts on the head page instead of spread throughout the pages, so we > really want compound pages. Oh no doubt! I'm not saying not to do that, just wanting to see some consolidation of the page table reading code. Instead of obtaining and checking the pgmap for PGMAP_COMPOUND (which is unique to devmap and very expensive) do the same algorithm we are talking about for unpin. Given a starting pfn and # of pages following (eg a PMD can be described like this) - compute the minimum list of (compound_head, ntails) tuples that spans that physical range. For instance using your folio language all the gup fast stuff pretty much boils down to: start_page = pmd_page(*pmd); // Select the sub PMD range GUP is interested in npages = adjust_for_vaddr(&start_page, vaddr, vlength, PMD_SHIFT); for_each_folio(start_page, num_pages, &folio, &ntails) { try_grab_folio(folio, ntails) } record_pages_in_output(start_page, npages); No need for all the gup_device* stuff at all. If 'for_each_folio' starts returing high order pages for devmap because the first part of this series made compound_order higher, then great! It also consolidates with the trailing part of gup_hugepte() and more on the gup slow side too. for_each_folio is just some simple maths that does: folio = to_folio(page) ntails = min(1 << folio_order(folio) - (head - page), num_pages) num_pages -= ntails page += ntails Jason