Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4544369ybp; Mon, 14 Oct 2019 06:23:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOkY5S8YfhBzsANEgR9oplWsVPWarPhwlUGYeQhVQ4jY3BANXu3C/pwkOU4Mp/cKZ6CXVo X-Received: by 2002:a50:a781:: with SMTP id i1mr28182729edc.17.1571059395212; Mon, 14 Oct 2019 06:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571059395; cv=none; d=google.com; s=arc-20160816; b=EnGtoo5WWVf5SI+iJFaKbJmGmW74Xt3xlOIPWRuQMd3C/5lzus0iBuknwCWt3gFp4m VIZE6XrkaN/yY3Qu6/sGn7OKWURFCVGVO3ZdwSncab3WIZJcXZVl+uZ5nslk2YEsQX5V aVEHdzJeVJObBaYJZCT/+ENgUSLKP+2X5+bBQ7aPEUdujxJTPuCJygXVPj9P54xoTBmM QLZ9iiUiXYvC39FacZcMLc1eR3UkBwlnkJAKt1+7VVQUgfZGDXMfFiJI+JiQRKbfCp++ BbVg4WkiMqXt9qNoLxwF//NDcjr7qxLOB3MkYeoq6FfOF9aJrrStZmZUnhd22g60SZVZ O1OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=AsSxBIFUB6RRTiw+7OwR/xsIxSv7MBBX0NcM6bTlppc=; b=vTwET8sUgGqGhayaPy6MJ+p7X4D5fFrMsnsZ9wCvK/YMusV3PjzBi/n+TprbYFnVqp fmk/+U+BU5tX6gtkNaxteavlLcIvuM+8I3ovm1/b8JqnplaBb6HlsTM2NLHw9KOaXN61 h2PHtZ3x2jwZ07uhHgFxPCtNir6GKNsVYZbIiWz6+fgauLOsKp7prjvvsYjumtEgrGln mDJ2OpY9/qRfy3nsGJxhutW13gGYQcwVGDYinrsrU90WvPJp9oRm7KKMJOhaX8NGiQVK dovmErzOT+lsC26rDH5de6TBBA2QNCW4U6Sjt+JxBXlF6B9jUG16R5R6cEfO5AQS/tsV gCGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@shipmail.org header.s=mail header.b=UQVesyL9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oy5si10846018ejb.170.2019.10.14.06.22.51; Mon, 14 Oct 2019 06:23:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@shipmail.org header.s=mail header.b=UQVesyL9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731098AbfJNNWT (ORCPT + 99 others); Mon, 14 Oct 2019 09:22:19 -0400 Received: from ste-pvt-msa1.bahnhof.se ([213.80.101.70]:43352 "EHLO ste-pvt-msa1.bahnhof.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727789AbfJNNWS (ORCPT ); Mon, 14 Oct 2019 09:22:18 -0400 Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTP id F1CF43F71B; Mon, 14 Oct 2019 15:22:15 +0200 (CEST) Authentication-Results: ste-pvt-msa1.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=UQVesyL9; 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 ste-pvt-msa1.bahnhof.se ([127.0.0.1]) by localhost (ste-pvt-msa1.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wYrT4GHhr-9o; Mon, 14 Oct 2019 15:22:15 +0200 (CEST) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id C92EC3F6C6; Mon, 14 Oct 2019 15:22:12 +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 EC4FC360162; Mon, 14 Oct 2019 15:22:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1571059332; bh=hV+XVq7EUXh8y1VcYcoa8HQXtDcCKb0r7kHhhlkJX1U=; h=From:To:Cc:Subject:Date:From; b=UQVesyL9nEZpc05sLIm1aMteXfE9aDLWe5wiDDkRsK7yq48Xn+4Ic3NU1b7WmhX86 gmU/TgMwyhEgfks7MjB8aX7ylth0HJlibkaHsFhk5L1bcHGHEdnXQ/TtgmOejCHOPS S1PV9c6taNCu/QHe3Y/u2/f3/cM3DwqIJqAYQ7mI= From: =?UTF-8?q?Thomas=20Hellstr=C3=B6m=20=28VMware=29?= To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: torvalds@linux-foundation.org, =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Andrew Morton , Matthew Wilcox , Will Deacon , Peter Zijlstra , Rik van Riel , Minchan Kim , Michal Hocko , Huang Ying , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , "Kirill A . Shutemov" Subject: [PATCH v6 0/8] Emulated coherent graphics memory take 2 Date: Mon, 14 Oct 2019 15:21:56 +0200 Message-Id: <20191014132204.7721-1-thomas_os@shipmail.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Changes since v5: - Fix tlb flushing when we have other pending tlb flushes. 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