Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752177AbaDDJJv (ORCPT ); Fri, 4 Apr 2014 05:09:51 -0400 Received: from mail-vc0-f173.google.com ([209.85.220.173]:44760 "EHLO mail-vc0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751899AbaDDJJq (ORCPT ); Fri, 4 Apr 2014 05:09:46 -0400 MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 4 Apr 2014 17:09:45 +0800 Message-ID: Subject: Re: Query for time tracking between userspace and kernelspace From: Lei Wen To: noman pouigt Cc: john.stultz@linaro.org, Thomas Gleixner , Stephen Boyd , Andrew Morton , Steven Rostedt , Michael Opdenacker , Joe Perches , Petr Mladek , linux-kernel@vger.kernel.org, leiwen@marvell.com Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 4, 2014 at 3:02 PM, noman pouigt wrote: > Hello, > > Probably this question belongs to kernelnewbies > list but I think i will get accurate answer from here. > > I am doing some optimization in kernel video driver > code to reduce the latency from the time buffer > is given to the time it is displayed. > > Userspace: > t1 = gettimeofday() > > Kernelspace: > t2 = do_gettimeofday() > > Using debugfs i am copying t2 to userspace and > subtracting the result. > > latency = t2 - t1 > > Would this be accurate? I know there is context > switch involved and other stuff but this is the method > i came up with. Any better way? > Not sure whether it is accurate or not... But from the code, gettimeofday syscall define in kernel/time.c is also using the kernel's do_gettimeofday API, and then copy to userspace, which shall not so different with your debugfs usage. For better way, would this vDSO getimeofday could fulfill your need? You may refer to: https://lwn.net/Articles/585203/ Thanks, Lei -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/