LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 09-18-2014, 08:09 AM   #1
mandoray
LQ Newbie
 
Registered: Sep 2014
Posts: 2

Rep: Reputation: Disabled
mmap slower than ioctl


I have written a driver that needs to access a PCI card's registers rapidly from a user application. This card provides a time stamp that is synchronized with other systems. The driver provides a mechanism to do this via an ioctl call, or by allowing the user to do a mmap and read the registers directly.

It appears that the ioctl call is faster and more consistent than reading the registers directly.

Any ideas why this is so?
 
Old 09-20-2014, 07:43 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Seems unlikely. Mmap is just creating a mapping in the process page tables to the PCI address. Both the kernel and the process have to do the same slow PCI access. The ioctl just has the extra call into the kernel. Is your CPU under heavy load at the time? Have you tried changing your process priority?
 
Old 09-22-2014, 05:37 AM   #3
mandoray
LQ Newbie
 
Registered: Sep 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
I thought so too!

It does seem like the mmaped I/O should be quicker than the ioctl, that's why I asked to see if others had seen this. The machine has 16 cores and nothing but Linux and a few background services running. It's pretty much a dedicated development machine. I am not sure what Linux does when PCI memory space is mapped to a process. Perhaps there is a page fault every time it is accessed.
 
Old 09-22-2014, 06:58 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
It may depend on the amount of memory actualy being mapped - mmap requires the addresses to be on a page boundary, and of a page size.

Not sure what happens when it is not, as the kernel may be emulating the access via page faults.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SUSE Linux 12.1 gets slower and slower henk32 SUSE / openSUSE 6 07-05-2012 10:52 AM
[SOLVED] LXDE suddenly getting slower and slower Aquarius_Girl Linux - Newbie 1 09-22-2010 05:22 AM
How to pass IOCTL arguments from usespace ioctl call devkpict Linux - Kernel 1 12-07-2007 06:45 PM
Why is Mandrake/KDE getting slower and slower? KWTm Mandriva 12 09-28-2004 09:43 PM
Internet connection becomes slower and slower. caesius_01 Linux - General 1 03-14-2004 02:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 02:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration