From owner-freebsd-hackers@FreeBSD.ORG Thu Mar 24 09:31:18 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D61D31065688; Thu, 24 Mar 2011 09:31:18 +0000 (UTC) (envelope-from jing.huang.pku@gmail.com) Received: from mail-qy0-f182.google.com (mail-qy0-f182.google.com [209.85.216.182]) by mx1.freebsd.org (Postfix) with ESMTP id 780628FC18; Thu, 24 Mar 2011 09:31:18 +0000 (UTC) Received: by qyk27 with SMTP id 27so7658064qyk.13 for ; Thu, 24 Mar 2011 02:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to:cc :content-type; bh=1Rjpfy168l9xD15+OLFoRng70GyiPM5QdrHqdQuD9YI=; b=usCqc0A+PKF5TEf7ncqCb5XaBiQhyxyNDLTe5dSn2BV0e5HhQgm56QY2p+QM/wxIIe yhDLRegz/9TS92vvPrW+6NGX1dHsqj6AeY2ZUzv7kQRNh/thUF6mjc8Nbz2Jpy8fWN2X h36iOjHwMeHci1rruQjonFBK0lokPctys+ZdE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=AS73dEHzHdEzbu02w1HS9tRfFuXODwppS63DdEurvHR/sOftamMsadsbvRtIZGnfkf KBfuOVtSq9lecpXgogvBjG0qOEoUzKSqU2yoapTa0xDVEr0IMaI8MQD3raAFTxR/N8f/ ke54/r35fvKA797OwdWrJCFqcorS988xCaJeI= MIME-Version: 1.0 Received: by 10.224.49.149 with SMTP id v21mr6959649qaf.26.1300957202647; Thu, 24 Mar 2011 02:00:02 -0700 (PDT) Received: by 10.229.100.132 with HTTP; Thu, 24 Mar 2011 02:00:02 -0700 (PDT) Date: Thu, 24 Mar 2011 17:00:02 +0800 Message-ID: From: Jing Huang To: kris@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-hackers@freebsd.org, hackers@FreeBSD.org Subject: Timecounter Project (GSoc2011) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Mar 2011 09:31:18 -0000 Hi Everyone, I am a student of Peking University in China. I am interest in the FreeBSD project of "Timecounter Performance Improvements". I am familiar with Linux kernel and virtualization systems, like KVM and Xen. I have maintained the Linux Server for my College for last whole year. Recently, I learned a lot about KVM and assigned VMs to students who need them. I also have experience of install and config FreeBSD system. In this scenario, I plan to use both tsc and shared memory to calculate precise time in user mode. The shared memory includes system_time, tsc_system_time and factor_tsc-system_time. a) system_time is the current time since the system boots, and it will be updated by time interrupt handling function. b) tsc_system_time is the tsc value when system_time update, and it is used to calculate rough delta. c) factor_tsc-system_time records the correspondence between tsc and time. It is used to calculate precise delta. When the process invokes gettimeofday, our mechanism will calculate time like: system_time+ ( factor_tsc-system_time(instant_rdtsc - tsc_system_time ) ). We see factor_tsc-system_time as a computing method here. I could refer to the relative implementation in KVM or Xen virtual machine. The real problem is that tsc counter is CPU sensitive. Our process will get wrong tsc value when switching to another CPU. I plan to force the FreeBSD kernel to update shared memory when monitoring context switch event. Alternatively, we can build NR_CPUS shared memories, and every CPU has one. Hmm.. how to recognize which CPU we are using in user mode? We also consider the CPU frequency, because tsc counter is related to it. When kernel changes CPU frequency, the shared memory should be update subsequently. Would some one give me some suggestions? Looking forward to your reply. yours sincerely. Jing