From owner-freebsd-hackers Mon Nov 9 01:14:18 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id BAA02749 for freebsd-hackers-outgoing; Mon, 9 Nov 1998 01:14:18 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from root.com (root.com [198.145.90.17]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id BAA02743 for ; Mon, 9 Nov 1998 01:14:16 -0800 (PST) (envelope-from xroot@root.com) Received: from implode.root.com (localhost [127.0.0.1]) by root.com (8.8.5/8.8.5) with ESMTP id BAA09637; Mon, 9 Nov 1998 01:15:16 -0800 (PST) Message-Id: <199811090915.BAA09637@root.com> To: Terry Lambert cc: grog@lemis.com (Greg Lehey), Reinier.Bezuidenhout@KryptoKom.DE, freebsd-hackers@FreeBSD.ORG Subject: Re: Malloc in the kernel In-reply-to: Your message of "Mon, 09 Nov 1998 04:22:11 GMT." <199811090422.VAA12381@usr07.primenet.com> From: David Greenman Reply-To: dg@root.com Date: Mon, 09 Nov 1998 01:15:16 -0800 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >> >> If I want to malloc really large space in the kernel, say from >> >> 2k up to 1M or maybe more .... wat parameter should 'n >> >> give to malloc ?? > >[ ... ] > >> > It depends on what you intend to use the memory for. >> > >> > Ideally, you would be prepared to take a page fault, and would >> > allocate pageable memory backed by swap so that you didn't >> > exhaust the physical memory in the system. >> > >> > In general, the kernel is better at deciding what memory it needs >> > when it needs it than a kernel code author. You either trust >> > the locality of reference model upon which VM systems are based, >> > or you don't. >> >> Assuming that fits his needs, what's the answer? > >vm_pager_allocate(OBJT_SWAP, 0, OFF_TO_IDX(size), VM_PROT_DEFAULT, 0); Bzzt! Wrong! ...but you could use kmem_alloc_pageable() (or call vm_map_find() directly) to allocate demand-zero, pageable, kernel memory. -DG David Greenman Co-founder/Principal Architect, The FreeBSD Project To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message