Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2683941rdb; Mon, 4 Dec 2023 04:57:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEO1U3ebCnQiiMoDe/T28fUieNfDTP6xJ4XabHFFACrGH3iQ9sfhEVSWpNNY04ssuYdNWbp X-Received: by 2002:a05:6358:6383:b0:170:17eb:b3c with SMTP id k3-20020a056358638300b0017017eb0b3cmr3532067rwh.38.1701694676134; Mon, 04 Dec 2023 04:57:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701694676; cv=none; d=google.com; s=arc-20160816; b=UwCDniaIcIvvz1QrhBKzuAmxwJgr1UJ8xMsYMx9gBm3+BTBSgYzeuHn8O4LY5MGEzo CNx2RCWv1x+crCnUtuRPq53BV2GusGWzQYTCrVIodY8tqAKDQUBgCtezq2bwK2aVuE8T Y3xto6K1IaX3GO0cZoSV2we3RaTwx804FiF7zNsc+SuBNUHdSa9pBBKzFtRQfmyLjTWF wHR32HVks73NKea6+ZhDrBvHcQqMBJ2dWFVTv48xumc/AybxFnRU0fwR8Uw7I+VQMaXv FEgS3Qj+sp1ZTgJ05NA3XVbr7b9WXZX2KtGKmDTUWGYgTuYn0/Q/aN8xjwunKj/D0oIv +qvQ== 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=JFhI8lD1QTu0a6aMa4k6PTk95/fWfSy6OGpp42XlRmg=; fh=8rGzNMnbVLE9DxJ1sssOjUOZeo4XKPS50MN5nLd8JmQ=; b=avMt/0EqkIYuCVpwX1cmJ0KCF8OoiUyqR+9e339I10Q/xELEmifzUm3rw490FThAp+ G+RvZG6bmHov8i3jRKiKA6guWiVtc4/zqB7nJQi9eAlvJRL9cyIiWZ9/w8GJYYbT0Gmr 3YxjuPxjrVf4sp8Be68ac6N2xf7XWNGqShuWHvkCeDIH7siLiO5ed4n9bxyS/BUEoWrj CVm0nqJ63L+R/YNtDR0RO5S0EF4+CRbuzH2HCgMDkQGM2PTvd2BmlOIHqsDPJmtVi0lL dbAYYJ7mjRXauGop/NZBTL7YII3b5JYKImSajY0cCKx4PRUzjxAt7hkkjO7vNulpNUBJ 9Qwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id l15-20020a65680f000000b005c67dd98b12si2500375pgt.280.2023.12.04.04.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 04:57:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id A8A1F8095826; Mon, 4 Dec 2023 04:57:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343948AbjLDM5I (ORCPT + 99 others); Mon, 4 Dec 2023 07:57:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233529AbjLDM5E (ORCPT ); Mon, 4 Dec 2023 07:57:04 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 35BC8D2 for ; Mon, 4 Dec 2023 04:57:10 -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 421031424; Mon, 4 Dec 2023 04:57:57 -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 2E2F63F5A1; Mon, 4 Dec 2023 04:57:07 -0800 (PST) Message-ID: <83497a70-45c3-4386-8994-92207ab521bd@arm.com> Date: Mon, 4 Dec 2023 12:57:05 +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> <52b042b9-ec95-4db0-b38a-f7f1cea0b90c@arm.com> <635de797-1219-40b0-b4b2-7eba758749a5@redhat.com> From: Ryan Roberts In-Reply-To: <635de797-1219-40b0-b4b2-7eba758749a5@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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 04 Dec 2023 04:57:53 -0800 (PST) On 04/12/2023 12:43, David Hildenbrand wrote: > On 04.12.23 13:39, Ryan Roberts wrote: >> 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?) > > Section size is variable (see SECTION_SIZE_BITS), but IIRC, buddy allocations > will never cross them. > >> >> Trying to figure out why my original usage in this series was wrong, but >> presumably the other places that I mentioned are safe. > > If only dealing with buddy allocations, *currently* it might always fall into a > single memory section. OK that makes sense - thanks! >