From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-la0-x234.google.com (mail-la0-x234.google.com [IPv6:2a00:1450:4010:c03::234]) by dpdk.org (Postfix) with ESMTP id 1D83F2E89 for ; Fri, 6 Sep 2013 08:33:24 +0200 (CEST) Received: by mail-la0-f52.google.com with SMTP id ev20so2393162lab.39 for ; Thu, 05 Sep 2013 23:33:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=38beaODfYp7xVQqiR+7ApvBl1m3xNXdsHYUIa+mp1tE=; b=VDCDhx1gYnMeR8VraPJonDEiMoiZEu5b5c8apTS2YS0EcUw2Ewjt2xDdHogxL4Atj3 OoLMxD/oEP00eF8nEeg8D5dHUFXFFXsbIP8iodHfsC5+2JoGs8fMIoYkYgg/tEWnGZGH 39MxodDswtpzh2JXzW/yUZRb4cVnb0JS/s4RP/dZj2cJVQkiDHRlb94+NpReFohbuG1f EOjBnBDP+4Ib3hBUSrG+pzqTnNnaLYp0tkpTawr+pNbq0k8AJgKAKdcY/zT/QHGL+Q52 teoVYEaJNgEOmEYq5hqFvwCRaulUOUA+zmVr0nrxc+kHsh12kXm80GQ/clMw9D313qPR lA3A== X-Received: by 10.152.7.100 with SMTP id i4mr104430laa.35.1378449239740; Thu, 05 Sep 2013 23:33:59 -0700 (PDT) Received: from [192.168.15.100] ([91.246.87.40]) by mx.google.com with ESMTPSA id vo1sm644553lbb.1.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Sep 2013 23:33:59 -0700 (PDT) Message-ID: <52297756.7060308@gmail.com> Date: Fri, 06 Sep 2013 10:33:58 +0400 From: Dmitry Vyal User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 MIME-Version: 1.0 To: Patrick Mahan References: <16BB02EF-879C-4DB1-804E-E5E6E08B935E@mahan.org> In-Reply-To: <16BB02EF-879C-4DB1-804E-E5E6E08B935E@mahan.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org Subject: Re: [dpdk-dev] Recommended method of getting timestamps? X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Sep 2013 06:33:25 -0000 Hello Patrick, I guess gettimeofday is too heavy if all you need is an abstract timestamp not related to any particular calendar. I think you should look at rte_rdtsc()? It returns a current value of CPU tick counter. So it's very cheap (just a few clocks) and has a great resolution (a fraction of nanosecond). Regards, Dmitry > I have a need to keep a timestamp on a piece of global data. When then timestamp grows too old I want to refresh that data. Is it safe to use, gettimeofday()? > > I thought about using an alarm, but I need to set an alarm from inside the alarm callback which doesn't look like it will work due to the spinlock on the alarm list. > > And since this is inside the driver I am working on, setting up a timer is not simple. > > So, I figure to timestamp the data, wait until I need to access it, check the timestamp and refresh if it is too old. > > Thoughts? Suggestions? > > Thanks, > > Patrick > > Coming to you from deep inside Fortress Mahan