From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 8 16:02:08 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E151116A4DA for ; Tue, 8 Mar 2005 16:02:05 +0000 (GMT) Received: from mail26.sea5.speakeasy.net (mail26.sea5.speakeasy.net [69.17.117.28]) by mx1.FreeBSD.org (Postfix) with ESMTP id 45B6543D46 for ; Tue, 8 Mar 2005 16:02:05 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: (qmail 30753 invoked from network); 8 Mar 2005 16:02:05 -0000 Received: from server.baldwin.cx ([216.27.160.63]) (envelope-sender )AES256-SHA encrypted SMTP for ; 8 Mar 2005 16:02:04 -0000 Received: from [10.50.40.202] (gw1.twc.weather.com [216.133.140.1]) (authenticated bits=0) by server.baldwin.cx (8.13.1/8.13.1) with ESMTP id j28G1mLF030122; Tue, 8 Mar 2005 11:01:58 -0500 (EST) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: freebsd-hackers@FreeBSD.org, Ravi Krishna Date: Tue, 8 Mar 2005 10:34:19 -0500 User-Agent: KMail/1.6.2 References: <6669fd8605030806056b53307a@mail.gmail.com> In-Reply-To: <6669fd8605030806056b53307a@mail.gmail.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200503081034.19696.jhb@FreeBSD.org> X-Spam-Status: No, score=-102.8 required=4.2 tests=ALL_TRUSTED, USER_IN_WHITELIST autolearn=failed version=3.0.2 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on server.baldwin.cx cc: hackers@FreeBSD.org Subject: Re: using segmentation to manage memory in FreeBSD X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Mar 2005 16:02:08 -0000 On Tuesday 08 March 2005 09:05 am, Ravi Krishna wrote: > Hi all! > > I would like to know if FreeBSD allows one to use segmentation on x86 > to reduce the penalty of context switches. (please read on for > details) > > Virtual memory on x86 can be managed by either segmentation or by paging. > > when using paging a context switch from one process to other all the > TLB mappings stored in TLB cache are flushed, this makes context the > switch expensive (we will have lots of TLB misses). > There are situations when individual processes donot have large memory > requirements . Some processors have TLB tagging, so OS doesnot flush > all the TLB entries when a context switch happens, only selective ones > are flushed. Unfortunatly Intex x86 does not have TLB tagging > available. Actually, it does. It's called the PG_G bit and is present if the PGE feature is listed in CR4 (which it is for most modern processors, maybe Pentium and later?) > The way to implement something similar on x86 is using segmentation. > say I have four modules > A, B, C, D each needing 100MB address. I can give each of these a > 100MB segment. Assuming TLB cache is large enough to store TLB > mappings for all of these four, to context switch (say frm A to B) I > can just switch the segment, by setting segmentation registers. > These there will be no TLB flush. When we come back frm B to A again > we switch the segment. Now again to TLB flush will happen and A will > be able to use the TLB cache entries for its segment. Segments just provide a base + offset into the virtual address space that is backed by the TLB mappings, so to make this practically useful would be a lot more work than would first appear because your segments have to map virtually contiguous memory. > This becomes more attractive for 64 bit systems. 64-bit x86 (that is, amd64 and Intel 64-bit xeons) doesn't even have segments. > My question is that is this functionality available on FreeBSD in any way? Nope. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org