| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: balloon.c,v 1.7 2011/04/18 01:36:25 jym Exp $ */ | | 1 | /* $NetBSD: balloon.c,v 1.8 2011/04/18 03:04:31 rmind Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Cherry G. Mathew <cherry@zyx.in> and | | 8 | * by Cherry G. Mathew <cherry@zyx.in> and |
9 | * Jean-Yves Migeon <jym@NetBSD.org> | | 9 | * Jean-Yves Migeon <jym@NetBSD.org> |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -61,27 +61,27 @@ | | | @@ -61,27 +61,27 @@ |
61 | * XXX Pages used by balloon are tracked through entries stored in a SLIST. | | 61 | * XXX Pages used by balloon are tracked through entries stored in a SLIST. |
62 | * This allows driver to conveniently add/remove wired pages from memory | | 62 | * This allows driver to conveniently add/remove wired pages from memory |
63 | * without the need to support these "memory gaps" inside uvm(9). Still, the | | 63 | * without the need to support these "memory gaps" inside uvm(9). Still, the |
64 | * driver does not currently "plug" new pages into uvm(9) when more memory | | 64 | * driver does not currently "plug" new pages into uvm(9) when more memory |
65 | * is available than originally managed by balloon. For example, deflating | | 65 | * is available than originally managed by balloon. For example, deflating |
66 | * balloon with a total number of pages above physmem is not supported for | | 66 | * balloon with a total number of pages above physmem is not supported for |
67 | * now. See balloon_deflate() for more details. | | 67 | * now. See balloon_deflate() for more details. |
68 | * | | 68 | * |
69 | */ | | 69 | */ |
70 | | | 70 | |
71 | #define BALLOONDEBUG 0 | | 71 | #define BALLOONDEBUG 0 |
72 | | | 72 | |
73 | #include <sys/cdefs.h> | | 73 | #include <sys/cdefs.h> |
74 | __KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.7 2011/04/18 01:36:25 jym Exp $"); | | 74 | __KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.8 2011/04/18 03:04:31 rmind Exp $"); |
75 | | | 75 | |
76 | #include <sys/inttypes.h> | | 76 | #include <sys/inttypes.h> |
77 | #include <sys/device.h> | | 77 | #include <sys/device.h> |
78 | #include <sys/param.h> | | 78 | #include <sys/param.h> |
79 | | | 79 | |
80 | #include <sys/atomic.h> | | 80 | #include <sys/atomic.h> |
81 | #include <sys/condvar.h> | | 81 | #include <sys/condvar.h> |
82 | #include <sys/kernel.h> | | 82 | #include <sys/kernel.h> |
83 | #include <sys/kmem.h> | | 83 | #include <sys/kmem.h> |
84 | #include <sys/kthread.h> | | 84 | #include <sys/kthread.h> |
85 | #include <sys/mutex.h> | | 85 | #include <sys/mutex.h> |
86 | #include <sys/pool.h> | | 86 | #include <sys/pool.h> |
87 | #include <sys/queue.h> | | 87 | #include <sys/queue.h> |
| @@ -219,31 +219,27 @@ balloon_xenbus_attach(device_t parent, d | | | @@ -219,31 +219,27 @@ balloon_xenbus_attach(device_t parent, d |
219 | #if BALLOONDEBUG | | 219 | #if BALLOONDEBUG |
220 | aprint_normal_dev(self, "min reservation: %"PRIu64" KiB\n", | | 220 | aprint_normal_dev(self, "min reservation: %"PRIu64" KiB\n", |
221 | sc->balloon_res_min); | | 221 | sc->balloon_res_min); |
222 | aprint_normal_dev(self, "max reservation: %"PRIu64" KiB\n", | | 222 | aprint_normal_dev(self, "max reservation: %"PRIu64" KiB\n", |
223 | BALLOON_PAGES_TO_KB(xenmem_get_maxreservation())); | | 223 | BALLOON_PAGES_TO_KB(xenmem_get_maxreservation())); |
224 | #endif | | 224 | #endif |
225 | | | 225 | |
226 | sc->bpge_pool = pool_cache_init(sizeof(struct balloon_page_entry), | | 226 | sc->bpge_pool = pool_cache_init(sizeof(struct balloon_page_entry), |
227 | 0, 0, 0, "xen_bpge", NULL, IPL_NONE, bpge_ctor, bpge_dtor, NULL); | | 227 | 0, 0, 0, "xen_bpge", NULL, IPL_NONE, bpge_ctor, bpge_dtor, NULL); |
228 | | | 228 | |
229 | sysctl_kern_xen_balloon_setup(sc); | | 229 | sysctl_kern_xen_balloon_setup(sc); |
230 | | | 230 | |
231 | /* List of MFNs passed from/to balloon for inflating/deflating */ | | 231 | /* List of MFNs passed from/to balloon for inflating/deflating */ |
232 | mfn_list = kmem_alloc(BALLOON_DELTA * sizeof(*mfn_list), KM_NOSLEEP); | | 232 | mfn_list = kmem_alloc(BALLOON_DELTA * sizeof(*mfn_list), KM_SLEEP); |
233 | if (mfn_list == NULL) { | | | |
234 | aprint_error_dev(self, "could not allocate mfn_list\n"); | | | |
235 | goto error; | | | |
236 | } | | | |
237 | sc->sc_mfn_list = mfn_list; | | 233 | sc->sc_mfn_list = mfn_list; |
238 | | | 234 | |
239 | /* Setup xenbus node watch callback */ | | 235 | /* Setup xenbus node watch callback */ |
240 | if (register_xenbus_watch(&balloon_xenbus_watch)) { | | 236 | if (register_xenbus_watch(&balloon_xenbus_watch)) { |
241 | aprint_error_dev(self, "unable to watch memory/target\n"); | | 237 | aprint_error_dev(self, "unable to watch memory/target\n"); |
242 | goto error; | | 238 | goto error; |
243 | } | | 239 | } |
244 | | | 240 | |
245 | /* Setup kernel thread to asynchronously (in/de)-flate the balloon */ | | 241 | /* Setup kernel thread to asynchronously (in/de)-flate the balloon */ |
246 | if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL, balloon_thread, | | 242 | if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL, balloon_thread, |
247 | sc, NULL, "xen_balloon")) { | | 243 | sc, NULL, "xen_balloon")) { |
248 | aprint_error_dev(self, "unable to create balloon thread\n"); | | 244 | aprint_error_dev(self, "unable to create balloon thread\n"); |
249 | unregister_xenbus_watch(&balloon_xenbus_watch); | | 245 | unregister_xenbus_watch(&balloon_xenbus_watch); |