From: Thomas Monjalon Subject: Re: [PATCH v3] timer: add new rte_rdtsc_precise function Date: Wed, 26 Feb 2014 10:39:56 +0100 Message-ID: <201402261039.57202.thomas.monjalon@6wind.com> References: <1392809945-28025-1-git-send-email-didier.pallard@6wind.com> <1392828368-8563-1-git-send-email-didier.pallard@6wind.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: dev-VfR2kkLFssw@public.gmane.org To: Didier Pallard Return-path: In-Reply-To: <1392828368-8563-1-git-send-email-didier.pallard-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 19/02/2014 17:46, Didier Pallard: > According to Intel Developer's Manual: > > "The RDTSC instruction is not a serializing instruction. It does not > necessarily wait until all previous instructions have been executed before > reading the counter. Simi- larly, subsequent instructions may begin > execution before the read operation is performed. If software requires > RDTSC to be executed only after all previous instruc- tions have completed > locally, it can either use RDTSCP (if the processor supports that > instruction) or execute the sequence LFENCE;RDTSC." > > So add a rte_rdtsc_precise function that do a memory barrier before rdtsc > to synchronize operations and ensure that the TSC read is done at the > expected place. > > Signed-off-by: Didier Pallard > --- > > Call rte_mb() and rte_rdtsc() rather than duplicating rte_rdtsc function. > Use r/w memory barrier instead of lfence to serialize both load and stores. Acked and applied. Thanks to all -- Thomas