On Sat, August 12, 2006 20:08, Peter Zijlstra said:
> On Sat, 2006-08-12 at 19:54 +0200, Indan Zupancic wrote:
>> True, but currently memalloc_reserve isn't used in a sensible way,
>> or I'm missing something.
>
> Well, I'm somewhat reluctant to stick network related code into mm/, it
> seems well separated now.

What I had in mind was something like:

+static DEFINE_SPINLOCK(memalloc_lock);
+static int memalloc_socks;
+
+atomic_t memalloc_skbs_used;
+EXPORT_SYMBOL_GPL(memalloc_skbs_used);
+
+int sk_adjust_memalloc(int nr_socks)
+{
+       unsigned long flags;
+       unsigned int reserve;
+       int err;
+
+       spin_lock_irqsave(&memalloc_lock, flags);
+
+       memalloc_socks += nr_socks;
+       BUG_ON(memalloc_socks < 0);
+
+       reserve = nr_socks * (2 * MAX_PHYS_SEGMENTS +   /* outbound */
+                             5 * MAX_CONCURRENT_SKBS); /* inbound */
+
+       err = adjust_memalloc_reserve(reserve);
+       spin_unlock_irqrestore(&memalloc_lock, flags);
+       if (err) {
+               printk(KERN_WARNING
+                       "Unable to change RX reserve to: %lu, error: %d\n",
+                       reserve, err);
+       }
+       return err;
+}

The original code missed the brackets, so 5 * MAX_CONCURRENT_SKBS wasn't done
per socket. But the comment said it was per socket, so I added in this version.

Greetings,

Indan


-
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

Reply via email to