From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424648AbdEADsk (ORCPT ); Sun, 30 Apr 2017 23:48:40 -0400 Received: from ale.deltatee.com ([207.54.116.67]:39710 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164158AbdEADsa (ORCPT ); Sun, 30 Apr 2017 23:48:30 -0400 From: Logan Gunthorpe To: Jerome Glisse , "Kirill A. Shutemov" References: <20170428063913.iz6xjcxblecofjlq@gmail.com> <149339998297.24933.1129582806028305912.stgit@dwillia2-desk3.amr.corp.intel.com> <1743017574.4309811.1493400875692.JavaMail.zimbra@redhat.com> <1579714997.4315035.1493402406629.JavaMail.zimbra@redhat.com> <1295710462.4327805.1493406971970.JavaMail.zimbra@redhat.com> <20170428193305.GA3912@redhat.com> <20170429101726.cdczojcjjupb7myy@node.shutemov.name> <20170430231421.GA15163@redhat.com> Cc: Dan Williams , Ingo Molnar , "linux-kernel@vger.kernel.org" , Linux MM , Ingo Molnar , Andrew Morton , Kirill Shutemov Message-ID: <6627ee37-9638-0201-c440-9310b46c54d3@deltatee.com> Date: Sun, 30 Apr 2017 21:48:20 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 MIME-Version: 1.0 In-Reply-To: <20170430231421.GA15163@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 68.147.191.165 X-SA-Exim-Rcpt-To: kirill.shutemov@linux.intel.com, akpm@linux-foundation.org, mingo@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, mingo@kernel.org, dan.j.williams@intel.com, kirill@shutemov.name, jglisse@redhat.com X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [PATCH v2] mm, zone_device: replace {get, put}_zone_device_page() with a single reference X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30/04/17 05:14 PM, Jerome Glisse wrote: > HMM ZONE_DEVICE pages are use like other pages (anonymous or file back page) > in _any_ vma. So i need to know when a page is freed ie either as result of > unmap, exit or migration or anything that would free the memory. For zone > device a page is free once its refcount reach 1 so i need to catch refcount > transition from 2->1 > > This is the only way i can inform the device that the page is now free. See > > https://cgit.freedesktop.org/~glisse/linux/commit/?h=hmm-v21&id=52da8fe1a088b87b5321319add79e43b8372ed7d > > There is _no_ way around that. I had a similar issue in a piece of my p2pmem RFC [1]. I hacked around it by tracking the pages separately and freeing them when the vma is closed. This is by no means a great solution, it certainly has it's own warts. However, maybe it will spark some ideas for some alternate choices which avoid the hot path. Another thing I briefly looked at was hooking the vma close process earlier so that it would callback in time that you can loop through the pages and do your free process. Of course this all depends on the vma not getting closed while the pages have other references. So it may not work at all. Again, just ideas. Logan [1] https://github.com/sbates130272/linux-p2pmem/commit/77c631d92cb5c451c9824b3a4cf9b6cddfde6bb7 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-f198.google.com (mail-io0-f198.google.com [209.85.223.198]) by kanga.kvack.org (Postfix) with ESMTP id 5515A6B0038 for ; Sun, 30 Apr 2017 23:48:31 -0400 (EDT) Received: by mail-io0-f198.google.com with SMTP id z63so52996427ioz.23 for ; Sun, 30 Apr 2017 20:48:31 -0700 (PDT) Received: from ale.deltatee.com (ale.deltatee.com. [207.54.116.67]) by mx.google.com with ESMTPS id 100si12793874ioj.93.2017.04.30.20.48.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Apr 2017 20:48:30 -0700 (PDT) From: Logan Gunthorpe References: <20170428063913.iz6xjcxblecofjlq@gmail.com> <149339998297.24933.1129582806028305912.stgit@dwillia2-desk3.amr.corp.intel.com> <1743017574.4309811.1493400875692.JavaMail.zimbra@redhat.com> <1579714997.4315035.1493402406629.JavaMail.zimbra@redhat.com> <1295710462.4327805.1493406971970.JavaMail.zimbra@redhat.com> <20170428193305.GA3912@redhat.com> <20170429101726.cdczojcjjupb7myy@node.shutemov.name> <20170430231421.GA15163@redhat.com> Message-ID: <6627ee37-9638-0201-c440-9310b46c54d3@deltatee.com> Date: Sun, 30 Apr 2017 21:48:20 -0600 MIME-Version: 1.0 In-Reply-To: <20170430231421.GA15163@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [PATCH v2] mm, zone_device: replace {get, put}_zone_device_page() with a single reference Sender: owner-linux-mm@kvack.org List-ID: To: Jerome Glisse , "Kirill A. Shutemov" Cc: Dan Williams , Ingo Molnar , "linux-kernel@vger.kernel.org" , Linux MM , Ingo Molnar , Andrew Morton , Kirill Shutemov On 30/04/17 05:14 PM, Jerome Glisse wrote: > HMM ZONE_DEVICE pages are use like other pages (anonymous or file back page) > in _any_ vma. So i need to know when a page is freed ie either as result of > unmap, exit or migration or anything that would free the memory. For zone > device a page is free once its refcount reach 1 so i need to catch refcount > transition from 2->1 > > This is the only way i can inform the device that the page is now free. See > > https://cgit.freedesktop.org/~glisse/linux/commit/?h=hmm-v21&id=52da8fe1a088b87b5321319add79e43b8372ed7d > > There is _no_ way around that. I had a similar issue in a piece of my p2pmem RFC [1]. I hacked around it by tracking the pages separately and freeing them when the vma is closed. This is by no means a great solution, it certainly has it's own warts. However, maybe it will spark some ideas for some alternate choices which avoid the hot path. Another thing I briefly looked at was hooking the vma close process earlier so that it would callback in time that you can loop through the pages and do your free process. Of course this all depends on the vma not getting closed while the pages have other references. So it may not work at all. Again, just ideas. Logan [1] https://github.com/sbates130272/linux-p2pmem/commit/77c631d92cb5c451c9824b3a4cf9b6cddfde6bb7 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org