On Wed, Feb 20, 2008 at 9:46 AM, Peter Zijlstra <[EMAIL PROTECTED]> wrote: > Provide the basic infrastructure to reserve and charge/account network memory. ...
> Index: linux-2.6/net/core/sock.c > =================================================================== > --- linux-2.6.orig/net/core/sock.c > +++ linux-2.6/net/core/sock.c ... > +/** > + * sk_adjust_memalloc - adjust the global memalloc reserve for critical > RX > + * @socks: number of new %SOCK_MEMALLOC sockets > + * @tx_resserve_pages: number of pages to (un)reserve for TX > + * > + * This function adjusts the memalloc reserve based on system demand. > + * The RX reserve is a limit, and only added once, not for each socket. > + * > + * NOTE: > + * @tx_reserve_pages is an upper-bound of memory used for TX hence > + * we need not account the pages like we do for RX pages. > + */ > +int sk_adjust_memalloc(int socks, long tx_reserve_pages) > +{ > + int nr_socks; > + int err; > + > + err = mem_reserve_pages_add(&net_tx_pages, tx_reserve_pages); > + if (err) > + return err; > + > + nr_socks = atomic_read(&memalloc_socks); > + if (!nr_socks && socks > 0) > + err = mem_reserve_connect(&net_reserve, &mem_reserve_root); > + nr_socks = atomic_add_return(socks, &memalloc_socks); > + if (!nr_socks && socks) > + err = mem_reserve_disconnect(&net_reserve); > + > + if (err) > + mem_reserve_pages_add(&net_tx_pages, -tx_reserve_pages); > + > + return err; > +} EXPORT_SYMBOL_GPL(sk_adjust_memalloc); is needed here to build sunrpc as a module. Mike -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/