From owner-freebsd-hackers@FreeBSD.ORG Fri Jun 3 12:12:56 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 77A19106564A; Fri, 3 Jun 2011 12:12:56 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 633498FC08; Fri, 3 Jun 2011 12:12:54 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id PAA13938; Fri, 03 Jun 2011 15:12:53 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1QSTFF-0000sS-AG; Fri, 03 Jun 2011 15:12:53 +0300 Message-ID: <4DE8CFC4.8070602@FreeBSD.org> Date: Fri, 03 Jun 2011 15:12:52 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.17) Gecko/20110503 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: John Baldwin References: <201105241356.45543.jkim@FreeBSD.org> <201106011655.51233.jkim@FreeBSD.org> <4DE8794B.60100@FreeBSD.org> <201106030750.37264.jhb@freebsd.org> In-Reply-To: <201106030750.37264.jhb@freebsd.org> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@FreeBSD.org, Jung-uk Kim Subject: Re: [RFC] Enabling invariant TSC timecounter on SMP 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: Fri, 03 Jun 2011 12:12:56 -0000 on 03/06/2011 14:50 John Baldwin said the following: > On Friday, June 03, 2011 2:03:55 am Andriy Gapon wrote: >>> Consecutive RDTSCs used on a same CPU is always incremental but we >>> cannot 100% guarantee that on two cores, even if TSC is derived from >>> the same clock. I am hoping at least latency difference (I believe >>> it's about few tens of cycles max) is "eaten up" by lowering >>> resolution. It's not perfect but it's better than serialization >>> (Linux) or heuristics (OpenSolaris), just because there are few rare >>> conditions to consider. Thoughts? >> >> I am still not sure which case this code should solve. >> >> Thread T1: x1 = rdtsc() on CPU1; >> Thread T1: x2 = rdtsc() on CPU2; >> x2 < x1 ? >> Or? > > Yes, that can happen. Well, I think that the test based on smp_rendezvous should ensure that difference in TSC values is "small enough"; that is, I expect that cost (in TSC ticks) of migrating a thread from CPU to CPU should be larger than that difference if the test was passed. Is this an unreasonable expectation? -- Andriy Gapon