Sto lavorando al benchmarking delle prestazioni di un driver UART Linux/Android SDIO e ho usato current_kernel_time() all'inizio e alla fine della lettura da analizzare, l'implementazione della funzione di scrittura, quindi la stampa della differenza di orario.Quanto è affidabile current_kernel_time()?
La maggior parte delle volte ho una differenza di tempo di 0 (zero) nanosecondi (indipendentemente dalla dimensione dei dati da leggere/scrivere: 16-2048 byte) che logicamente ritengo sia errata, solo pochissime volte ottengo qualche si spera che i valori siano corretti.
Quanto è affidabile il current_kernel_time()?
Perché ottengo 0ns la maggior parte delle volte?
Sto progettando di profilo a livello di kernel per ottenere più details..before che qualcuno può gettare un po 'di luce su questo behavior..has nessuno ha osservato niente di simile prima ...
Inoltre, tutti i suggerimenti per aiutare/correggi il mio approccio al benchmarking!
Grazie.
MODIFICA:
Questo è il codice letto dalla versione del kernel Linux 2.6.32.9. Ho aggiunto current_kernel_time() come di seguito nella sezione # 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
}
Perché non mostri del codice? È difficile dire cosa c'è che non va in qualcosa che non puoi vedere. –
Quale piattaforma? Questo tipo di domanda è piuttosto specifico per l'hardware (o almeno specifico per l'architettura) –
Grazie per i commenti. Ho aggiunto il codice. Sto provando questo su Linux (laptop Dell a 32 bit) e Android (Android Dev Phone). – TheCottonSilk