ia64/linux-2.6.18-xen.hg

view drivers/net/fec_8xx/fec_8xx-netta.c @ 897:329ea0ccb344

balloon: try harder to balloon up under memory pressure.

Currently if the balloon driver is unable to increase the guest's
reservation it assumes the failure was due to reaching its full
allocation, gives up on the ballooning operation and records the limit
it reached as the "hard limit". The driver will not try again until
the target is set again (even to the same value).

However it is possible that ballooning has in fact failed due to
memory pressure in the host and therefore it is desirable to keep
attempting to reach the target in case memory becomes available. The
most likely scenario is that some guests are ballooning down while
others are ballooning up and therefore there is temporary memory
pressure while things stabilise. You would not expect a well behaved
toolstack to ask a domain to balloon to more than its allocation nor
would you expect it to deliberately over-commit memory by setting
balloon targets which exceed the total host memory.

This patch drops the concept of a hard limit and causes the balloon
driver to retry increasing the reservation on a timer in the same
manner as when decreasing the reservation.

Also if we partially succeed in increasing the reservation
(i.e. receive less pages than we asked for) then we may as well keep
those pages rather than returning them to Xen.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 05 14:01:20 2009 +0100 (2009-06-05)
parents 831230e53067
children
line source
1 /*
2 * FEC instantatiation file for NETTA
3 */
5 #include <linux/kernel.h>
6 #include <linux/types.h>
7 #include <linux/sched.h>
8 #include <linux/string.h>
9 #include <linux/ptrace.h>
10 #include <linux/errno.h>
11 #include <linux/ioport.h>
12 #include <linux/slab.h>
13 #include <linux/interrupt.h>
14 #include <linux/pci.h>
15 #include <linux/init.h>
16 #include <linux/delay.h>
17 #include <linux/netdevice.h>
18 #include <linux/etherdevice.h>
19 #include <linux/skbuff.h>
20 #include <linux/spinlock.h>
21 #include <linux/mii.h>
22 #include <linux/ethtool.h>
23 #include <linux/bitops.h>
25 #include <asm/8xx_immap.h>
26 #include <asm/pgtable.h>
27 #include <asm/mpc8xx.h>
28 #include <asm/irq.h>
29 #include <asm/uaccess.h>
30 #include <asm/commproc.h>
32 #include "fec_8xx.h"
34 /*************************************************/
36 static struct fec_platform_info fec1_info = {
37 .fec_no = 0,
38 .use_mdio = 1,
39 .phy_addr = 8,
40 .fec_irq = SIU_LEVEL1,
41 .phy_irq = CPM_IRQ_OFFSET + CPMVEC_PIO_PC6,
42 .rx_ring = 128,
43 .tx_ring = 16,
44 .rx_copybreak = 240,
45 .use_napi = 1,
46 .napi_weight = 17,
47 };
49 static struct fec_platform_info fec2_info = {
50 .fec_no = 1,
51 .use_mdio = 1,
52 .phy_addr = 2,
53 .fec_irq = SIU_LEVEL3,
54 .phy_irq = CPM_IRQ_OFFSET + CPMVEC_PIO_PC7,
55 .rx_ring = 128,
56 .tx_ring = 16,
57 .rx_copybreak = 240,
58 .use_napi = 1,
59 .napi_weight = 17,
60 };
62 static struct net_device *fec1_dev;
63 static struct net_device *fec2_dev;
65 /* XXX custom u-boot & Linux startup needed */
66 extern const char *__fw_getenv(const char *var);
68 /* access ports */
69 #define setbits32(_addr, _v) __fec_out32(&(_addr), __fec_in32(&(_addr)) | (_v))
70 #define clrbits32(_addr, _v) __fec_out32(&(_addr), __fec_in32(&(_addr)) & ~(_v))
72 #define setbits16(_addr, _v) __fec_out16(&(_addr), __fec_in16(&(_addr)) | (_v))
73 #define clrbits16(_addr, _v) __fec_out16(&(_addr), __fec_in16(&(_addr)) & ~(_v))
75 int fec_8xx_platform_init(void)
76 {
77 immap_t *immap = (immap_t *)IMAP_ADDR;
78 bd_t *bd = (bd_t *) __res;
79 const char *s;
80 char *e;
81 int i;
83 /* use MDC for MII */
84 setbits16(immap->im_ioport.iop_pdpar, 0x0080);
85 clrbits16(immap->im_ioport.iop_pddir, 0x0080);
87 /* configure FEC1 pins */
88 setbits16(immap->im_ioport.iop_papar, 0xe810);
89 setbits16(immap->im_ioport.iop_padir, 0x0810);
90 clrbits16(immap->im_ioport.iop_padir, 0xe000);
92 setbits32(immap->im_cpm.cp_pbpar, 0x00000001);
93 clrbits32(immap->im_cpm.cp_pbdir, 0x00000001);
95 setbits32(immap->im_cpm.cp_cptr, 0x00000100);
96 clrbits32(immap->im_cpm.cp_cptr, 0x00000050);
98 clrbits16(immap->im_ioport.iop_pcpar, 0x0200);
99 clrbits16(immap->im_ioport.iop_pcdir, 0x0200);
100 clrbits16(immap->im_ioport.iop_pcso, 0x0200);
101 setbits16(immap->im_ioport.iop_pcint, 0x0200);
103 /* configure FEC2 pins */
104 setbits32(immap->im_cpm.cp_pepar, 0x00039620);
105 setbits32(immap->im_cpm.cp_pedir, 0x00039620);
106 setbits32(immap->im_cpm.cp_peso, 0x00031000);
107 clrbits32(immap->im_cpm.cp_peso, 0x00008620);
109 setbits32(immap->im_cpm.cp_cptr, 0x00000080);
110 clrbits32(immap->im_cpm.cp_cptr, 0x00000028);
112 clrbits16(immap->im_ioport.iop_pcpar, 0x0200);
113 clrbits16(immap->im_ioport.iop_pcdir, 0x0200);
114 clrbits16(immap->im_ioport.iop_pcso, 0x0200);
115 setbits16(immap->im_ioport.iop_pcint, 0x0200);
117 /* fill up */
118 fec1_info.sys_clk = bd->bi_intfreq;
119 fec2_info.sys_clk = bd->bi_intfreq;
121 s = __fw_getenv("ethaddr");
122 if (s != NULL) {
123 for (i = 0; i < 6; i++) {
124 fec1_info.macaddr[i] = simple_strtoul(s, &e, 16);
125 if (*e)
126 s = e + 1;
127 }
128 }
130 s = __fw_getenv("eth1addr");
131 if (s != NULL) {
132 for (i = 0; i < 6; i++) {
133 fec2_info.macaddr[i] = simple_strtoul(s, &e, 16);
134 if (*e)
135 s = e + 1;
136 }
137 }
139 fec_8xx_init_one(&fec1_info, &fec1_dev);
140 fec_8xx_init_one(&fec2_info, &fec2_dev);
142 return fec1_dev != NULL && fec2_dev != NULL ? 0 : -1;
143 }
145 void fec_8xx_platform_cleanup(void)
146 {
147 if (fec2_dev != NULL)
148 fec_8xx_cleanup_one(fec2_dev);
150 if (fec1_dev != NULL)
151 fec_8xx_cleanup_one(fec1_dev);
152 }