From patchwork Tue Dec 3 13:22:31 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: 11271285 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 0EA3C112B for ; Tue, 3 Dec 2019 13:23:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C3204207DD for ; Tue, 3 Dec 2019 13:23:20 +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="Ffcmxdyv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3204207DD 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 39A5B6B052D; Tue, 3 Dec 2019 08:23:05 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3725F6B052E; Tue, 3 Dec 2019 08:23:05 -0500 (EST) 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 212626B052F; Tue, 3 Dec 2019 08:23:05 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0095.hostedemail.com [216.40.44.95]) by kanga.kvack.org (Postfix) with ESMTP id 096716B052D for ; Tue, 3 Dec 2019 08:23:05 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id CEE85181AC9BF for ; Tue, 3 Dec 2019 13:23:04 +0000 (UTC) X-FDA: 76223895888.09.bag86_37e9217160e1c X-Spam-Summary: 2,0,0,1e54e4c2e4769d4e,d41d8cd98f00b204,thomas_os@shipmail.org,::linux-kernel@vger.kernel.org:dri-devel@lists.freedesktop.org:pv-drivers@vmware.com:linux-graphics-maintainer@vmware.com:thomas_os@shipmail.org:akpm@linux-foundation.org:mhocko@suse.com:willy@infradead.org:kirill.shutemov@linux.intel.com:rcampbell@nvidia.com:jglisse@redhat.com:christian.koenig@amd.com,RULES_HIT:41:152:355:379:541:800:960:973:981:988:989:1260:1261:1277:1311:1313:1314:1345:1431:1437:1515:1516:1518:1535:1543:1593:1594:1676:1711:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:2693:2730:2731:3138:3139:3140:3141:3142:3355:3865:3866:3867:3868:3870:3871:3874:4117:4250:5007:6117:6119:6261:6630:6653:7903:7974:8603:10004:10400:11026:11658:11914:12043:12296:12297:12517:12519:13095:13161:13229:13894:14181:14394:14659:14721:21063:21080:21433:21451:21627:21740:21795:30012:30054:30056:30062:30064:30070:30090,0,RBL:79.136.2.42:@shipmail.org:.lbl8.mailshell.net-62.2.203.100 64.100.201.201,CacheIP :none,Ba X-HE-Tag: bag86_37e9217160e1c X-Filterd-Recvd-Size: 6192 Received: from pio-pvt-msa3.bahnhof.se (pio-pvt-msa3.bahnhof.se [79.136.2.42]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Tue, 3 Dec 2019 13:23:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTP id EFE6E3F490; Tue, 3 Dec 2019 14:23:02 +0100 (CET) Authentication-Results: pio-pvt-msa3.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=Ffcmxdyv; 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-msa3.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa3.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EpLTpw4cJgOd; Tue, 3 Dec 2019 14:22:51 +0100 (CET) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTPA id 0939C3F528; Tue, 3 Dec 2019 14:22:49 +0100 (CET) Received: from localhost.localdomain.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id ECF713624F0; Tue, 3 Dec 2019 14:22:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1575379369; bh=LcP+CiM/H2qFU6XdEOkpDvMlsyScoUvfGPuZbgRkIhM=; h=From:To:Cc:Subject:Date:From; b=Ffcmxdyvf3CJxPEnVFfaz/xCs1ZBTpu9IO8AsYSEKxDCRX+EKzN+Urt2FqNbJTvhd scnDixrYtHjWC/93KWP3fG/TDC7slvA7vUGThO7Bc5e4mwVToMK/QtQmApVfm080Bk m1VWzvkfN8Zpxg+yJNg2gj8fMZPdIHKW1cyB8IlU= From: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28VMware=29?= To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: pv-drivers@vmware.com, linux-graphics-maintainer@vmware.com, =?utf-8?q?T?= =?utf-8?q?homas_Hellstr=C3=B6m?= , Andrew Morton , Michal Hocko , "Matthew Wilcox (Oracle)" , "Kirill A. Shutemov" , Ralph Campbell , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , =?utf-8?q?Christian_?= =?utf-8?q?K=C3=B6nig?= Subject: [PATCH 0/8] Huge page-table entries for TTM Date: Tue, 3 Dec 2019 14:22:31 +0100 Message-Id: <20191203132239.5910-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: In order to save TLB space and CPU usage this patchset enables huge- and giant page-table entries for TTM and TTM-enabled graphics drivers. Patch 1 introduces a vma_is_special_huge() function to make the mm code take the same path as DAX when splitting huge- and giant page table entries, (which currently is zapping the page-table entry and rely on re-faulting). Patch 2 makes the mm code split existing huge page-table entries on huge_fault fallbacks. Typically on COW or on buffer-objects that want write-notify. COW and write-notification is always done on the lowest page-table level. See the patch log message for additional considerations. Patch 3 introduces functions to allow the graphics drivers to manipulate the caching- and encryption flags of huge page-table entries without ugly hacks. Patch 4 implements the huge_fault handler in TTM. This enables huge page-table entries, provided that the kernel is configured to support transhuge pages, either by default or using madvise(). However, they are unlikely to be inserted unless the kernel buffer object pfns and user-space addresses align perfectly. There are various options here, but since buffer objects that reside in system pages typically start at huge page boundaries if they are backed by huge pages, we try to enforce buffer object starting pfns and user-space addresses to be huge page-size aligned if their size exceeds a huge page-size. If pud-size transhuge ("giant") pages are enabled by the arch, the same holds for those. Patch 5 implements a specialized huge_fault handler for vmwgfx. The vmwgfx driver may perform dirty-tracking and needs some special code to handle that correctly. Patch 6 implements a drm helper to align user-space addresses according to the above scheme, if possible. Patch 7 implements a TTM range manager that does the same for graphics IO memory. Patch 8 finally hooks up the helpers of patch 6 and 7 to the vmwgfx driver. A similar change is needed for graphics drivers that want a reasonable likelyhood of actually using huge page-table entries. Finally, if a buffer object size is not huge-page or giant-page aligned, its size will NOT be inflated by this patchset. This means that the buffer object tail will use smaller size page-table entries and thus no memory overhead occurs. Drivers that want to pay the memory overhead price need to implement their own scheme to inflate buffer-object sizes. PMD size huge page-table-entries have been tested with vmwgfx and found to work well both with system memory backed and IO memory backed buffer objects. PUD size giant page-table-entries have seen limited (fault and COW) testing using a modified kernel and a fake vmwgfx TTM memory type. The vmwgfx driver does otherwise not support 1GB-size IO memory resources. Comments and suggestions welcome. Thomas Changes since RFC: * Check for buffer objects present in contigous IO Memory (Christian König) * Rebased on the vmwgfx emulated coherent memory functionality. That rebase adds patch 5. Cc: Andrew Morton Cc: Michal Hocko Cc: "Matthew Wilcox (Oracle)" Cc: "Kirill A. Shutemov" Cc: Ralph Campbell Cc: "Jérôme Glisse" Cc: "Christian König"