Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751400AbcLDLLR (ORCPT ); Sun, 4 Dec 2016 06:11:17 -0500 Received: from mail-db5eur01on0071.outbound.protection.outlook.com ([104.47.2.71]:13440 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750778AbcLDLLN (ORCPT ); Sun, 4 Dec 2016 06:11:13 -0500 Authentication-Results: spf=pass (sender IP is 193.47.165.134) smtp.mailfrom=mellanox.com; amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=pass action=none header.from=mellanox.com;amd.com; dkim=none (message not signed) header.d=none; X-IncomingTopHeaderMarker: OriginalChecksum:;UpperCasedChecksum:;SizeAsReceived:2656;Count:17 Subject: Re: Enabling peer to peer device transactions for PCIe devices To: Serguei Sagalovitch , Jason Gunthorpe References: <20161123215510.GA16311@obsidianresearch.com> <91d28749-bc64-622f-56a1-26c00e6b462a@deltatee.com> <20161124164249.GD20818@obsidianresearch.com> <3f2d2db3-fb75-2422-2a18-a8497fd5d70e@amd.com> <20161125193252.GC16504@obsidianresearch.com> <20161128165751.GB28381@obsidianresearch.com> <1480357179.19407.13.camel@mellanox.com> <20161128190244.GA21975@obsidianresearch.com> <20161130162353.GA24639@obsidianresearch.com> <2560aab2-426c-6e58-cb4f-77ec76e0c941@amd.com> CC: "linux-kernel@vger.kernel.org" , "linux-rdma@vger.kernel.org" , "linux-nvdimm@ml01.01.org" , "christian.koenig@amd.com" , "Suravee.Suthikulpanit@amd.com" , "John.Bridgman@amd.com" , "Alexander.Deucher@amd.com" , "Linux-media@vger.kernel.org" , "dan.j.williams@intel.com" , "logang@deltatee.com" , "dri-devel@lists.freedesktop.org" , "Max Gurtovoy" , "linux-pci@vger.kernel.org" , "Paul.Blinzer@amd.com" , "Felix.Kuehling@amd.com" , "ben.sander@amd.com" From: Haggai Eran Message-ID: Date: Sun, 4 Dec 2016 09:33:09 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 MIME-Version: 1.0 In-Reply-To: <2560aab2-426c-6e58-cb4f-77ec76e0c941@amd.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.0.52.254] X-IncomingHeaderCount: 17 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:193.47.165.134;IPV:NLI;CTRY:IL;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(7916002)(2980300002)(438002)(377424004)(189002)(57704003)(377454003)(199003)(24454002)(81156014)(81166006)(6666003)(2950100002)(38730400001)(8676002)(5890100001)(229853002)(8936002)(39450400002)(39410400001)(2906002)(4326007)(65826007)(3846002)(65956001)(65806001)(6116002)(50466002)(33646002)(47776003)(7846002)(7736002)(83506001)(92566002)(626004)(31696002)(86362001)(5660300001)(230700001)(189998001)(8666005)(7416002)(305945005)(356003)(23746002)(4001150100001)(4001350100001)(36756003)(77096006)(64126003)(31686004)(93886004)(5001770100001)(76176999)(54356999)(50986999)(106466001)(7059030)(3940600001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0501MB2466;H:mtlcas13.mtl.com;FPR:;SPF:Pass;PTR:mail13.mellanox.com;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;DB3FFO11FD021;1:qhBcKZZJodMyMoag2z89SWIpNd8WfDWJrpC5oqGuFAmJAA1Dt1OCEXP92lubRsAQ9/BZaOkOgX+cjkD2DRZzWxr7K7X3FXf8PYS5QWL42N3b1wTI8KtOIUYiTduOnSXukIu9H8QUm9NS9/YcCBBYaf49DBbWVBc3LljLxbUMUPljE4AYfs7QR6j6eQ7WHrHNVibnLXPjJE5UibGSK968Y6ubMZXcMU/0dLlyT3JckiX3WN1me7x/05xKbq998kqytcrACnAgLr0cDAjNewnCViMsgz6umHtCjyAjRdpcGwLQ6G2q2Ugvw6Gsm6mgZkuOvbWAuDsRlrbtwNnHgUsqF2P7UVLj25mHP+KRIRAmDMEtDvSxniNjVjA46epZszQfMuWqTUDEyynm19WrJilHf1C/y28qAA8liY3qzPlRm8NBfmWncExarO/4O71r0xaWcDgEgc89PGOY4dhRIImgXlb4Ubmj0d+NgeO2xWmFGwCEvHhDVjRYtb+2CJgfTb5xsykLZFX0ovY+5586z6KxW4PbD7+iRwEoTLiA7O8IMTTlbPseW364sApKYbUlBmjW X-MS-Office365-Filtering-Correlation-Id: 634441cb-2799-4da6-df14-08d41c180355 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(8251501002);SRVR:AM5PR0501MB2466; X-Microsoft-Exchange-Diagnostics: 1;AM5PR0501MB2466;3:Elpaw+hbc+Lnb2fvKlWH1qpVbOUjeriG0ry6/db3IOLirLzpeMrH/FDehNHsByEmlgT/qD+7IiWNzJcet9cmCCxeSBwuQWafl75AntRSizhnXBr6Lwg+Kh8GR9WRq2hpgMOYuFJttVtbrh3g6S9jru4cQMrsLZs2/R3dRm99cri/exROkWxVWc2JwuNlGFKY6TmrQCWyqNEbxQfM7xN0Urak04+RwnmHvGjDL4qXLBXMaU1uh2OLVpYwBLVFGY/ds2EbvQoufYPlZdQ6sTLultOjcWjhhA7fcQxugYxGUk/pEKJzuzLd3m6EQhHqtxDqstz28iy97KqlJCQcg9YMLKrNxGwIoTseiCvJaGmmU9c9ImotQZWy/Qd1d42tQlsPxVvBDTwu4Ddm8reOhVb9Qw==;25:XbFDb6gtD66FhS7ckI2caHwLSJ/Izrsl1bDZTcvaEd81m/QdBbgwPUrCcpmPlio+InnU4KFDCwzzCpzo8cMID/rC+5kI3unZg9p7cIXnM4KqVPWFFYVasn+XMOhNVvqBwsJcGDbfb1Xfz3GL4zZZEVbQv0HPx+81P+61fBmUWgRf+SojcdcuAv8S3vIWP7u+w870RPF6FwDmm7aKrDE5NrsvQxji0lyCeKI7o5IUzEFxqDHaDYwuyIUKeFtJMEoh/WqbpusuPkZknphsweyoQHcMsHFZx1Qtf9y3npCed07/EVh9AEgqqZTxC9/QRS0nco85yLNDGIWnp0Yy/y6Z1FzcH0bYQkcnbjKjX6xb0sBH2b8jEdZCj6bhvY8GMJyUR05zWW46qv54JX8qbeSzM7b/8LoCnk8h6282fhvRHkqG6WZyI7OzgSjjDlilinaCB6yDu+JIMcCbqf4eJSIgIw== X-Microsoft-Exchange-Diagnostics: 1;AM5PR0501MB2466;31:OPsol4fmCM9HEtugjPZZ5K/U6tc+IvFJNSVxZY2h1T22nPX+JnIrQip56v8FUMYlh+3/PAA61gTrbP5g/Vo/EblSnZqFDY+iGER0I29qZWqUZm95/TpAEASUwgabATWaO7uQ8iKPFOqw59H00Mzd6BUJD7RpW6M+IHp6mRMQ5+EV8vK6VJpBDX7QWY6mm1hSV5GcSQbimTyjEJjS50Jw2mvJbS3AZur42HgvzqNHd6tt2ZH1xVZ6ViEk+WqKiWEZO/JqxpjmktntZ6KLf7drlA==;20:e8zU4tm9qxo7E9wsgEQ/2QzOqm2pfaWPyU3Rr0fUwea5lnSBy6dhDymBiR7TyxdC9Fiksvkn98CVgMKnm5boFDHAWVoh0zBfMeTuhhNG5p4TkdwRvvmWaGUz8FjH9/1FE03zHyYZ+K2ajzELuRSiAONx0Uwz2z9Gdg3EI1WqePHm3GPhZtrKdkTJy66lb6HZSXnSGVXS9QOYIDdySZLXUbeuvM0wvOvtQa8EvhOX0Aru+6bd6VP613j4S+4EsCemAOt/wkzHqHka7umUj0yFSvL3MPNa1jMfuukadpLbX4rLMEkW7ABGQDvpDAMA70oBYfT+YJ77q22mBdZUcfByfztPA9tkWv3+PHW4vua/cEAL0KWnUnUux3iuDodpsTj1T55w/8+zhiokdK/NrYytqINrpyZ4a0VzLy+o6GklSvpFtW5symH2Z6XjEAHWCDSPy67J1a5W1rpXRPcCbkTV8JyWk3ZAEieMz6WwJbpgosUejrFosUHiwXiENvTUNpPt X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(13016025)(13018025)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123562025)(20161123564025)(20161123560025)(6072148);SRVR:AM5PR0501MB2466;BCL:0;PCL:0;RULEID:;SRVR:AM5PR0501MB2466; X-Microsoft-Exchange-Diagnostics: 1;AM5PR0501MB2466;4:CrxrBwuCaQr8fb+F23ZvLi2R8/p+HZGLeOyjMMAv4sH+7C7yHb+wiH8e3pb5Jpb94gzRQev708be8i0TzwcGPRkbHGtEkWFNacHIrRbg+VZ32KOQR6bYtv+920o91KQJxPlA7SYIIKcktvM92sW6G1zacPas5HOnurTaAQmMGGOcr4iqNltK7qhFY3AYDrfpnLx4Syiwf/9Dm2VrP9dAABJUtwCXHi1kJPZ/lPpMutL2jel2Kg59M1NAgw6CvCaOFee5KOAKwqogcJ7BpOgxum8IEzzS9V4c1JkiAN8DKEPMj2dyixdlDmspcegUwsQRC11KhB/P4TUoRUCm01GFotggBYywEiXMchfFqBtNsSMXP0iOQwoX5FymnZZvZ1BxyZmElnoBtF9YYRgfqd8TMnx7aU7ngBijiHW9J67Q+a/H3EnsZT/dM1aExRLdq5P1zX8nti0Au75EAntuTx4ILEUa8KxC3QO1Iaw9kEohvCSBfwgWPSNXZJtqEmtCYSP/QicwV3jYmJM4iCatGC50DP/fA2xZ0w8EJtkUBZKcsAzTlf4jn1RiDwGmzk3JTCj77zAe+WLeDyGZa1AqluNF/J6EgGAcHrffBsjNI7H9Hd0m850J1kIrqQ1X6bRMqBTV X-Forefront-PRVS: 014617085B X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;AM5PR0501MB2466;23:6MajnA+T7noJ5DszEsNgBr0f8nCapd9xUll?= =?Windows-1252?Q?1EJbPXtO17XXw1doZMnD1MpcIQA/M53jJkrjNRpf2skxwp+ye4ZdpawS?= =?Windows-1252?Q?zwebt/AXvZx5EcGLom9LzJIcUDuqrSA03e++rJvkuejlH1iQGq9QpASj?= =?Windows-1252?Q?fp+ERyhMTiPTb8BUx8Lv+ixi6u6QABLq4DkYRylATJGfKHNVPY6sN+Ek?= =?Windows-1252?Q?bYznitMu4mkqzs1nzuo9HX38krCwA7FXoozfXELDEVJVUIQgslKMt+RO?= =?Windows-1252?Q?NOzpY1/9H4kSoWd/yshD1RTYUcHIJrqQ47g3pddvSUO+tVVbv1U1joZU?= =?Windows-1252?Q?K/RZS67Mi13n43mO8cs7o4yRPtvss8xELeaY9pQoasRm+KlhlqN3SBVe?= =?Windows-1252?Q?GcwA+pdabAb4iK36pBZH4JfGaziUZbT5NlXu768+/OEVL6vBpWtZ/ALi?= =?Windows-1252?Q?Tl+9LaggqWc+WX5Lhvt6LJL6XYVFd2sIJTYn/FVTid0AjPqcrc62hTnc?= =?Windows-1252?Q?7T7ahPhBkGZyNGH5Vav4uA2xKgPVB5C3LW3pXuMfVERCbXS1bpnUQacf?= =?Windows-1252?Q?34LNHuOAoU+6DBpo9jWhP+YIPyJ5Nua4Xkq909c0zOQdhIjxjXht8CpB?= =?Windows-1252?Q?Q6lDFJ9ORYuptdoSg1mdFDAhEro6D35uOga6DwTScvkseiR8+FDmCoL8?= =?Windows-1252?Q?0PqxlCV9grbQwchD6n5WE5qh6APOKL3jq+OW0BtYB7kRPlGkqfdAjlrM?= =?Windows-1252?Q?AoKLKJ7fO/Vb5QGDHpuQ77sCwlgJgH2gZgYClZmEuzDQhq7KWXyi0rcU?= =?Windows-1252?Q?un/XtZsF8BMydeuV3qc7GF8Kgbt2Z3boUhirjtE38VA1Pvx4h36EW2PI?= =?Windows-1252?Q?WIvqh6YZDUXgCi0oG/YZ0vixofarzXSOBSMLlQms/omAzAytEhMIscNk?= =?Windows-1252?Q?ksM0EP1NmO0BU+/nzAQl7tlrg5He6/7MAq/Bj30IzQHCpftRi8bIsZ1F?= =?Windows-1252?Q?ysnYRJUrTd0C+smPNh8ijGKLnz1LCrj/1EVfCc7H7mxhNeomv2HarGzf?= =?Windows-1252?Q?oTpJXpxmET7sfZAn4qIDnPO/4Z5vIWsBn7jOXuEdNhmnaPXA6vevam4O?= =?Windows-1252?Q?d2tUdMfgCm/1+7UGWHsu3nRBbF3mq7lSi2IOsheCLukuO8KLKobPxDzh?= =?Windows-1252?Q?2ce18UZ1y+wTzjTvjOdfJLGwKzw+DFO777cMVnYssb/0BKSGUXnqJYC6?= =?Windows-1252?Q?dhHok1kO9GPaz3JDUEDLKInnX8+ijEub0JrAkzabH6+vDpxVIPpRNO83?= =?Windows-1252?Q?sv24quwVm04RiUIEOkMhn+aXE3rOrokQR+nnea1D6of9+fgwAStaq4pW?= =?Windows-1252?Q?U6ahcXt0I+DsNk7h0HCMWZAeKE296CId5jaR/jRqGRLiTzfLQUOfnEFe?= =?Windows-1252?Q?7UBL+ZLj1sdwDH45dCRQLKxRk2qvTmQ7imYkMcvmwtjEogwBLYx9My3a?= =?Windows-1252?Q?pUvbKiMXaC9sVovWbPifaAQWorlp9IUmAmotSjSHAYmgjpBK0vcgFHM/?= =?Windows-1252?Q?QRw7M8BBysJJIxHE=3D?= X-Microsoft-Exchange-Diagnostics: 1;AM5PR0501MB2466;6:ISkHUGP/nBPhxucfrYJISbMBs14ybMpr8w2AFTDZXseXbKsyVJ2i6Y2FitJe84cimzFXGbfZN54S3inZNh4+BD2AoWGw1tZu7W6aBT1T7Fku/YyJBTrqV7bIFkzPj5vpUD2qNX1bBkTR/JHHjPNtIA0IHVVBL8ZpXC5w3zidduSCdLoBflTPhEyBmnORFpDytwXRjs4VSgYS9D4a6/fAfIfCNdyRjaOd8JqwZKDSWOS2KIM2//GAjzwjPekwU3ii7vW7JODDUHq0qZwKLPrOZmrWqd9e76SuBTYhR3v5LBfmWjh7wK6fBvGYckoHajGfXmpsNMxsOFcVvUXAD39kSXvl9PLV1D+7YQCQCb0suLSqGbj1/m8XWiOqGuJT197qGn2womcG69ByyouCUp99rDCkvsTNFBrDK7QZ7LPXQUvP7mZiRfHBgggEgzVMOHsZn4jsXrK8Tzhs/btt8cEpUb+y8gliLeOc0xso1tV5ygHnpABFt2FZy336r4wpUM35;5:GQxc3TdsqlmKaHI85Xn8dEYCJ61pGRKKlB7s3ZGs05V2CBCQN5OHUw01JXXuTcqTrylyXGvT9b27u25xzB9q4fDJ1c123ZBkSabkzwlepkT3PgtssHUY/TxMM7ngOV5HaLptmPJbdRemKm05c4CEjg==;24:6dl1s2IcAtgIIEYronQxLUZld/eaTzGblBS3BGEXguUX9338SJHUBkI7Q8NI2cFpLujZ1SHxq3X5/IKq2UeUYbGSjZVCSjNqUPiw2Ocf0HY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;AM5PR0501MB2466;7:VX6+UzpareNPrnkuok99OfrKNn3rxvXVDtZPu6bPMbLzZpwApTJz+qygaFNNsC3ims1hlxPLj4PidI5a0zNaq50dvTK/J4ieU/fqG4v7Ygvy/vtSZRg7uP7Q6/noVSJ+EEhR9hdyOBx5vYb5ShECOV1BHXAQhMILidnXBiCBDOhfCnLMRbh4K6tdcNrC13tZHWCQZ6rZoyjhhzzO5pwxe2sOkiQnD8OVZQN59LMgQFB00JIADHECErMHLF2OuPACjMtAkbwdFpQ1EbmWyn/EPAq/OW847lQHwM3aXGEuNFIIHLeyztQd1WoeqCjjGrc4pvZkm1YNebq/Z2T74V9/gUGqOK8XhcaBgzUzjLevLYslD/Ox3W7twKEWOWL6CC2D1iF3oHjomzsVfyngv30uyv3I4jjrjJMeW9vwCFcrpDEJqZY4N0shmBUueRAUjLGjCPWEsZge+AjsDWZ+C7GeXw== X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2016 07:34:42.4494 (UTC) X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a652971c-7d2e-4d9b-a6a4-d149256f461b;Ip=[193.47.165.134];Helo=[mtlcas13.mtl.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0501MB2466 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2438 Lines: 38 On 11/30/2016 7:28 PM, Serguei Sagalovitch wrote: > On 2016-11-30 11:23 AM, Jason Gunthorpe wrote: >>> Yes, that sounds fine. Can we simply kill the process from the GPU driver? >>> Or do we need to extend the OOM killer to manage GPU pages? >> I don't know.. > We could use send_sig_info to send signal from kernel to user space. So theoretically GPU driver > could issue KILL signal to some process. > >> On Wed, Nov 30, 2016 at 12:45:58PM +0200, Haggai Eran wrote: >>> I think we can achieve the kernel's needs with ZONE_DEVICE and DMA-API support >>> for peer to peer. I'm not sure we need vmap. We need a way to have a scatterlist >>> of MMIO pfns, and ZONE_DEVICE allows that. > I do not think that using DMA-API as it is is the best solution (at least in the current form): > > - It deals with handles/fd for the whole allocation but client could/will use sub-allocation as > well as theoretically possible to "merge" several allocations in one from GPU perspective. > - It require knowledge to export but because "sharing" is controlled from user space it > means that we must "export" all allocation by default > - It deals with 'fd'/handles but user application may work with addresses/pointers. Aren't you confusing DMABUF and DMA-API? DMA-API is how you program the IOMMU (dma_map_page/dma_map_sg/etc.). The comment above is just about the need to extend this API to allow mapping peer device pages to bus addresses. In the past I sent an RFC for using DMABUF for peer to peer. I think it had some advantages for legacy devices. I agree that working with addresses and pointers through something like HMM/ODP is much more flexible and easier to program from user-space. For legacy, DMABUF would have allowed you a way to pin the pages so the GPU knows not to move them. However, that can probably also be achieved simply via the reference count on ZONE_DEVICE pages. The other nice thing about DMABUF is that it migrate the buffer itself during attachment according to the requirements of the device that is attaching, so you can automatically decide in the exporter whether to use p2p or a staging buffer. > > Also current DMA-API force each time to do all DMA table programming unrelated if > location was changed or not. With vma / mmu we are able to install notifier to intercept > changes in location and update translation tables only as needed (we do not need to keep > get_user_pages() lock). I agree.