From owner-freebsd-arch@freebsd.org Thu May 12 03:37:05 2016 Return-Path: Delivered-To: freebsd-arch@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9BA20B2D512 for ; Thu, 12 May 2016 03:37:05 +0000 (UTC) (envelope-from kmacybsd@gmail.com) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 7EF7A1E08 for ; Thu, 12 May 2016 03:37:05 +0000 (UTC) (envelope-from kmacybsd@gmail.com) Received: by mailman.ysv.freebsd.org (Postfix) id 7E4EDB2D511; Thu, 12 May 2016 03:37:05 +0000 (UTC) Delivered-To: arch@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7DF80B2D510 for ; Thu, 12 May 2016 03:37:05 +0000 (UTC) (envelope-from kmacybsd@gmail.com) Received: from mail-io0-x231.google.com (mail-io0-x231.google.com [IPv6:2607:f8b0:4001:c06::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BAC21E07; Thu, 12 May 2016 03:37:05 +0000 (UTC) (envelope-from kmacybsd@gmail.com) Received: by mail-io0-x231.google.com with SMTP id d62so79756517iof.2; Wed, 11 May 2016 20:37:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:cc; bh=0otaq8NOzQdvfV7AalhloiC9jdHs5GzJKw8l1NaBfwk=; b=h04uSLnegpPd2fUMcWmwYIvc+5DmUcirawqt0RZBzaH9iE+F9fhCOps4ECDYkUwXPc VpGMIJya1pdrXIL60eZ05MWZQ7HjtYTwps5Ka+iP0ztW4DBovRsNQeqqdrrHQ1qBE6rr 6IoUQUo6nW4cyL1aYJOMoeBCYp4I68iVYyjqpGYjF30UAs6eJlhjAJDe29nobCGSSC/j enqsMp8ktK24wQrmUo7rKyKrwUKF2maAMzAZiuvtbHKIHLHl4mHgikoEyF3G4R/vj8Vn 38aze9ZIhucNzi/A8/nOPwXU8ym7O9u1UJIl++sEPNG4YrkmnVPA/VbCKfpnmRJgzZR+ JYew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:date:message-id:subject:from :to:cc; bh=0otaq8NOzQdvfV7AalhloiC9jdHs5GzJKw8l1NaBfwk=; b=NsGElI+kEPPIJQAIHpQftfStaOP1H8ZeTr3sqPpaXUV+FYhupCQb5wRU+azMbfS9EO xQ1hiZUmesPszawL+Ev3FJTG5UVRnyNP9q0bmlQtW8+lsCpMIaFnHOvVqz9+Z78WKt5v 3jCsohMWZffazq7xzPHk2B5U9AMRn0nSEN8V1FvAyvfr1EU4Zs8SygmbKYQsQw/05q6N KDls5HSdtBKCBoX2vcrN/k0b+Du7m7K0dNy6q5mSKfJZ/A0tgEEAra3UWpZkOlE/n1Ml JT5ex7SRGqYQM3Sbp9FHGsQdyU8cTwiZ0v0C69AFPq4TkM9Xst2whoBunMaOzd/usB/i m2uQ== X-Gm-Message-State: AOPr4FXhMR8Mk5pA9ttsxgzNflI/O3UyzMecPdhB6Iw4G1UrewJWmywUYzNd3vko7DTT9hYDJ8Q7zCzPxxHCmQ== MIME-Version: 1.0 X-Received: by 10.36.29.13 with SMTP id 13mr6803857itj.99.1463024224307; Wed, 11 May 2016 20:37:04 -0700 (PDT) Sender: kmacybsd@gmail.com Received: by 10.107.140.8 with HTTP; Wed, 11 May 2016 20:37:04 -0700 (PDT) Date: Wed, 11 May 2016 20:37:04 -0700 X-Google-Sender-Auth: SXO59ZbbqQ3fS7svlPKQGenw87A Message-ID: Subject: MMU Notifiers and the quest for graphics feature parity From: "K. Macy" To: "freebsd-arch@freebsd.org" Cc: Ed Maste , Mark Johnston Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2016 03:37:05 -0000 My motivation for writing this email stems from my recent work extending the linuxkpi to facilitate updating graphics support for FreeBSD. I've made reasonable progress limiting my changes to the linuxkpi so far. I have 3D HW acceleration working on an essentially unmodified 4.6-rc5 drm and i915 driver. The 4.6 i915 driver supports all of Haswell (3.8 doesn't), Broadwall, Skylake, and the, as of yet, unreleased Kaby Lake processors. Additionally, I am expecting a Thinkpad e565 (AMD based) to arrive on Friday which will allow me to bring up amdgpu (the Radeon driver for post 2013 AMD GPU hardware) this weekend. I find this exciting as it means that FreeBSD will be able to run on _all_ x86 graphics hardware. Unfortunately, most if not all ARM GPU drivers are closed source. This isn't quite everything though. There is a new "userptr" ioctl in graphics drivers that allows applications to safely register user memory with the driver. This works because if pages are evicted or the process goes away, the driver will be notified first. This notification takes place through the "mmu notifier" facility. MMU Notifiers are essentially just VM callbacks (or in FreeBSD parlance eventhandlers). They were first added to Linux to enable KVM to better interoperate with the native VM's resident set management: https://lwn.net/Articles/266320/ They're now also used by IB, IOMMUs, MPSS (Xeon Phi), and graphics drivers. The API is well enough documented in the header file: http://lxr.free-electrons.com/source/include/linux/mmu_notifier.h I don't have strong feelings for what these are called or their precise location. I do, however, need to be able to support roughly equivalent semantics when I register these eventhandlers from the notifer calls in the linuxkpi. I haven't worked on the VM in a year or two so don't know quite how to proceed. I'm happy to produce patches for review, but fear that they might be rejected out of hand for one reason or another. I'd like feedback on the approach itself and what I might do to make any proposed patches more palatable. Thanks in advance.