From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Nick Piggin <npiggin@suse.de>,
Linux Memory Management <linux-mm@kvack.org>,
Linux Kernel <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>,
David Howells <dhowells@redhat.com>, Ingo Molnar <mingo@elte.hu>
Subject: pagefault_disable (was Re: [patch 6/6] mm: fix pagecache write deadlocks)
Date: Tue, 17 Oct 2006 01:24:01 +1000 [thread overview]
Message-ID: <4533A411.2020207@yahoo.com.au> (raw)
In-Reply-To: <1160928835.5230.41.camel@lappy>
(trimming cc list)
Peter Zijlstra wrote:
> On Sun, 2006-10-15 at 17:57 +0200, Nick Piggin wrote:
>>Hmm, but you may not be doing a copy*user within the kmap. And you may
>>want an atomic copy*user not within a kmap (maybe).
>>
>>I think it really would be more logical to do it in a wrapper function
>>pagefault_disable() pagefault_enable()? ;)
>
>
> I did that one first, but then noticed that most non trivial kmap_atomic
> implementations already did the inc_preempt_count()/dec_preempt_count()
> thing (except frv which did preempt_disable()/preempt_enable() ?)
>
> Anyway, here goes:
>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
I think this is a good approach. The missed preempt checks could easily
have been causing scheduling delays because the usercopy can take up a
lot of kernel time.
I don't know that the function should go in filemap.h... uaccess.h seems
more appropriate, and had thought the pagefault_disable() be calle
directly from within the copy_*_user_inatomic functions themselves, not
the filemap helper.
Also, the rest of the kernel tree (mainly uaccess and futexes) should be
converted ;)
> Index: linux-2.6/mm/filemap.h
> ===================================================================
> --- linux-2.6.orig/mm/filemap.h 2006-10-14 20:20:20.000000000 +0200
> +++ linux-2.6/mm/filemap.h 2006-10-15 17:17:45.000000000 +0200
> @@ -21,6 +21,22 @@ __filemap_copy_from_user_iovec_inatomic(
> size_t bytes);
>
> /*
> + * By increasing the preempt_count we make sure the arch preempt
> + * handler bails out early, before taking any locks, so that the copy
> + * operation gets terminated early.
> + */
> +pagefault_static inline void disable(void)
> +{
> + inc_preempt_count();
> +}
> +
> +pagefault_static inline void enable(void)
> +{
> + dec_preempt_count();
> + preempt_check_resched();
> +}
Interesting prototype ;)
--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com
WARNING: multiple messages have this Message-ID (diff)
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Nick Piggin <npiggin@suse.de>,
Linux Memory Management <linux-mm@kvack.org>,
Linux Kernel <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>,
David Howells <dhowells@redhat.com>, Ingo Molnar <mingo@elte.hu>
Subject: pagefault_disable (was Re: [patch 6/6] mm: fix pagecache write deadlocks)
Date: Tue, 17 Oct 2006 01:24:01 +1000 [thread overview]
Message-ID: <4533A411.2020207@yahoo.com.au> (raw)
In-Reply-To: <1160928835.5230.41.camel@lappy>
(trimming cc list)
Peter Zijlstra wrote:
> On Sun, 2006-10-15 at 17:57 +0200, Nick Piggin wrote:
>>Hmm, but you may not be doing a copy*user within the kmap. And you may
>>want an atomic copy*user not within a kmap (maybe).
>>
>>I think it really would be more logical to do it in a wrapper function
>>pagefault_disable() pagefault_enable()? ;)
>
>
> I did that one first, but then noticed that most non trivial kmap_atomic
> implementations already did the inc_preempt_count()/dec_preempt_count()
> thing (except frv which did preempt_disable()/preempt_enable() ?)
>
> Anyway, here goes:
>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
I think this is a good approach. The missed preempt checks could easily
have been causing scheduling delays because the usercopy can take up a
lot of kernel time.
I don't know that the function should go in filemap.h... uaccess.h seems
more appropriate, and had thought the pagefault_disable() be calle
directly from within the copy_*_user_inatomic functions themselves, not
the filemap helper.
Also, the rest of the kernel tree (mainly uaccess and futexes) should be
converted ;)
> Index: linux-2.6/mm/filemap.h
> ===================================================================
> --- linux-2.6.orig/mm/filemap.h 2006-10-14 20:20:20.000000000 +0200
> +++ linux-2.6/mm/filemap.h 2006-10-15 17:17:45.000000000 +0200
> @@ -21,6 +21,22 @@ __filemap_copy_from_user_iovec_inatomic(
> size_t bytes);
>
> /*
> + * By increasing the preempt_count we make sure the arch preempt
> + * handler bails out early, before taking any locks, so that the copy
> + * operation gets terminated early.
> + */
> +pagefault_static inline void disable(void)
> +{
> + inc_preempt_count();
> +}
> +
> +pagefault_static inline void enable(void)
> +{
> + dec_preempt_count();
> + preempt_check_resched();
> +}
Interesting prototype ;)
--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2006-10-16 15:24 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-13 16:43 [rfc] buffered write deadlock fix Nick Piggin
2006-10-13 16:43 ` Nick Piggin
2006-10-13 16:44 ` [patch 1/6] mm: revert "generic_file_buffered_write(): handle zero length iovec segments" Nick Piggin
2006-10-13 16:44 ` Nick Piggin, Andrew Morton
2006-10-13 16:44 ` [patch 2/6] mm: revert "generic_file_buffered_write(): deadlock on vectored write" Nick Piggin
2006-10-13 16:44 ` Nick Piggin, Andrew Morton
2006-10-13 16:44 ` [patch 3/6] mm: generic_file_buffered_write cleanup Nick Piggin
2006-10-13 16:44 ` Nick Piggin, Andrew Morton
2006-10-13 16:44 ` [patch 4/6] mm: comment mmap_sem / lock_page lockorder Nick Piggin
2006-10-13 16:44 ` Nick Piggin
2006-10-13 16:44 ` [patch 5/6] mm: debug write deadlocks Nick Piggin
2006-10-13 16:44 ` Nick Piggin
2006-10-13 16:44 ` [patch 6/6] mm: fix pagecache " Nick Piggin
2006-10-13 16:44 ` Nick Piggin, Andrew Morton
2006-10-13 22:14 ` Andrew Morton
2006-10-13 22:14 ` Andrew Morton
2006-10-14 4:19 ` Nick Piggin
2006-10-14 4:19 ` Nick Piggin
2006-10-14 4:30 ` Nick Piggin
2006-10-14 4:30 ` Nick Piggin
2006-10-15 11:35 ` Peter Zijlstra
2006-10-15 11:35 ` Peter Zijlstra
2006-10-14 5:04 ` Nick Piggin
2006-10-14 5:04 ` Nick Piggin
2006-10-15 11:37 ` Peter Zijlstra
2006-10-15 11:37 ` Peter Zijlstra
2006-10-15 11:56 ` Nick Piggin
2006-10-15 11:56 ` Nick Piggin
2006-10-15 13:51 ` Peter Zijlstra
2006-10-15 13:51 ` Peter Zijlstra
2006-10-15 14:19 ` SPAM: " Nick Piggin
2006-10-15 14:19 ` Nick Piggin
2006-10-15 15:47 ` Peter Zijlstra
2006-10-15 15:47 ` Peter Zijlstra
2006-10-15 15:57 ` RRe: " Nick Piggin
2006-10-15 15:57 ` Nick Piggin
2006-10-15 16:13 ` Peter Zijlstra
2006-10-15 16:13 ` Peter Zijlstra
2006-10-16 15:24 ` Nick Piggin [this message]
2006-10-16 15:24 ` pagefault_disable (was Re: [patch 6/6] mm: fix pagecache write deadlocks) Nick Piggin
2006-10-16 16:05 ` Peter Zijlstra
2006-10-16 16:05 ` Peter Zijlstra
2006-10-16 16:12 ` Nick Piggin
2006-10-16 16:12 ` Nick Piggin
2006-10-18 14:25 ` [patch 6/6] mm: fix pagecache write deadlocks Chris Mason
2006-10-18 14:25 ` Chris Mason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4533A411.2020207@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@osdl.org \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@elte.hu \
--cc=npiggin@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.