Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2675316rdb; Mon, 4 Dec 2023 04:40:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfVn9hWV008OkyGBo+Y+DCtDhUK0N7f7jPv+fEWWHCNHXFkHgF//kE0PkSqzDHR4zKE/48 X-Received: by 2002:a17:90a:3048:b0:286:6cc1:8672 with SMTP id q8-20020a17090a304800b002866cc18672mr1597842pjl.87.1701693642232; Mon, 04 Dec 2023 04:40:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701693642; cv=none; d=google.com; s=arc-20160816; b=eIJL5fKZo3IsPZn5Ey3h7GFsUlB8TVIbzWW4UvRZ+1C2/x1S8jUGkpU3jzfUTYSKAn nPLbYec9k/U5mVOaBLVxx3eLuW0Z1/vAM1jyXUGrBrNH4xVNxn3HjALu8rDTpvXtygn9 HQNWtuD3oPKVst8vUoObNSwNJ6SesLsvEUDcEJPNH92I1n4MxY1w765XfDvMq/YXLyHn 7hM5WYrdUFc36+ikI/gLo2kLS233yAlY0KkCGd46jKhLbjtZdVmt7ArtAcs5HVfYvraL AwDWWUYCFxCFlf1PYUUnxXebXs7uCFQ9d3l/8cMp2kTN7Ze9N7+nyvxzY2/KZIEEWq7z h1GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=+5b8MBu6rfJuWDzcAfvQbPo0RTOjpJ87Cty6pHQRk6Y=; fh=8rGzNMnbVLE9DxJ1sssOjUOZeo4XKPS50MN5nLd8JmQ=; b=rJZdjdarhWKgU5XBvTnEwvq+vXJ+7OnOWBw4Ui+JW7l+L+TIqQ8jg2o40ejmGLhDHS Et/Y8eFcyCnbI81yPLWa1nHaw/i//vEK2leXZhZW5dSFbn3GPedkGlJ2m7p3/7LW7KRh UQrE0XJL3xGbOHEa6Mpw76HYwHQiKOXzZdxPMGMqev8lpIB0wrPEF6+yKV50kJsyEw9l fyVH0WrwhH8hxjuNfAjtuZ6HkO7OQYVs2NERQdEI3mC90vW+E2YQ0kHdmNkFVBhfWuCP qskKQtBcERO5+fGClmufEfqkMbnE4TQevMN2fp0sH+1jTt/Q6b/M2ONZ1kaBvFc/1tYN 49fw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id v5-20020a17090a458500b002867c645d4bsi3281854pjg.13.2023.12.04.04.40.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 04:40:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 7A409804C627; Mon, 4 Dec 2023 04:40:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233215AbjLDMjz (ORCPT + 99 others); Mon, 4 Dec 2023 07:39:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233435AbjLDMjk (ORCPT ); Mon, 4 Dec 2023 07:39:40 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B233D106 for ; Mon, 4 Dec 2023 04:39:45 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A917C1424; Mon, 4 Dec 2023 04:40:32 -0800 (PST) Received: from [10.57.73.130] (unknown [10.57.73.130]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EA8AC3F5A1; Mon, 4 Dec 2023 04:39:42 -0800 (PST) Message-ID: <52b042b9-ec95-4db0-b38a-f7f1cea0b90c@arm.com> Date: Mon, 4 Dec 2023 12:39:41 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 4/4] mm/mmu_gather: Store and process pages in contig ranges Content-Language: en-GB To: David Hildenbrand , Zi Yan , Matthew Wilcox Cc: Will Deacon , "Aneesh Kumar K.V" , Andrew Morton , Nick Piggin , Peter Zijlstra , Christian Borntraeger , Sven Schnelle , Arnd Bergmann , Yu Zhao , "Kirill A. Shutemov" , Yin Fengwei , Yang Shi , "Huang, Ying" , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20230810103332.3062143-1-ryan.roberts@arm.com> <20230810103332.3062143-5-ryan.roberts@arm.com> <800937DA-BAD0-4C60-B155-AECCA21E955E@nvidia.com> <1a0f5cb8-421c-4f28-a986-f3c381406e81@arm.com> <90EC4C0D-0254-4B93-AFD5-3C09580A77DE@nvidia.com> <6dd6164a-1dd5-46e7-bcf7-b62ff5c6e8ec@arm.com> <890f4455-bf1b-437b-a355-7895e4dd3085@redhat.com> From: Ryan Roberts In-Reply-To: <890f4455-bf1b-437b-a355-7895e4dd3085@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 04 Dec 2023 04:40:09 -0800 (PST) On 04/12/2023 12:28, David Hildenbrand wrote: > On 04.12.23 13:26, Ryan Roberts wrote: >>>>> >>>>> Also, struct page (memmap) might not be always contiguous, using struct page >>>>> points to represent folio range might not give the result you want. >>>>> See nth_page() and folio_page_idx() in include/linux/mm.h. >>>> >>>> Is that true for pages within the same folio too? Or are all pages in a folio >>>> guarranteed contiguous? Perhaps I'm better off using pfn? >>> >>> folio_page_idx() says not all pages in a folio is guaranteed to be contiguous. >>> PFN might be a better choice. >> >> Hi Zi, Matthew, >> >> Zi made this comment a couple of months back that it is incorrect to assume that >> `struct page`s within a folio are (virtually) contiguous. I'm not sure if that's >> really the case though? I see other sites in the source that do page++ when >> iterating over a folio. e.g. smaps_account(), splice_folio_into_pipe(), >> __collapse_huge_page_copy(), etc. >> >> Any chance someone could explain the rules? > > With the vmemmap, they are contiguous. Without a vmemmap, but with sparsemem, we > might end up allocating one memmap chunk per memory section (e.g., 128 MiB). > > So, for example, a 1 GiB hugetlb page could cross multiple 128 MiB sections, and > therefore, the memmap might not be virtually consecutive. OK, is a "memory section" always 128M or is it variable? If fixed, does that mean that it's impossible for a THP to cross section boundaries? (because a THP is always smaller than a section?) Trying to figure out why my original usage in this series was wrong, but presumably the other places that I mentioned are safe. > >