Re: [PATCH 3/6] HMM: introduce heterogeneous memory management v2.
On 01/12/2015 05:46 PM, Jerome Glisse wrote: > On Sun, Jan 11, 2015 at 03:24:42PM +0200, Oded Gabbay wrote: >> >> >> On 01/06/2015 12:44 AM, j.gli...@gmail.com wrote: >>> From: Jérôme Glisse >>> >>> This patch only introduce core HMM functions for registering a new mirror >>> and >>> stopping a mirror as well as registering and unregistering a device. >>> >>> The lifecycle of HMM object is handled differently then one of mmu_notifier >>> because unlike mmu_notifier there can be concurrent call from both mm code >>> to >>> HMM code and/or from device driver code to HMM code. Moreover lifetime of >>> HMM >>> can be uncorrelated from the lifetime of the process that is being mirror. >>> >>> Changed since v1: >>> - Updated comment of hmm_device_register(). >>> >>> Signed-off-by: Jérôme Glisse >>> Signed-off-by: Sherry Cheung >>> Signed-off-by: Subhash Gutti >>> Signed-off-by: Mark Hairgrove >>> Signed-off-by: John Hubbard >>> Signed-off-by: Jatin Kumar >>> --- >>> MAINTAINERS | 7 + >>> include/linux/hmm.h | 129 >>> include/linux/mm.h | 11 ++ >>> include/linux/mm_types.h | 14 ++ >>> kernel/fork.c| 2 + >>> mm/Kconfig | 15 ++ >>> mm/Makefile | 1 + >>> mm/hmm.c | 373 >>> +++ >>> 8 files changed, 552 insertions(+) >>> create mode 100644 include/linux/hmm.h >>> create mode 100644 mm/hmm.c >>> >>> diff --git a/MAINTAINERS b/MAINTAINERS >>> index c03bc6c..3ec87c4 100644 >>> --- a/MAINTAINERS >>> +++ b/MAINTAINERS >>> @@ -4533,6 +4533,13 @@ F: include/uapi/linux/if_hippi.h >>> F: net/802/hippi.c >>> F: drivers/net/hippi/ >>> >>> +HMM - Heterogeneous Memory Management >>> +M: Jérôme Glisse >>> +L: linux...@kvack.org >>> +S: Maintained >>> +F: mm/hmm.c >>> +F: include/linux/hmm.h >>> + >>> HOST AP DRIVER >>> M: Jouni Malinen >>> L: hos...@shmoo.com (subscribers-only) >>> diff --git a/include/linux/hmm.h b/include/linux/hmm.h >>> new file mode 100644 >>> index 000..8eddc15 >>> --- /dev/null >>> +++ b/include/linux/hmm.h >>> @@ -0,0 +1,129 @@ >>> +/* >>> + * Copyright 2013 Red Hat Inc. >>> + * >>> + * This program is free software; you can redistribute it and/or modify >>> + * it under the terms of the GNU General Public License as published by >>> + * the Free Software Foundation; either version 2 of the License, or >>> + * (at your option) any later version. >>> + * >>> + * This program is distributed in the hope that it will be useful, >>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >>> + * GNU General Public License for more details. >>> + * >>> + * Authors: Jérôme Glisse >>> + */ >>> +/* This is a heterogeneous memory management (hmm). In a nutshell this >>> provide >>> + * an API to mirror a process address on a device which has its own mmu >>> using >>> + * its own page table for the process. It supports everything except >>> special >>> + * vma. >>> + * >>> + * Mandatory hardware features : >>> + * - An mmu with pagetable. >>> + * - Read only flag per cpu page. >>> + * - Page fault ie hardware must stop and wait for kernel to service >>> fault. >>> + * >>> + * Optional hardware features : >>> + * - Dirty bit per cpu page. >>> + * - Access bit per cpu page. >>> + * >>> + * The hmm code handle all the interfacing with the core kernel mm code and >>> + * provide a simple API. It does support migrating system memory to device >>> + * memory and handle migration back to system memory on cpu page fault. >>> + * >>> + * Migrated memory is considered as swaped from cpu and core mm code point >>> of >>> + * view. >>> + */ >>> +#ifndef _HMM_H >>> +#define _HMM_H >>> + >>> +#ifdef CONFIG_HMM >>> + >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> + >>> +struct hmm_device; >>> +struct hmm_mirror; >>> +struct hmm; >>> + >>> + >>> +/* hmm_device - Each device must register one and only one hmm_device. >>> + * >>> + * The hmm_device is the link btw HMM and each device driver. >>> + */ >>> + >>> +/* struct hmm_device_operations - HMM device operation callback >>> + */ >>> +struct hmm_device_ops { >>> + /* release() - mirror must stop using the address space. >>> +* >>> +* @mirror: The mirror that link process address space with the device. >>> +* >>> +* This callback is call either on mm destruction or as result to a >>> +* call to hmm_mirror_release(). Device driver have to stop all hw >>> +* thread and all usage of the address space, it has to dirty all pages >>> +* that have been dirty by the device. But it must not clear any entry >>> +* from the mirror page table. >>> +*/ >>> + void (*release)(struct hmm_mirror *mirror); >>> +}; >>> + >>> +/* struct hmm_device - per device HMM structure >>> + * >>> + * @name: Device name (uniquel
Re: [PATCH 3/6] HMM: introduce heterogeneous memory management v2.
On Sun, Jan 11, 2015 at 03:24:42PM +0200, Oded Gabbay wrote: > > > On 01/06/2015 12:44 AM, j.gli...@gmail.com wrote: > > From: Jérôme Glisse > > > > This patch only introduce core HMM functions for registering a new mirror > > and > > stopping a mirror as well as registering and unregistering a device. > > > > The lifecycle of HMM object is handled differently then one of mmu_notifier > > because unlike mmu_notifier there can be concurrent call from both mm code > > to > > HMM code and/or from device driver code to HMM code. Moreover lifetime of > > HMM > > can be uncorrelated from the lifetime of the process that is being mirror. > > > > Changed since v1: > > - Updated comment of hmm_device_register(). > > > > Signed-off-by: Jérôme Glisse > > Signed-off-by: Sherry Cheung > > Signed-off-by: Subhash Gutti > > Signed-off-by: Mark Hairgrove > > Signed-off-by: John Hubbard > > Signed-off-by: Jatin Kumar > > --- > > MAINTAINERS | 7 + > > include/linux/hmm.h | 129 > > include/linux/mm.h | 11 ++ > > include/linux/mm_types.h | 14 ++ > > kernel/fork.c| 2 + > > mm/Kconfig | 15 ++ > > mm/Makefile | 1 + > > mm/hmm.c | 373 > > +++ > > 8 files changed, 552 insertions(+) > > create mode 100644 include/linux/hmm.h > > create mode 100644 mm/hmm.c > > > > diff --git a/MAINTAINERS b/MAINTAINERS > > index c03bc6c..3ec87c4 100644 > > --- a/MAINTAINERS > > +++ b/MAINTAINERS > > @@ -4533,6 +4533,13 @@ F: include/uapi/linux/if_hippi.h > > F: net/802/hippi.c > > F: drivers/net/hippi/ > > > > +HMM - Heterogeneous Memory Management > > +M: Jérôme Glisse > > +L: linux...@kvack.org > > +S: Maintained > > +F: mm/hmm.c > > +F: include/linux/hmm.h > > + > > HOST AP DRIVER > > M: Jouni Malinen > > L: hos...@shmoo.com (subscribers-only) > > diff --git a/include/linux/hmm.h b/include/linux/hmm.h > > new file mode 100644 > > index 000..8eddc15 > > --- /dev/null > > +++ b/include/linux/hmm.h > > @@ -0,0 +1,129 @@ > > +/* > > + * Copyright 2013 Red Hat Inc. > > + * > > + * This program is free software; you can redistribute it and/or modify > > + * it under the terms of the GNU General Public License as published by > > + * the Free Software Foundation; either version 2 of the License, or > > + * (at your option) any later version. > > + * > > + * This program is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > + * GNU General Public License for more details. > > + * > > + * Authors: Jérôme Glisse > > + */ > > +/* This is a heterogeneous memory management (hmm). In a nutshell this > > provide > > + * an API to mirror a process address on a device which has its own mmu > > using > > + * its own page table for the process. It supports everything except > > special > > + * vma. > > + * > > + * Mandatory hardware features : > > + * - An mmu with pagetable. > > + * - Read only flag per cpu page. > > + * - Page fault ie hardware must stop and wait for kernel to service > > fault. > > + * > > + * Optional hardware features : > > + * - Dirty bit per cpu page. > > + * - Access bit per cpu page. > > + * > > + * The hmm code handle all the interfacing with the core kernel mm code and > > + * provide a simple API. It does support migrating system memory to device > > + * memory and handle migration back to system memory on cpu page fault. > > + * > > + * Migrated memory is considered as swaped from cpu and core mm code point > > of > > + * view. > > + */ > > +#ifndef _HMM_H > > +#define _HMM_H > > + > > +#ifdef CONFIG_HMM > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > + > > +struct hmm_device; > > +struct hmm_mirror; > > +struct hmm; > > + > > + > > +/* hmm_device - Each device must register one and only one hmm_device. > > + * > > + * The hmm_device is the link btw HMM and each device driver. > > + */ > > + > > +/* struct hmm_device_operations - HMM device operation callback > > + */ > > +struct hmm_device_ops { > > + /* release() - mirror must stop using the address space. > > +* > > +* @mirror: The mirror that link process address space with the device. > > +* > > +* This callback is call either on mm destruction or as result to a > > +* call to hmm_mirror_release(). Device driver have to stop all hw > > +* thread and all usage of the address space, it has to dirty all pages > > +* that have been dirty by the device. But it must not clear any entry > > +* from the mirror page table. > > +*/ > > + void (*release)(struct hmm_mirror *mirror); > > +}; > > + > > +/* struct hmm_device - per device HMM structure > > + * > > + * @name: Device name (uniquely identify the device on the system). > > + *
Re: [PATCH 3/6] HMM: introduce heterogeneous memory management v2.
On 01/06/2015 12:44 AM, j.gli...@gmail.com wrote: > From: Jérôme Glisse > > This patch only introduce core HMM functions for registering a new mirror and > stopping a mirror as well as registering and unregistering a device. > > The lifecycle of HMM object is handled differently then one of mmu_notifier > because unlike mmu_notifier there can be concurrent call from both mm code to > HMM code and/or from device driver code to HMM code. Moreover lifetime of HMM > can be uncorrelated from the lifetime of the process that is being mirror. > > Changed since v1: > - Updated comment of hmm_device_register(). > > Signed-off-by: Jérôme Glisse > Signed-off-by: Sherry Cheung > Signed-off-by: Subhash Gutti > Signed-off-by: Mark Hairgrove > Signed-off-by: John Hubbard > Signed-off-by: Jatin Kumar > --- > MAINTAINERS | 7 + > include/linux/hmm.h | 129 > include/linux/mm.h | 11 ++ > include/linux/mm_types.h | 14 ++ > kernel/fork.c| 2 + > mm/Kconfig | 15 ++ > mm/Makefile | 1 + > mm/hmm.c | 373 > +++ > 8 files changed, 552 insertions(+) > create mode 100644 include/linux/hmm.h > create mode 100644 mm/hmm.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index c03bc6c..3ec87c4 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -4533,6 +4533,13 @@ F: include/uapi/linux/if_hippi.h > F: net/802/hippi.c > F: drivers/net/hippi/ > > +HMM - Heterogeneous Memory Management > +M: Jérôme Glisse > +L: linux...@kvack.org > +S: Maintained > +F: mm/hmm.c > +F: include/linux/hmm.h > + > HOST AP DRIVER > M: Jouni Malinen > L: hos...@shmoo.com (subscribers-only) > diff --git a/include/linux/hmm.h b/include/linux/hmm.h > new file mode 100644 > index 000..8eddc15 > --- /dev/null > +++ b/include/linux/hmm.h > @@ -0,0 +1,129 @@ > +/* > + * Copyright 2013 Red Hat Inc. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * Authors: Jérôme Glisse > + */ > +/* This is a heterogeneous memory management (hmm). In a nutshell this > provide > + * an API to mirror a process address on a device which has its own mmu using > + * its own page table for the process. It supports everything except special > + * vma. > + * > + * Mandatory hardware features : > + * - An mmu with pagetable. > + * - Read only flag per cpu page. > + * - Page fault ie hardware must stop and wait for kernel to service fault. > + * > + * Optional hardware features : > + * - Dirty bit per cpu page. > + * - Access bit per cpu page. > + * > + * The hmm code handle all the interfacing with the core kernel mm code and > + * provide a simple API. It does support migrating system memory to device > + * memory and handle migration back to system memory on cpu page fault. > + * > + * Migrated memory is considered as swaped from cpu and core mm code point of > + * view. > + */ > +#ifndef _HMM_H > +#define _HMM_H > + > +#ifdef CONFIG_HMM > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > + > +struct hmm_device; > +struct hmm_mirror; > +struct hmm; > + > + > +/* hmm_device - Each device must register one and only one hmm_device. > + * > + * The hmm_device is the link btw HMM and each device driver. > + */ > + > +/* struct hmm_device_operations - HMM device operation callback > + */ > +struct hmm_device_ops { > + /* release() - mirror must stop using the address space. > + * > + * @mirror: The mirror that link process address space with the device. > + * > + * This callback is call either on mm destruction or as result to a > + * call to hmm_mirror_release(). Device driver have to stop all hw > + * thread and all usage of the address space, it has to dirty all pages > + * that have been dirty by the device. But it must not clear any entry > + * from the mirror page table. > + */ > + void (*release)(struct hmm_mirror *mirror); > +}; > + > +/* struct hmm_device - per device HMM structure > + * > + * @name: Device name (uniquely identify the device on the system). > + * @ops: The hmm operations callback. > + * @mirrors: List of all active mirrors for the device. > + * @mutex: Mutex protecting mirrors list. > + * > + * Each device that want to mirror an address space must register one of this > + * struct (only once per linux device). > + */ > +struct hmm_device { > + const char
[PATCH 3/6] HMM: introduce heterogeneous memory management v2.
From: Jérôme Glisse This patch only introduce core HMM functions for registering a new mirror and stopping a mirror as well as registering and unregistering a device. The lifecycle of HMM object is handled differently then one of mmu_notifier because unlike mmu_notifier there can be concurrent call from both mm code to HMM code and/or from device driver code to HMM code. Moreover lifetime of HMM can be uncorrelated from the lifetime of the process that is being mirror. Changed since v1: - Updated comment of hmm_device_register(). Signed-off-by: Jérôme Glisse Signed-off-by: Sherry Cheung Signed-off-by: Subhash Gutti Signed-off-by: Mark Hairgrove Signed-off-by: John Hubbard Signed-off-by: Jatin Kumar --- MAINTAINERS | 7 + include/linux/hmm.h | 129 include/linux/mm.h | 11 ++ include/linux/mm_types.h | 14 ++ kernel/fork.c| 2 + mm/Kconfig | 15 ++ mm/Makefile | 1 + mm/hmm.c | 373 +++ 8 files changed, 552 insertions(+) create mode 100644 include/linux/hmm.h create mode 100644 mm/hmm.c diff --git a/MAINTAINERS b/MAINTAINERS index c03bc6c..3ec87c4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4533,6 +4533,13 @@ F: include/uapi/linux/if_hippi.h F: net/802/hippi.c F: drivers/net/hippi/ +HMM - Heterogeneous Memory Management +M: Jérôme Glisse +L: linux...@kvack.org +S: Maintained +F: mm/hmm.c +F: include/linux/hmm.h + HOST AP DRIVER M: Jouni Malinen L: hos...@shmoo.com (subscribers-only) diff --git a/include/linux/hmm.h b/include/linux/hmm.h new file mode 100644 index 000..8eddc15 --- /dev/null +++ b/include/linux/hmm.h @@ -0,0 +1,129 @@ +/* + * Copyright 2013 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * Authors: Jérôme Glisse + */ +/* This is a heterogeneous memory management (hmm). In a nutshell this provide + * an API to mirror a process address on a device which has its own mmu using + * its own page table for the process. It supports everything except special + * vma. + * + * Mandatory hardware features : + * - An mmu with pagetable. + * - Read only flag per cpu page. + * - Page fault ie hardware must stop and wait for kernel to service fault. + * + * Optional hardware features : + * - Dirty bit per cpu page. + * - Access bit per cpu page. + * + * The hmm code handle all the interfacing with the core kernel mm code and + * provide a simple API. It does support migrating system memory to device + * memory and handle migration back to system memory on cpu page fault. + * + * Migrated memory is considered as swaped from cpu and core mm code point of + * view. + */ +#ifndef _HMM_H +#define _HMM_H + +#ifdef CONFIG_HMM + +#include +#include +#include +#include +#include +#include +#include + + +struct hmm_device; +struct hmm_mirror; +struct hmm; + + +/* hmm_device - Each device must register one and only one hmm_device. + * + * The hmm_device is the link btw HMM and each device driver. + */ + +/* struct hmm_device_operations - HMM device operation callback + */ +struct hmm_device_ops { + /* release() - mirror must stop using the address space. +* +* @mirror: The mirror that link process address space with the device. +* +* This callback is call either on mm destruction or as result to a +* call to hmm_mirror_release(). Device driver have to stop all hw +* thread and all usage of the address space, it has to dirty all pages +* that have been dirty by the device. But it must not clear any entry +* from the mirror page table. +*/ + void (*release)(struct hmm_mirror *mirror); +}; + +/* struct hmm_device - per device HMM structure + * + * @name: Device name (uniquely identify the device on the system). + * @ops: The hmm operations callback. + * @mirrors: List of all active mirrors for the device. + * @mutex: Mutex protecting mirrors list. + * + * Each device that want to mirror an address space must register one of this + * struct (only once per linux device). + */ +struct hmm_device { + const char *name; + const struct hmm_device_ops *ops; + struct list_headmirrors; + struct mutexmutex; +}; + +int hmm_device_register(struct hmm_device *device); +int hmm_device_unregister(struct hmm_device *device); + + +/* hmm_mirror - device specifi