Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3697388
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:51:14+00:00 2026-05-19T04:51:14+00:00

I am working on performance benchmarking of a SDIO UART Linux/Android driver and used

  • 0

I am working on performance benchmarking of a SDIO UART Linux/Android driver and used current_kernel_time() at start and end of the to-be-analysed read, write function implementation, then printing the time difference.

Most of the time I get time difference as 0 (zero) nanoseconds (irrespective of size of the data to read/write : 16-2048 bytes) which logically I think is incorrect, only a very few times I get some values hopefully those are correct.

How reliable is the current_kernel_time()?

Why I get 0ns most of the times?

I am planning to profile at kernel level to get more details..before that can somebody throw some light on this behavior..has anybody observed anything like this before…

Also, any suggestions to help/correct my approach to benchmarking are also welcome!

Thank you.

EDIT:
This is the read code from Linux kernel version 2.6.32.9. I added current_kernel_time() as below under #ifdef-endif:

static void sdio_uart_receive_chars(struct sdio_uart_port *port, unsigned int *status)
{
#ifdef SDIO_UART_DEBUG
struct timespec time_spec1, time_spec2;
time_spec1 = current_kernel_time();
#endif

    struct tty_struct *tty = port->tty;
    unsigned int ch, flag;
    int max_count = 256;

    do {
        ch = sdio_in(port, UART_RX);
        flag = TTY_NORMAL;
        port->icount.rx++;

        if (unlikely(*status & (UART_LSR_BI | UART_LSR_PE |
                        UART_LSR_FE | UART_LSR_OE))) {
            /*
             * For statistics only
             */
            if (*status & UART_LSR_BI) {
                *status &= ~(UART_LSR_FE | UART_LSR_PE);
                port->icount.brk++;
            } else if (*status & UART_LSR_PE)
                port->icount.parity++;
            else if (*status & UART_LSR_FE)
                port->icount.frame++;
            if (*status & UART_LSR_OE)
                port->icount.overrun++;

            /*
             * Mask off conditions which should be ignored.
             */
            *status &= port->read_status_mask;
            if (*status & UART_LSR_BI) {
                flag = TTY_BREAK;
            } else if (*status & UART_LSR_PE)
                flag = TTY_PARITY;
            else if (*status & UART_LSR_FE)
                flag = TTY_FRAME;
        }

        if ((*status & port->ignore_status_mask & ~UART_LSR_OE) == 0)
            tty_insert_flip_char(tty, ch, flag);

        /*
         * Overrun is special.  Since it's reported immediately,
         * it doesn't affect the current character.
         */
        if (*status & ~port->ignore_status_mask & UART_LSR_OE)
            tty_insert_flip_char(tty, 0, TTY_OVERRUN);

        *status = sdio_in(port, UART_LSR);
    } while ((*status & UART_LSR_DR) && (max_count-- > 0));
    tty_flip_buffer_push(tty);

#ifdef SDIO_UART_DEBUG
time_spec2 = current_kernel_time();
printk(KERN_INFO "\n MY_DBG : read took: %ld nanoseconds",
    (time_spec2.tv_sec  - time_spec1.tv_sec) * 1000000000 + (time_spec2.tv_nsec - time_spec1.tv_nsec));
#endif

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:51:15+00:00Added an answer on May 19, 2026 at 4:51 am

    current_kernel_time is meant for timekeeping, not for performance measurement.
    It returns, a value, not based on an actual timer, but on a time value that is updated by a timer interrupt. So the precision depends on the timer interrupt period.
    and you get poor resolution.

    However, perhaps getnstimeofday, is more suited to your need, since it also read the actual clock source to adjust the time value. It should be more fine grained.

    Based on kernel source, maybe the best function is getrawmonotonic, in the unlikely event that the system time is adjusted backward during your measurement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on linux and am using the values in /proc//stat to log performance
I'm working on performance tuning my SQL Server 2008 database and am using the
I'm working on a large scale performance critical asp web application with a pretty
I'm working on a project were we need more performance. Over time we've continued
I'm working on some code for a loosely coupled cluster. To achieve optimal performance
Working on improving performance of our decision center, one of the bottlenecks we identify
I'm currently working on a performance critical application which incorporates legacy c code (a
How much does the garbage collector affect performance when working with lots of objects
I'm attempting to write a performance testing function that can take any function, run
Working with dates in ruby and rails on windows, I'm having problems with pre-epoch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.