Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp106574ybk; Fri, 8 May 2020 20:19:28 -0700 (PDT) X-Google-Smtp-Source: APiQypLy9HemrpRMUK4qUuuD/fMH97g66rt1IOCBNpahq09EUDGXS/QQxZz7J11hyUvlB2BANsOb X-Received: by 2002:a17:906:34c8:: with SMTP id h8mr4623038ejb.321.1588994368787; Fri, 08 May 2020 20:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588994368; cv=none; d=google.com; s=arc-20160816; b=FAjVOlSH1RgvyLQd4csYHeya8QWGNxvkmJeYanuO6XAAhSo/wwQjWhAoMzyroMsyq7 H3jjLjknW/wcC0AxaGmLj4n/vZURM+gIbCMuoEYKazzpzelFgNOSMeRXUTskKpLEGcfz KWDSUG/7Tvex44l4mXZ7wBcmDLkyt6ybwsPOCp7tRyI3kVkQHkv/sGR4HA+3sxFGcWWt 0iw7GEAJepsse/Bn5aNFf5L01qwEUhPaiuLB3yDWa3T+7vwZzwprxG5rXtyZ091l8U45 qKLqbdp6o8ZaupJR+1c5qChvzU8iTIoPnDF0HWg4VHrSZE5lb9+E58uHUrbDLwJ7D2lV XIkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=lyg8KFPxTn0tWshWc1x4r9ezlzCrdRUk1alOb1U8QOk=; b=AqopG3VSlRUodjcRHravNaxhtd5UBgtFwAEfWpMqcUWsRwuziuR3Kfe+g9ABxRGglf uJc8sJkVZ7+Nuvzj4d8FF5KShMOWcJN9ORYHSFBtUvwmI8cpOhxzVgzhsr6JLOw+rgib DkMM8a8WqTJIIdpoHBABpZ+oq1x8z633H1okCBHYacVvhJNOw2eynq3tymIvKNH1GB8i wb94jL14pKLMUQJHcVupOX5An2NbKBKZwRCMK+0G83KEBVDiEmwLPI/yHy3OQGXxZCDJ coSirQy1qeh9XtYCiDsETb08dIMBPW/WNQcx9DMS08OS+M4DDIShf+SXn/jJpOU6kkL5 zEVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=mjzVRHGS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h8si2064924ejl.53.2020.05.08.20.19.05; Fri, 08 May 2020 20:19:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=mjzVRHGS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728626AbgEIDRd (ORCPT + 99 others); Fri, 8 May 2020 23:17:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728421AbgEIDRc (ORCPT ); Fri, 8 May 2020 23:17:32 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4D35C061A0C; Fri, 8 May 2020 20:17:32 -0700 (PDT) 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=lyg8KFPxTn0tWshWc1x4r9ezlzCrdRUk1alOb1U8QOk=; b=mjzVRHGSFUzWCtzv5ct3WCVzIJ ctNdyru+3tw2Jx6byTHTJQdaLOT6wypRAwM0vM2BA4uTaZtqgBMteST/YjZJAGCjBwcYThXJPE7/x yKqdUpYrah7TLL+CgNUvGMi7er7Ds8YVx/LcngEtraSyPD7EPowngkYGh2oEmoNlgi8apHTbQjn/V buoEqQ4HLNZNOjPcy+7VUaM1SwZI2P+rqXh0qrcN0izk711h14xjyY8hAK7g2BXziyMosb87vaZUW IzKvDkrSzkQsUUdLQZC3Zpq8nEMRjyBLe+cpQChBogC+1GMjV2EmiLtnG0vtSzWy/cSY+ZO6ik0mL /JrDhQLw==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jXFzS-0001xm-Dk; Sat, 09 May 2020 03:17:26 +0000 Date: Fri, 8 May 2020 20:17:26 -0700 From: Matthew Wilcox To: Ralph Campbell Cc: nouveau@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Jerome Glisse , John Hubbard , Christoph Hellwig , Jason Gunthorpe , Ben Skeggs , Andrew Morton , Shuah Khan Subject: Re: [PATCH 0/6] nouveau/hmm: add support for mapping large pages Message-ID: <20200509031726.GT16070@bombadil.infradead.org> References: <20200508192009.15302-1-rcampbell@nvidia.com> <20200508195910.GR16070@bombadil.infradead.org> <72422dca-e025-002a-4748-addfb392ffc4@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <72422dca-e025-002a-4748-addfb392ffc4@nvidia.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 08, 2020 at 01:17:55PM -0700, Ralph Campbell wrote: > On 5/8/20 12:59 PM, Matthew Wilcox wrote: > > On Fri, May 08, 2020 at 12:20:03PM -0700, Ralph Campbell wrote: > > > hmm_range_fault() returns an array of page frame numbers and flags for > > > how the pages are mapped in the requested process' page tables. The PFN > > > can be used to get the struct page with hmm_pfn_to_page() and the page size > > > order can be determined with compound_order(page) but if the page is larger > > > than order 0 (PAGE_SIZE), there is no indication that the page is mapped > > > using a larger page size. To be fully general, hmm_range_fault() would need > > > to return the mapping size to handle cases like a 1GB compound page being > > > mapped with 2MB PMD entries. However, the most common case is the mapping > > > size the same as the underlying compound page size. > > > This series adds a new output flag to indicate this so that callers know it > > > is safe to use a large device page table mapping if one is available. > > > Nouveau and the HMM tests are updated to use the new flag. > > > > This explanation doesn't make any sense. It doesn't matter how somebody > > else has it mapped; if it's a PMD-sized page, you can map it with a > > 2MB mapping. > > Sure, the I/O will work OK, but is it safe? > Copy on write isn't an issue? splitting a PMD in one process due to > mprotect of a shared page will cause other process' page tables to be split > the same way? Are you saying that if you call this function on an address range of a process which has done COW of a single page in the middle of a THP, you want to return with this flag clear, but if the THP is still intact, you want to set this flag? > Recall that these are system memory pages that could be THPs, shmem, hugetlbfs, > mmap shared file pages, etc.