[lkml]   [1996]   [Oct]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectCode optimization in sounddriver (Was: Naming conflict in sound drivers)
Date writes:
> My limited C programming skills are puzzled also by:
> dmasound.c:736: *p++ = get_user(userPtr++) ^ 0x80;

This line
1) reads from user space the memory location that userPtr points to,
2) increments userPtr by one byte so that it points to the next data
byte to be read,
3) flips the topmost bit, hereby converting from an unsigned number
to a signed one,
4) stores the result to kernel space in the memory location that p
points to,
5) increments p by one byte so that is points to the next data byte
to be written.

As this code is evaluated in a loop, it effectively copies a buffer
from user space to kernel space while converting the data
format. There is a more advanced variation of this code, a few lines
down. It performs the same conversion for two bytes at a time.

In a previous posting, Linus wrote that he discourages code that calls
get_user or put_user in a tight loop. So, it might be possible to
improve this copy/conversion loop by first calling copy_from_user for
the entire data block and then performing the conversion in place. Any
comments as to the expected performance improvement?


 \ /
  Last update: 2005-03-22 13:38    [W:0.186 / U:0.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site