linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* kernel_lock() profiling results
@ 1999-05-23 14:30 Manfred Spraul
  1999-05-26 16:34 ` Stephen C. Tweedie
  0 siblings, 1 reply; 5+ messages in thread
From: Manfred Spraul @ 1999-05-23 14:30 UTC (permalink / raw)
  To: linux-kernel, linux-mm

I've written a small patch that measures the duration how long the
kernel-lock is owned.
The main results:
- compiling:
* nearly 60% of all callers release the lock after less than 1024 CPU
cycles.
* a few callers own the lock very long, e.g. sys_bdflush for more than
10 milliseconds (>0.01 seconds).
- serving web pages with apache:
* only 17% need less than 1024 CPU cycles
* 55% need less than 2048 CPU cycles.

The patch and a list of all functions which owned the lock for more then
1.5 milliseconds is at
http://www.colorfullife.com/manfreds/kernel_lock/


OTHO, 2048 cpu cycles is about as long as __cpu_user() needs for 700
bytes if source,dest are currently not in the cache (I've tested it
with a 16 MB move from user mode). The memmove will be even
slower with faster CPU's (i.e. with a higher cpu clock/bus clock
multiplier)

My question:
Shouldn't we change file_read_actor() [mm/filemap.c, the function which
copies data from the page cache to user mode]:
we could release the kernel lock if we copy more than 1024 bytes.
(we currently do that only if the user mode memory is not paged in.)

Manfred

--
To unsubscribe, send a message with 'unsubscribe linux-mm my@address'
in the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://humbolt.geo.uu.nl/Linux-MM/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: kernel_lock() profiling results
  1999-05-23 14:30 kernel_lock() profiling results Manfred Spraul
@ 1999-05-26 16:34 ` Stephen C. Tweedie
  1999-05-26 17:41   ` Manfred Spraul
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen C. Tweedie @ 1999-05-26 16:34 UTC (permalink / raw)
  To: masp0008; +Cc: linux-kernel, linux-mm, David S. Miller, Stephen Tweedie

Hi,

On Sun, 23 May 1999 16:30:52 +0200, Manfred Spraul
<manfreds@colorfullife.com> said:

> Shouldn't we change file_read_actor() [mm/filemap.c, the function which
> copies data from the page cache to user mode]:
> we could release the kernel lock if we copy more than 1024 bytes.
> (we currently do that only if the user mode memory is not paged in.)

	ftp://ftp.uk.linux.org/pub/linux/sct/performance

contains a patch Dave Miller and I put together to drop the kernel lock
during a number of key user mode copies.

--Stephen
--
To unsubscribe, send a message with 'unsubscribe linux-mm my@address'
in the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://humbolt.geo.uu.nl/Linux-MM/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: kernel_lock() profiling results
  1999-05-26 16:34 ` Stephen C. Tweedie
@ 1999-05-26 17:41   ` Manfred Spraul
  1999-05-26 19:22     ` Stephen C. Tweedie
  0 siblings, 1 reply; 5+ messages in thread
From: Manfred Spraul @ 1999-05-26 17:41 UTC (permalink / raw)
  To: Stephen C. Tweedie; +Cc: linux-kernel, linux-mm, David S. Miller

"Stephen C. Tweedie" wrote:
>         ftp://ftp.uk.linux.org/pub/linux/sct/performance
> 
> contains a patch Dave Miller and I put together to drop the kernel lock
> during a number of key user mode copies.

1) Andrea noticed that 'unlock_kernel()' only releases the kernel lock
if the lock was obtained once.
He added two new functions: one stores the current lock depth,
releases the lock and sets current->lock_depth =-1.
The other reverses that.

I think we need these functions:
* it's save to call the functions without the kernel_lock held.
* the unlock is effective for recursive calls.

2) Here's a excerpt from an email I wrote a few days ago:
> I've modified uaccess.h, and I have now a list of all functions which
> called copy_to/from_user() for more than 512 bytes (apache, make clean;
> make fs; find /usr/bin)
> 
> * read_file_actor()
> * ext2_file_write()
> * block_read()
> * copy_mount_options()  << really rare
> * proc_file_read()      << rare??
> * pipe_write()
> * pipe_read()
> * 2*vt_ioctl() << could be remote gdb.
> * tcp_do_sendmsg()
> * copy_strings()        << only during fork()?
> 
> Additionally, the following functions could also release the kernel
> lock:
> * padzero() in binfmt_elf:
>         This function clears up to 4096 bytes user memory.
>         The average should be 2048.
> * update_vm_mapping():
>         the function can wait in wait_on_page(), we should break nothing
> * get_free_page():
>         if GFP_WAIT, for memset(,0,PAGE_SIZE)
I didn't use NFS, knfsd, other fs except ext2.

--
	Manfred
--
To unsubscribe, send a message with 'unsubscribe linux-mm my@address'
in the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://humbolt.geo.uu.nl/Linux-MM/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: kernel_lock() profiling results
  1999-05-26 17:41   ` Manfred Spraul
@ 1999-05-26 19:22     ` Stephen C. Tweedie
  1999-05-29  0:45       ` Andrea Arcangeli
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen C. Tweedie @ 1999-05-26 19:22 UTC (permalink / raw)
  To: masp0008; +Cc: Stephen C. Tweedie, linux-kernel, linux-mm, David S. Miller

Hi,

On Wed, 26 May 1999 19:41:11 +0200, Manfred Spraul
<manfreds@colorfullife.com> said:

> 1) Andrea noticed that 'unlock_kernel()' only releases the kernel lock
> if the lock was obtained once.

Yes, but in all the places we are currently doing the copy_*_user, we
only hold the lock once.  In general we might want to do a true
save/restore of lock_depth for a new, self-unlocking copy_*_user, but
right now the droplock diffs still do the right thing the simple way.

--Stephen
--
To unsubscribe, send a message with 'unsubscribe linux-mm my@address'
in the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://humbolt.geo.uu.nl/Linux-MM/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: kernel_lock() profiling results
  1999-05-26 19:22     ` Stephen C. Tweedie
@ 1999-05-29  0:45       ` Andrea Arcangeli
  0 siblings, 0 replies; 5+ messages in thread
From: Andrea Arcangeli @ 1999-05-29  0:45 UTC (permalink / raw)
  To: Stephen C. Tweedie; +Cc: masp0008, linux-kernel, linux-mm, David S. Miller

On Wed, 26 May 1999, Stephen C. Tweedie wrote:

>save/restore of lock_depth for a new, self-unlocking copy_*_user, but
>right now the droplock diffs still do the right thing the simple way.

I wouldn't call it the "right thing". It's also not simpler according to
me since to make sure that the unlock_kernel is really dropping the
kernel_flag spinlock you must check all entry paths and verify that
lock_depth is 0 at such time.

Andrea Arcangeli

--
To unsubscribe, send a message with 'unsubscribe linux-mm my@address'
in the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://humbolt.geo.uu.nl/Linux-MM/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1999-05-29  0:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-23 14:30 kernel_lock() profiling results Manfred Spraul
1999-05-26 16:34 ` Stephen C. Tweedie
1999-05-26 17:41   ` Manfred Spraul
1999-05-26 19:22     ` Stephen C. Tweedie
1999-05-29  0:45       ` Andrea Arcangeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox