2 * Copyright 2013 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * Authors: Jérôme Glisse <jglisse@redhat.com>
17 * Refer to include/linux/hmm.h for information about heterogeneous memory
18 * management or HMM for short.
21 #include <linux/hmm.h>
22 #include <linux/slab.h>
23 #include <linux/sched.h>
28 * struct hmm - HMM per mm struct
30 * @mm: mm struct this HMM struct is bound to
37 * hmm_register - register HMM against an mm (HMM internal)
39 * @mm: mm struct to attach to
41 * This is not intended to be used directly by device drivers. It allocates an
42 * HMM struct if mm does not have one, and initializes it.
44 static struct hmm *hmm_register(struct mm_struct *mm)
47 struct hmm *hmm = NULL;
49 hmm = kmalloc(sizeof(*hmm), GFP_KERNEL);
54 spin_lock(&mm->page_table_lock);
59 spin_unlock(&mm->page_table_lock);
63 * The hmm struct can only be freed once the mm_struct goes away,
64 * hence we should always have pre-allocated an new hmm struct
70 void hmm_mm_destroy(struct mm_struct *mm)
74 #endif /* CONFIG_HMM */