On Wed, 3 Aug 2005, Daniel Phillips wrote: > Hi, > > Here is a preliminary patch, not tested at all, just to give everybody a > target to aim bricks at. > > * A new __GFP_MEMALLOC flag gives access to the memalloc reserve. > > * In dev_alloc_skb, if GFP_ATOMIC fails then try again with __GFP_MEMALLOC.
This might give some unwanted side effects... Normally a NIC driver has an rx-ring with skbs that are allocated by using dev_alloc_skb() And before the memory got low the skbs in the ring was allocated using GFP_ATOMIC and when packets are recieved the skb is passed up the stack and if in the meantime (since the skb was allocated) memory got low the checks for __GFP_MEMALLOC won't trigger as it isn't set in the skb. And what's worse is that when memory is low new packets allocated with dev_alloc_skb() will allocate them from __GFP_MEMALLOC, and then they are placed in the rx-ring just waiting to be used which might not happen for a while. One positive thing might be that at least some GFP_ATOMIC memory is released in the befinning when the skbs in the rx-ring is beeing reallocated. So when memory gets tight, you won't notice __GFP_MEMALLOC for as many packets as the rx-ring contains skbs. But you do allocate skbs with __GFP_MEMALLOC just that they get stuffed into the rx-ring and will stay there until used by incoming packets. iirc, the e1000 driver defaults to a rx-ring size of 256 skbs. One thing could be to utilize the skb copybreak that certain NIC drivers implement. If the packetsize is rather small a new skb is allocated and the data is copied from the skb in the rx-ring to the new skb which then contains the __GFP_MEMALLOC and the GFP_ATOMIC skb stays in the rx-ring. This could be used to avoid the problems above, but... it adds overhead to all packets when memory isn't low since all packets needs to be copied and the copy is more expensive for larger packets which slows things down compared to not copying. If there's another way of detecting the low memory situation other than a failing copy the copybreak abuse could be enabled only when memory is low, that would probably get the best from both worlds. /Martin - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html