ia64/linux-2.6.18-xen.hg

view drivers/net/spider_net_ethtool.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 * Network device driver for Cell Processor-Based Blade
3 *
4 * (C) Copyright IBM Corp. 2005
5 *
6 * Authors : Utz Bacher <utz.bacher@de.ibm.com>
7 * Jens Osterkamp <Jens.Osterkamp@de.ibm.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
24 #include <linux/netdevice.h>
25 #include <linux/ethtool.h>
26 #include <linux/pci.h>
28 #include "spider_net.h"
30 static int
31 spider_net_ethtool_get_settings(struct net_device *netdev,
32 struct ethtool_cmd *cmd)
33 {
34 struct spider_net_card *card;
35 card = netdev_priv(netdev);
37 cmd->supported = (SUPPORTED_1000baseT_Full |
38 SUPPORTED_FIBRE);
39 cmd->advertising = (ADVERTISED_1000baseT_Full |
40 ADVERTISED_FIBRE);
41 cmd->port = PORT_FIBRE;
42 cmd->speed = card->phy.speed;
43 cmd->duplex = DUPLEX_FULL;
45 return 0;
46 }
48 static void
49 spider_net_ethtool_get_drvinfo(struct net_device *netdev,
50 struct ethtool_drvinfo *drvinfo)
51 {
52 struct spider_net_card *card;
53 card = netdev_priv(netdev);
55 /* clear and fill out info */
56 memset(drvinfo, 0, sizeof(struct ethtool_drvinfo));
57 strncpy(drvinfo->driver, spider_net_driver_name, 32);
58 strncpy(drvinfo->version, "0.1", 32);
59 strcpy(drvinfo->fw_version, "no information");
60 strncpy(drvinfo->bus_info, pci_name(card->pdev), 32);
61 }
63 static void
64 spider_net_ethtool_get_wol(struct net_device *netdev,
65 struct ethtool_wolinfo *wolinfo)
66 {
67 /* no support for wol */
68 wolinfo->supported = 0;
69 wolinfo->wolopts = 0;
70 }
72 static u32
73 spider_net_ethtool_get_msglevel(struct net_device *netdev)
74 {
75 struct spider_net_card *card;
76 card = netdev_priv(netdev);
77 return card->msg_enable;
78 }
80 static void
81 spider_net_ethtool_set_msglevel(struct net_device *netdev,
82 u32 level)
83 {
84 struct spider_net_card *card;
85 card = netdev_priv(netdev);
86 card->msg_enable = level;
87 }
89 static int
90 spider_net_ethtool_nway_reset(struct net_device *netdev)
91 {
92 if (netif_running(netdev)) {
93 spider_net_stop(netdev);
94 spider_net_open(netdev);
95 }
96 return 0;
97 }
99 static u32
100 spider_net_ethtool_get_rx_csum(struct net_device *netdev)
101 {
102 struct spider_net_card *card = netdev->priv;
104 return card->options.rx_csum;
105 }
107 static int
108 spider_net_ethtool_set_rx_csum(struct net_device *netdev, u32 n)
109 {
110 struct spider_net_card *card = netdev->priv;
112 card->options.rx_csum = n;
113 return 0;
114 }
116 static uint32_t
117 spider_net_ethtool_get_tx_csum(struct net_device *netdev)
118 {
119 return (netdev->features & NETIF_F_HW_CSUM) != 0;
120 }
122 static int
123 spider_net_ethtool_set_tx_csum(struct net_device *netdev, uint32_t data)
124 {
125 if (data)
126 netdev->features |= NETIF_F_HW_CSUM;
127 else
128 netdev->features &= ~NETIF_F_HW_CSUM;
130 return 0;
131 }
133 static void
134 spider_net_ethtool_get_ringparam(struct net_device *netdev,
135 struct ethtool_ringparam *ering)
136 {
137 struct spider_net_card *card = netdev->priv;
139 ering->tx_max_pending = SPIDER_NET_TX_DESCRIPTORS_MAX;
140 ering->tx_pending = card->tx_desc;
141 ering->rx_max_pending = SPIDER_NET_RX_DESCRIPTORS_MAX;
142 ering->rx_pending = card->rx_desc;
143 }
145 struct ethtool_ops spider_net_ethtool_ops = {
146 .get_settings = spider_net_ethtool_get_settings,
147 .get_drvinfo = spider_net_ethtool_get_drvinfo,
148 .get_wol = spider_net_ethtool_get_wol,
149 .get_msglevel = spider_net_ethtool_get_msglevel,
150 .set_msglevel = spider_net_ethtool_set_msglevel,
151 .nway_reset = spider_net_ethtool_nway_reset,
152 .get_rx_csum = spider_net_ethtool_get_rx_csum,
153 .set_rx_csum = spider_net_ethtool_set_rx_csum,
154 .get_tx_csum = spider_net_ethtool_get_tx_csum,
155 .set_tx_csum = spider_net_ethtool_set_tx_csum,
156 .get_ringparam = spider_net_ethtool_get_ringparam,
157 };