From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754889AbdFXDyt convert rfc822-to-8bit (ORCPT ); Fri, 23 Jun 2017 23:54:49 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:15685 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754723AbdFXDyr (ORCPT ); Fri, 23 Jun 2017 23:54:47 -0400 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Fri, 23 Jun 2017 20:54:46 -0700 Subject: Re: [HMM 09/15] mm/hmm/devmem: device memory hotplug using ZONE_DEVICE v5 To: =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , , , CC: Dan Williams , "Kirill A . Shutemov" , Evgeny Baskakov , Mark Hairgrove , Sherry Cheung , Subhash Gutti , Evgeny Baskakov References: <20170524172024.30810-1-jglisse@redhat.com> <20170524172024.30810-10-jglisse@redhat.com> X-Nvconfidentiality: public From: John Hubbard Message-ID: <64f74f48-ca5e-e16d-7546-0d57163f6f93@nvidia.com> Date: Fri, 23 Jun 2017 20:54:44 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <20170524172024.30810-10-jglisse@redhat.com> X-Originating-IP: [172.17.160.221] X-ClientProxiedBy: HQMAIL106.nvidia.com (172.18.146.12) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/24/2017 10:20 AM, Jérôme Glisse wrote: [...] > +/* > + * hmm_devmem_fault_range() - migrate back a virtual range of memory > + * > + * @devmem: hmm_devmem struct use to track and manage the ZONE_DEVICE memory > + * @vma: virtual memory area containing the range to be migrated > + * @ops: migration callback for allocating destination memory and copying > + * @src: array of unsigned long containing source pfns > + * @dst: array of unsigned long containing destination pfns > + * @start: start address of the range to migrate (inclusive) > + * @addr: fault address (must be inside the range) > + * @end: end address of the range to migrate (exclusive) > + * @private: pointer passed back to each of the callback > + * Returns: 0 on success, VM_FAULT_SIGBUS on error > + * > + * This is a wrapper around migrate_vma() which checks the migration status > + * for a given fault address and returns the corresponding page fault handler > + * status. That will be 0 on success, or VM_FAULT_SIGBUS if migration failed > + * for the faulting address. > + * > + * This is a helper intendend to be used by the ZONE_DEVICE fault handler. > + */ > +int hmm_devmem_fault_range(struct hmm_devmem *devmem, > + struct vm_area_struct *vma, > + const struct migrate_vma_ops *ops, > + unsigned long *src, > + unsigned long *dst, > + unsigned long start, > + unsigned long addr, > + unsigned long end, > + void *private) > +{ > + if (migrate_vma(ops, vma, start, end, src, dst, private)) > + return VM_FAULT_SIGBUS; > + > + if (dst[(addr - start) >> PAGE_SHIFT] & MIGRATE_PFN_ERROR) > + return VM_FAULT_SIGBUS; > + > + return 0; > +} > +EXPORT_SYMBOL(hmm_devmem_fault_range); > +#endif /* IS_ENABLED(CONFIG_HMM_DEVMEM) */ > Hi Jerome (+Evgeny), After some time and testing, I'd like to recommend that we delete the above hmm_dev_fault_range() function from the patchset. Reasons: 1. Our driver code is actually easier to follow if we call migrate_vma() directly, for CPU faults. That's because there are a lot of hmm_* calls in both directions (driver <--> core), already, and it takes some time to remember which direction each one goes. 2. The helper is a little confusing to use, what with a start, end, *and* an addr argument. 3. ...and it doesn't add anything that the driver can't trivially do itself. So, let's just remove it. Less is more this time. :) thanks, -- John Hubbard NVIDIA