Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 157244
b: refs/heads/master
c: ab1f5e4
h: refs/heads/master
v: v3
  • Loading branch information
David S. Miller committed Aug 29, 2009
1 parent 5e9def7 commit e0b0376
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 11ebd1bf07fafde8d16562966c96b05b0d4ced9e
refs/heads/master: ab1f5e49f84e7072a0aade47cfeecef70be46c0f
4 changes: 0 additions & 4 deletions trunk/drivers/net/irda/au1k_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/slab.h>
#include <linux/rtnetlink.h>
#include <linux/interrupt.h>
Expand Down Expand Up @@ -205,9 +204,6 @@ static const struct net_device_ops au1k_irda_netdev_ops = {
.ndo_start_xmit = au1k_irda_hard_xmit,
.ndo_tx_timeout = au1k_tx_timeout,
.ndo_do_ioctl = au1k_irda_ioctl,
.ndo_change_mtu = eth_change_mtu,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
};

static int au1k_irda_net_init(struct net_device *dev)
Expand Down
4 changes: 0 additions & 4 deletions trunk/drivers/net/irda/sa1100_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/slab.h>
#include <linux/rtnetlink.h>
#include <linux/interrupt.h>
Expand Down Expand Up @@ -881,9 +880,6 @@ static const struct net_device_ops sa1100_irda_netdev_ops = {
.ndo_stop = sa1100_irda_stop,
.ndo_start_xmit = sa1100_irda_hard_xmit,
.ndo_do_ioctl = sa1100_irda_ioctl,
.ndo_change_mtu = eth_change_mtu,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
};

static int sa1100_irda_probe(struct platform_device *pdev)
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/smc91x.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ static inline void smc_rcv(struct net_device *dev)
local_irq_restore(flags); \
__ret; \
})
#define smc_special_lock(lock, flags) spin_lock_irq(lock, flags)
#define smc_special_lock(lock, flags) spin_lock_irqsave(lock, flags)
#define smc_special_unlock(lock, flags) spin_unlock_irqrestore(lock, flags)
#else
#define smc_special_trylock(lock, flags) (1)
Expand Down
61 changes: 46 additions & 15 deletions trunk/drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ struct virtnet_info
struct sk_buff_head recv;
struct sk_buff_head send;

/* Work struct for refilling if we run low on memory. */
struct delayed_work refill;

/* Chain pages by the private ptr. */
struct page *pages;
};
Expand Down Expand Up @@ -273,19 +276,22 @@ static void receive_skb(struct net_device *dev, struct sk_buff *skb,
dev_kfree_skb(skb);
}

static void try_fill_recv_maxbufs(struct virtnet_info *vi)
static bool try_fill_recv_maxbufs(struct virtnet_info *vi, gfp_t gfp)
{
struct sk_buff *skb;
struct scatterlist sg[2+MAX_SKB_FRAGS];
int num, err, i;
bool oom = false;

sg_init_table(sg, 2+MAX_SKB_FRAGS);
for (;;) {
struct virtio_net_hdr *hdr;

skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN + NET_IP_ALIGN);
if (unlikely(!skb))
if (unlikely(!skb)) {
oom = true;
break;
}

skb_reserve(skb, NET_IP_ALIGN);
skb_put(skb, MAX_PACKET_LEN);
Expand All @@ -296,7 +302,7 @@ static void try_fill_recv_maxbufs(struct virtnet_info *vi)
if (vi->big_packets) {
for (i = 0; i < MAX_SKB_FRAGS; i++) {
skb_frag_t *f = &skb_shinfo(skb)->frags[i];
f->page = get_a_page(vi, GFP_ATOMIC);
f->page = get_a_page(vi, gfp);
if (!f->page)
break;

Expand Down Expand Up @@ -325,31 +331,35 @@ static void try_fill_recv_maxbufs(struct virtnet_info *vi)
if (unlikely(vi->num > vi->max))
vi->max = vi->num;
vi->rvq->vq_ops->kick(vi->rvq);
return !oom;
}

static void try_fill_recv(struct virtnet_info *vi)
/* Returns false if we couldn't fill entirely (OOM). */
static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp)
{
struct sk_buff *skb;
struct scatterlist sg[1];
int err;
bool oom = false;

if (!vi->mergeable_rx_bufs) {
try_fill_recv_maxbufs(vi);
return;
}
if (!vi->mergeable_rx_bufs)
return try_fill_recv_maxbufs(vi, gfp);

for (;;) {
skb_frag_t *f;

skb = netdev_alloc_skb(vi->dev, GOOD_COPY_LEN + NET_IP_ALIGN);
if (unlikely(!skb))
if (unlikely(!skb)) {
oom = true;
break;
}

skb_reserve(skb, NET_IP_ALIGN);

f = &skb_shinfo(skb)->frags[0];
f->page = get_a_page(vi, GFP_ATOMIC);
f->page = get_a_page(vi, gfp);
if (!f->page) {
oom = true;
kfree_skb(skb);
break;
}
Expand All @@ -373,6 +383,7 @@ static void try_fill_recv(struct virtnet_info *vi)
if (unlikely(vi->num > vi->max))
vi->max = vi->num;
vi->rvq->vq_ops->kick(vi->rvq);
return !oom;
}

static void skb_recv_done(struct virtqueue *rvq)
Expand All @@ -385,6 +396,23 @@ static void skb_recv_done(struct virtqueue *rvq)
}
}

static void refill_work(struct work_struct *work)
{
struct virtnet_info *vi;
bool still_empty;

vi = container_of(work, struct virtnet_info, refill.work);
napi_disable(&vi->napi);
try_fill_recv(vi, GFP_KERNEL);
still_empty = (vi->num == 0);
napi_enable(&vi->napi);

/* In theory, this can happen: if we don't get any buffers in
* we will *never* try to fill again. */
if (still_empty)
schedule_delayed_work(&vi->refill, HZ/2);
}

static int virtnet_poll(struct napi_struct *napi, int budget)
{
struct virtnet_info *vi = container_of(napi, struct virtnet_info, napi);
Expand All @@ -400,10 +428,10 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
received++;
}

/* FIXME: If we oom and completely run out of inbufs, we need
* to start a timer trying to fill more. */
if (vi->num < vi->max / 2)
try_fill_recv(vi);
if (vi->num < vi->max / 2) {
if (!try_fill_recv(vi, GFP_ATOMIC))
schedule_delayed_work(&vi->refill, 0);
}

/* Out of packets? */
if (received < budget) {
Expand Down Expand Up @@ -893,6 +921,7 @@ static int virtnet_probe(struct virtio_device *vdev)
vi->vdev = vdev;
vdev->priv = vi;
vi->pages = NULL;
INIT_DELAYED_WORK(&vi->refill, refill_work);

/* If they give us a callback when all buffers are done, we don't need
* the timer. */
Expand Down Expand Up @@ -941,7 +970,7 @@ static int virtnet_probe(struct virtio_device *vdev)
}

/* Last of all, set up some receive buffers. */
try_fill_recv(vi);
try_fill_recv(vi, GFP_KERNEL);

/* If we didn't even get one input buffer, we're useless. */
if (vi->num == 0) {
Expand All @@ -958,6 +987,7 @@ static int virtnet_probe(struct virtio_device *vdev)

unregister:
unregister_netdev(dev);
cancel_delayed_work_sync(&vi->refill);
free_vqs:
vdev->config->del_vqs(vdev);
free:
Expand Down Expand Up @@ -986,6 +1016,7 @@ static void virtnet_remove(struct virtio_device *vdev)
BUG_ON(vi->num != 0);

unregister_netdev(vi->dev);
cancel_delayed_work_sync(&vi->refill);

vdev->config->del_vqs(vi->vdev);

Expand Down
2 changes: 1 addition & 1 deletion trunk/net/sched/sch_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ EXPORT_SYMBOL(qdisc_warn_nonwc);
static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer)
{
struct qdisc_watchdog *wd = container_of(timer, struct qdisc_watchdog,
timer);
timer.timer);

wd->qdisc->flags &= ~TCQ_F_THROTTLED;
__netif_schedule(qdisc_root(wd->qdisc));
Expand Down
2 changes: 1 addition & 1 deletion trunk/net/sched/sch_cbq.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ static psched_tdiff_t cbq_undelay_prio(struct cbq_sched_data *q, int prio,
static enum hrtimer_restart cbq_undelay(struct hrtimer *timer)
{
struct cbq_sched_data *q = container_of(timer, struct cbq_sched_data,
delay_timer);
delay_timer.timer);
struct Qdisc *sch = q->watchdog.qdisc;
psched_time_t now;
psched_tdiff_t delay = 0;
Expand Down

0 comments on commit e0b0376

Please sign in to comment.