From owner-freebsd-net@FreeBSD.ORG Thu Nov 3 03:45:32 2005 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C0EB916A41F for ; Thu, 3 Nov 2005 03:45:32 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from pi.codefab.com (pi.codefab.com [199.103.21.227]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5BB6E43D45 for ; Thu, 3 Nov 2005 03:45:32 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from localhost (localhost [127.0.0.1]) by pi.codefab.com (Postfix) with ESMTP id 8E6015DA1; Wed, 2 Nov 2005 22:45:31 -0500 (EST) Received: from pi.codefab.com ([127.0.0.1]) by localhost (pi.codefab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 50422-07; Wed, 2 Nov 2005 22:45:30 -0500 (EST) Received: from [192.168.1.3] (pool-68-161-122-227.ny325.east.verizon.net [68.161.122.227]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pi.codefab.com (Postfix) with ESMTP id 79CFC5CE9; Wed, 2 Nov 2005 22:45:30 -0500 (EST) Message-ID: <436987E1.30706@mac.com> Date: Wed, 02 Nov 2005 22:45:37 -0500 From: Chuck Swiger Organization: The Courts of Chaos User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 X-Accept-Language: en-us, en MIME-Version: 1.0 To: kamal kc References: <20051103023936.63209.qmail@web35704.mail.mud.yahoo.com> In-Reply-To: <20051103023936.63209.qmail@web35704.mail.mud.yahoo.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at codefab.com Cc: freebsd Subject: Re: allocating 14KB memory per packet compression/decompression results in vm_fault X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2005 03:45:32 -0000 kamal kc wrote: > i am trying to compress/decompress ip packets. > for this i have implemented the adaptive lzw compression. > i put the code in the ip_output.c and do my compression/decompression > just before the if_output() function call so that i won't interfere with > the ip processing of the kernel. > > for my compression/decompression i use string tables and temporary > buffers which take about 14KB of memory per packet. It's highly likely that the problem you are trying to solve has already been implemented elsewhere, you ought to look at the code for these kernel options in particular: # The PPP_BSDCOMP option enables support for compress(1) style entire # packet compression, the PPP_DEFLATE is for zlib/gzip style compression. [ ... ] > These are the memory operations i perform in my code. > Now when i run the modified kernel the behaviour is unpredictable. > The compression/decompression > works fine with expected results. But soon the kernel would crash with > vm_fault: message. > > -Is the memory requirement of 14KB per packet too high to be allocated by > the kernel ?? > - Are there any other techniqures to allocate memory in kernel without > producing vm_faults ?? > - Am I not following the correct procedures to > allocate and deallocate memory in kernel space ?? > - Or is the problem elsewhere ?? You should allocate buffers once and reuse them, not continually free and reallocate 14KB of memory per packet. Look at "man 9 malloc" and the output of "sysctl kern.malloc". Perhaps you're leaking memory with each packet and run the kernel out of KVA pages, but without knowing more about the problem you are trying to solve, and without seeing more of the code you've written or at least a backtrace, it's not really useful to make random guesses. You should be looking to get a dump and run kgdb... -- -Chuck