2007-08-28 10:40:26

by John Sigler

[permalink] [raw]
Subject: pdflush preemption

Hello,

I've been using the latency tracing tool in -rt.
Linux version 2.6.22.1-rt9 (gcc version 3.4.4) #1 PREEMPT RT

prctl(0, 1); /* start tracing */
TsOut.Write(buf, packet_size);
prctl(0, 0); /* stop tracing */

Write() calls the driver through an ioctl, which schedules a DMA to copy
the buffer to a hardware device, and sleeps until the device acks the data.

The user space process has RT prio 30.
The device's IRQ line is IRQ-5.
I lowered softirq-timer's prio because at least two pieces of code
sometimes insisted on running even when an interrupt was pending
(eepro100 talking to the EEPROM and net route flush).

What's the difference between the softirq-* gizmos and the IRQ threads?
(ksoftirqd vs irqd)

# ps -eo pid,class,rtprio,ni,pri,stat,wchan:14,comm
PID CLS RTPRIO NI PRI STAT WCHAN COMMAND
1 TS - 0 19 Ss select init
2 TS - -5 24 S< kthreadd kthreadd
3 FF 99 - 139 S< posix_cpu_time posix_cpu_timer
4 FF 50 - 90 S< ksoftirqd softirq-high/0
5 FF 10 - 50 S< ksoftirqd softirq-timer/0
6 FF 50 - 90 S< ksoftirqd softirq-net-tx/
7 FF 50 - 90 S< ksoftirqd softirq-net-rx/
8 FF 50 - 90 S< ksoftirqd softirq-block/0
9 FF 50 - 90 S< ksoftirqd softirq-tasklet
10 FF 50 - 90 S< ksoftirqd softirq-sched/0
11 FF 50 - 90 S< ksoftirqd softirq-hrtimer
12 FF 50 - 90 S< ksoftirqd softirq-rcu/0
13 TS - -10 29 S< desched_thread desched/0
14 FF 1 - 41 S< worker_thread events/0
15 TS - -5 24 S< worker_thread khelper
31 TS - -5 24 S< worker_thread kblockd/0
32 TS - -5 24 S< worker_thread kacpid
33 TS - -5 24 S< worker_thread kacpi_notify
34 FF 50 - 90 S< irqd IRQ-9
96 TS - -5 24 S< serio_thread kseriod
113 TS - 0 19 S pdflush pdflush
114 TS - 0 19 S pdflush pdflush
115 TS - -5 24 S< kswapd kswapd0
116 TS - -5 24 S< worker_thread flush_filesd/0
117 TS - -5 24 S< worker_thread aio/0
720 FF 50 - 90 S< irqd IRQ-14
732 FF 50 - 90 S< irqd IRQ-12
733 FF 50 - 90 S< irqd IRQ-1
806 TS - -4 23 S<s select udevd
826 TS - 0 19 Ss select syslogd
828 TS - 0 19 Ss syslog klogd
867 FF 50 - 90 S< irqd IRQ-10
899 FF 50 - 90 S< irqd IRQ-11
937 TS - 0 19 Ss select sshd
943 TS - 0 19 Ss poll acpid
946 TS - 0 19 Ss+ read_chan agetty
949 TS - 0 19 Ss+ read_chan agetty
982 TS - 0 19 Rs - sshd
984 TS - 0 19 Ss wait bash
1005 FF 60 - 100 S< irqd IRQ-5
2443 TS - 0 19 R+ - ps

Why does pdflush kick in to ruin my party? :-)
The expected latency is ~600 ?s.
http://linux.kernel.free.fr/latency/pdflush.trace
Does ide_inb mean I'm reading from the disk?

Why are there two pdflush threads?

# cat /proc/meminfo
MemTotal: 250560 kB
MemFree: 230236 kB
Buffers: 412 kB
Cached: 12300 kB
SwapCached: 0 kB
Active: 8044 kB
Inactive: 6036 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 1384 kB
Mapped: 2276 kB
Slab: 4384 kB
SReclaimable: 1796 kB
SUnreclaim: 2588 kB
PageTables: 136 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
CommitLimit: 125280 kB
Committed_AS: 10640 kB
VmallocTotal: 778196 kB
VmallocUsed: 168 kB
VmallocChunk: 777988 kB

Does pdflush stand for page disk flush?
http://www.westnet.com/~gsmith/content/linux-pdflush.htm

# cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / ext2 rw,noatime 0 0
none /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
tmpfs /dev tmpfs rw 0 0
tmpfs /var tmpfs rw 0 0
/dev/hda2 /mnt/vidip ext2 rw,noatime 0 0

(hda is an IDE-compatible flash device.)

Is pdflush in a non-preemptible section in my trace?
(AFAICT the DOM does not support DMA.)

/var and /tmp are tmpfs, so writes to these directories don't go to hda.

There shouldn't be any writes to hda...

Regards.


2007-08-28 14:34:42

by Daniel Walker

[permalink] [raw]
Subject: Re: pdflush preemption

On Tue, 2007-08-28 at 12:39 +0200, John Sigler wrote:

> Why does pdflush kick in to ruin my party? :-)
> The expected latency is ~600 µs.
> http://linux.kernel.free.fr/latency/pdflush.trace
> Does ide_inb mean I'm reading from the disk?

Does your real time application lock it's memory, or allow itself to be
swapped?

Daniel

2007-08-28 15:10:19

by John Sigler

[permalink] [raw]
Subject: Re: pdflush preemption

Daniel Walker wrote:

> John Sigler wrote:
>
>> Why does pdflush kick in to ruin my party? :-)
>> The expected latency is ~600 µs.
>> http://linux.kernel.free.fr/latency/pdflush.trace
>> Does ide_inb mean I'm reading from the disk?
>
> Does your real time application lock its memory, or allow itself to be
> swapped?

Now that you mention it, I do remember reading this page:
http://rt.wiki.kernel.org/index.php/HOWTO:_Build_an_RT-application

There is no swap configured on the system, and 90% of the 256 MB of RAM
are free, according to /proc/meminfo, and the system is otherwise idle.

I don't think this is a major page fault. Am I wrong?

# /bin/time ./check_dektec_output2 4140063957 38000000 2632 30
0.02user 0.31system 0:20.02elapsed 1%CPU
(0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+270minor)pagefaults 0swaps
^^^^^^

# cat /proc/vmstat
nr_free_pages 59351
nr_inactive 1465
nr_active 1830
nr_anon_pages 486
nr_mapped 569
nr_file_pages 2813
nr_dirty 0
nr_writeback 0
nr_slab_reclaimable 449
nr_slab_unreclaimable 663
nr_page_table_pages 41
nr_unstable 0
nr_bounce 0
nr_vmscan_write 0
pgpgin 8197
pgpgout 113
pswpin 0
pswpout 0
pgalloc_dma 0
pgalloc_normal 27260
pgfree 86682
pgactivate 1372
pgdeactivate 0
pgfault 77490
pgmajfault 121
pgrefill_dma 0
pgrefill_normal 0
pgsteal_dma 0
pgsteal_normal 0
pgscan_kswapd_dma 0
pgscan_kswapd_normal 0
pgscan_direct_dma 0
pgscan_direct_normal 0
pginodesteal 0
slabs_scanned 0
kswapd_steal 0
kswapd_inodesteal 0
pageoutrun 0
allocstall 0
pgrotated 0

Regards.