From owner-freebsd-performance@FreeBSD.ORG Wed May 10 02:38:38 2006 Return-Path: X-Original-To: freebsd-performance@freebsd.org Delivered-To: freebsd-performance@freebsd.org Received: from [127.0.0.1] (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id D101E16A401; Wed, 10 May 2006 02:38:35 +0000 (UTC) (envelope-from davidxu@freebsd.org) Message-ID: <4461522D.9060405@freebsd.org> Date: Wed, 10 May 2006 10:38:37 +0800 From: David Xu User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.12) Gecko/20060302 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tim Kientzle References: <20060506150622.C17611@fledge.watson.org> <20060509181302.GD3636@eucla.lemis.com> <20060509182330.GB92714@xor.obsecurity.org> <200605100726.28243.davidxu@freebsd.org> <44613469.2050000@freebsd.org> In-Reply-To: <44613469.2050000@freebsd.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: performance@freebsd.org, current@freebsd.org, Robert Watson , Kris Kennaway , Greg 'groggy' Lehey , freebsd-performance@freebsd.org Subject: Re: Fine-grained locking for POSIX local sockets (UNIX domain sockets) X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 May 2006 02:38:38 -0000 Tim Kientzle wrote: > I recall Matt talking about implementing gettimeofday() > without a syscall. The basic idea is to have the kernel > record some constants in a page that's mapped across > all processes, then libc can just read the time from > a known location. > > It might be nice to combine this with some of the > other ideas being tossed around here: > * On each clock tick, store a base time in > a known location (page mapped read-only, no-execute > across all memory maps) > * libc can just read the base time (accurate > to the clock rate) from a constant. Very, very fast. > * For higher resolution, the kernel could record > TSC and CPU clock speed data (per-CPU? Hmmm...) > and libc could use that to fine-tune the time? > > Still some details I need to think through... > > Tim > > One of the problems to implement it is that atomic operations, if there are multiple integer needs to be updated by kernel, userland maybe gets an inconsistent result, the way to avoid the problem is using two generation numbers. http://gsu.linux.org.tr/~mpekmezci/kernelapi/unitedlinux/arch/x86_64/kernel/vsyscall.c.html check do_vgettimeofday(struct timeval * tv): Another problem is how you tell userland the address of the kernel page ? do you use fixed address or tell it via program headers like the PT_TLS set by kernel, check /usr/src/lib/libc/gen/tls.c. David Xu