From patchwork Thu Oct 10 12:43:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28Intel=29?= X-Patchwork-Id: 11183429 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CA941575 for ; Thu, 10 Oct 2019 12:43:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 329F320B7C for ; Thu, 10 Oct 2019 12:43:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=shipmail.org header.i=@shipmail.org header.b="NAaNoRX/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 329F320B7C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shipmail.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 64DF08E000A; Thu, 10 Oct 2019 08:43:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5D7E86B0005; Thu, 10 Oct 2019 08:43:41 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47B788E000A; Thu, 10 Oct 2019 08:43:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 1F34C6B0003 for ; Thu, 10 Oct 2019 08:43:41 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id B5680181AC9AE for ; Thu, 10 Oct 2019 12:43:40 +0000 (UTC) X-FDA: 76027841400.21.shake47_3cf1bc3a3e223 X-Spam-Summary: 2,0,0,658972ed1b37fcd6,d41d8cd98f00b204,thomas_os@shipmail.org,:linux-kernel@vger.kernel.org::torvalds@linux-foundation.org:kirill@shutemov.name:thellstrom@vmware.com:akpm@linux-foundation.org:willy@infradead.org:will.deacon@arm.com:peterz@infradead.org:riel@surriel.com:minchan@kernel.org:mhocko@suse.com:ying.huang@intel.com:jglisse@redhat.com,RULES_HIT:41:152:355:379:541:800:960:968:973:988:989:1260:1261:1277:1311:1313:1314:1345:1431:1437:1515:1516:1518:1535:1543:1593:1594:1676:1711:1730:1747:1777:1792:2393:2559:2562:2693:2895:2897:3138:3139:3140:3141:3142:3355:3865:3866:3867:3868:3870:3871:3874:4117:4250:5007:6117:6119:6261:6653:7576:7875:7903:7974:10004:10400:11026:11232:11658:11914:12043:12048:12296:12297:12438:12517:12519:12679:13095:13161:13229:13894:14181:14394:14659:14721:21063:21080:21433:21451:21627:21809:21939:30012:30034:30054:30056:30064:30069:30070:30091,0,RBL:79.136.2.41:@shipmail.org:.lbl8.mailshell.net-62.2.203.100 64.100.201.201,CacheIP:none, Bayesian X-HE-Tag: shake47_3cf1bc3a3e223 X-Filterd-Recvd-Size: 6032 Received: from pio-pvt-msa2.bahnhof.se (pio-pvt-msa2.bahnhof.se [79.136.2.41]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Oct 2019 12:43:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 839293F66E; Thu, 10 Oct 2019 14:43:31 +0200 (CEST) Authentication-Results: pio-pvt-msa2.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=NAaNoRX/; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -2.099 X-Spam-Level: X-Spam-Status: No, score=-2.099 tagged_above=-999 required=6.31 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Received: from pio-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id t1tejHvEyFaS; Thu, 10 Oct 2019 14:43:25 +0200 (CEST) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 67FB33F260; Thu, 10 Oct 2019 14:43:23 +0200 (CEST) Received: from localhost.localdomain.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id C051A36016C; Thu, 10 Oct 2019 14:43:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1570711402; bh=DUBZteFxRv+biRAr6ikt9dxEsTdkCF11hutElrgSLqA=; h=From:To:Cc:Subject:Date:From; b=NAaNoRX/AmaY33dT8r1CHyHyVrTM0aSbQBgT3unS/YYrbVbmH28TCylntbnj5bHyp vW62Rkaoi+tNnDDEwoeMf+bvzonXkVwAq9fW/5jHi7eeo6RnlB51GTaeplfhNxfIE4 oFL8fVBbA9mcq5pkN7dRjjF3XeyueXYygpH0zf4k= From: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28VMware=29?= To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, torvalds@linux-foundation.org, kirill@shutemov.name Cc: =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Andrew Morton , Matthew Wilcox , Will Deacon , Peter Zijlstra , Rik van Riel , Minchan Kim , Michal Hocko , Huang Ying , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= Subject: [PATCH v5 0/8] Emulated coherent graphics memory take 2 Date: Thu, 10 Oct 2019 14:43:06 +0200 Message-Id: <20191010124314.40067-1-thomas_os@shipmail.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 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: From: Thomas Hellström Graphics APIs like OpenGL 4.4 and Vulkan require the graphics driver to provide coherent graphics memory, meaning that the GPU sees any content written to the coherent memory on the next GPU operation that touches that memory, and the CPU sees any content written by the GPU to that memory immediately after any fence object trailing the GPU operation is signaled. Paravirtual drivers that otherwise require explicit synchronization needs to do this by hooking up dirty tracking to pagefault handlers and buffer object validation. Provide mm helpers needed for this and that also allow for huge pmd- and pud entries (patch 1-3), and the associated vmwgfx code (patch 4-7). The code has been tested and exercised by a tailored version of mesa where we disable all explicit synchronization and assume graphics memory is coherent. The performance loss varies of course; a typical number is around 5%. I would like to merge this code through the DRM tree, so an ack to include the new mm helpers in that merge would be greatly appreciated. Changes since RFC: - Merge conflict changes moved to the correct patch. Fixes intra-patchset compile errors. - Be more aggressive when turning ttm vm code into helpers. This makes sure we can use a const qualifier on the vmwgfx vm_ops. - Reinstate a lost comment an fix an error path that was broken when turning the ttm vm code into helpers. - Remove explicit type-casts of struct vm_area_struct::vm_private_data - Clarify the locking inversion that makes us not being able to use the mm pagewalk code. Changes since v1: - Removed the vmwgfx maintainer entry for as_dirty_helpers.c, updated commit message accordingly - Removed the TTM patches from the series as they are merged separately through DRM. Changes since v2: - Split out the pagewalk code from as_dirty_helpers.c and document locking. - Add pre_vma and post_vma callbacks to the pagewalk code. - Remove huge pmd and -pud asserts that would trip when we protect vmas with struct address_space::i_mmap_rwsem rather than with struct vm_area_struct::mmap_sem. - Do some naming cleanup in as_dirty_helpers.c Changes since v3: - Extensive renaming of the dirty helpers including the filename. - Update walk_page_mapping() doc. - Update the pagewalk code to not unconditionally split pmds if a pte_entry() callback is present. Update the dirty helper pmd_entry accordingly. - Use separate walk ops for the dirty helpers. - Update the pagewalk code to take the pagetable lock in walk_pte_range. Changes since v4: - Fix pte pointer confusion in patch 2/8 - Skip the pagewalk code conditional split patch for now, and update the mapping_dirty_helper accordingly. That problem will be solved in a cleaner way in a follow-up patchset. Cc: Andrew Morton Cc: Matthew Wilcox Cc: Will Deacon Cc: Peter Zijlstra Cc: Rik van Riel Cc: Minchan Kim Cc: Michal Hocko Cc: Huang Ying Cc: Jérôme Glisse Cc: Kirill A. Shutemov