The HyperNews Linux KHG Discussion Pages
Next-in-Thread Next Message Previous Message Next Thread

Disagree: Re: Question on alloc_skb()

Forum: Network Buffers And Memory Management
Re: Question Question on alloc_skb() (Joern Wohlrab)
Keywords: network interface
Date: Tue, 08 Apr 1997 04:42:56 GMT
From: Erik Petersen <erik@spellcast.com>

Hmm.... I'm not sure why you would want to do this personally. If alloc_skb() returns NULL, there is no memory to allocate the block you want. Normally you would report the squeeze and drop the data.

When you pass the skb to netif_rx you are esentially saying "here you go". You cant expect to reclaim the buffer as it will eventually be freed.

If you must make a best effort to deliver the data regardless of the memory situation at the time the data is received (the interrupt handler), I would create an skb list when the driver loads. Then during the interrupt, try to alloc_skb and if it fails, stuff the data in one of the pre-alloced buffers. Then the next time an interrupt occurs, try to replenish the buffer pool.

If you get to a point where both the alloc_skb fails and the buffer pool is empty, you're pretty much screwed anyways.

This would solve short-term squeeze situations but if you are that tight for memory, you might want to just printk a message saying "Get more memory cheapskate" or words to that effect.

If you're smart about it, you could balance the buffer pool at interrupt time to ensure you have enough to do the job. If you're using a good number of the buffers continuously, you might want to dynamically increase the number of buffers in the pool. If you aren't, you could reduce the number dynamically.

Just a thought.

Next-in-Thread Next Message Previous Message Next Thread

to: "Re: Question on alloc_skb()"

Subscribe Membership Move/Remove Admin Mode Show Frames Help for HyperNews 1.9.4