From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754730Ab3ESUjz (ORCPT ); Sun, 19 May 2013 16:39:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30390 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752000Ab3ESUjx (ORCPT ); Sun, 19 May 2013 16:39:53 -0400 Date: Sun, 19 May 2013 23:35:51 +0300 From: "Michael S. Tsirkin" To: Steven Rostedt Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Catalin Marinas , Will Deacon , David Howells , Hirokazu Takata , Michal Simek , Koichi Yasutake , Benjamin Herrenschmidt , Paul Mackerras , Chris Metcalf , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Arnd Bergmann , linux-arm-kernel@lists.infradead.org, linux-m32r@ml.linux-m32r.org, linux-m32r-ja@ml.linux-m32r.org, microblaze-uclinux@itee.uq.edu.au, linux-am33-list@redhat.com, linuxppc-dev@lists.ozlabs.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org Subject: Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep Message-ID: <20130519203551.GA27708@redhat.com> References: <1f85dc8e6a0149677563a2dfb4cef9a9c7eaa391.1368702323.git.mst@redhat.com> <20130516184041.GP19669@dyad.programming.kicks-ass.net> <20130519093526.GD19883@redhat.com> <1368966844.6828.111.camel@gandalf.local.home> <20130519133418.GA24381@redhat.com> <1368979579.6828.114.camel@gandalf.local.home> <20130519164009.GA2434@redhat.com> <1368995002.6828.117.camel@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1368995002.6828.117.camel@gandalf.local.home> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 19, 2013 at 04:23:22PM -0400, Steven Rostedt wrote: > On Sun, 2013-05-19 at 19:40 +0300, Michael S. Tsirkin wrote: > > > OK I get it. So let me correct myself. The simple code > > that does something like this under a spinlock: > > > preempt_disable > > > pagefault_disable > > > error = copy_to_user > > > pagefault_enable > > > preempt_enable > > > > > is not doing anything wrong and should not get a warning, > > as long as error is handled correctly later. > > Right? > > I came in mid thread and I don't know the context. The context is that I want to change might_fault from might_sleep to might_sleep_if(!in_atomic()) so that above does not trigger warnings even with CONFIG_DEBUG_ATOMIC_SLEEP enabled. > Anyway, the above > looks to me as you just don't want to sleep. Exactly. upstream we can just do pagefault_disable but to make this code -rt ready it's best to do preempt_disable as well. > If you try to copy data to > user space that happens not to be currently mapped for any reason, you > will get an error. Even if the address space is completely valid. Is > that what you want? > > -- Steve > Yes, this is by design. We detect that and bounce the work to a thread outside any locks. Thanks, -- MST From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep Date: Sun, 19 May 2013 23:35:51 +0300 Message-ID: <20130519203551.GA27708@redhat.com> References: <1f85dc8e6a0149677563a2dfb4cef9a9c7eaa391.1368702323.git.mst@redhat.com> <20130516184041.GP19669@dyad.programming.kicks-ass.net> <20130519093526.GD19883@redhat.com> <1368966844.6828.111.camel@gandalf.local.home> <20130519133418.GA24381@redhat.com> <1368979579.6828.114.camel@gandalf.local.home> <20130519164009.GA2434@redhat.com> <1368995002.6828.117.camel@gandalf.local.home> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1368995002.6828.117.camel@gandalf.local.home> Sender: owner-linux-mm@kvack.org To: Steven Rostedt Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Catalin Marinas , Will Deacon , David Howells , Hirokazu Takata , Michal Simek , Koichi Yasutake , Benjamin Herrenschmidt , Paul Mackerras , Chris Metcalf , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Arnd Bergmann , linux-arm-kernel@lists.infradead.org, linux-m32r@ml.linux-m32r.org, linux-m32r-ja@ml.linux-m32r.org, microblaze-uclinux@itee.uq.edu.au, linux-am33-list@redhat.com, linuxppc-dev@lists.ozlabs.org, linux-arch@vg List-Id: linux-arch.vger.kernel.org On Sun, May 19, 2013 at 04:23:22PM -0400, Steven Rostedt wrote: > On Sun, 2013-05-19 at 19:40 +0300, Michael S. Tsirkin wrote: > > > OK I get it. So let me correct myself. The simple code > > that does something like this under a spinlock: > > > preempt_disable > > > pagefault_disable > > > error = copy_to_user > > > pagefault_enable > > > preempt_enable > > > > > is not doing anything wrong and should not get a warning, > > as long as error is handled correctly later. > > Right? > > I came in mid thread and I don't know the context. The context is that I want to change might_fault from might_sleep to might_sleep_if(!in_atomic()) so that above does not trigger warnings even with CONFIG_DEBUG_ATOMIC_SLEEP enabled. > Anyway, the above > looks to me as you just don't want to sleep. Exactly. upstream we can just do pagefault_disable but to make this code -rt ready it's best to do preempt_disable as well. > If you try to copy data to > user space that happens not to be currently mapped for any reason, you > will get an error. Even if the address space is completely valid. Is > that what you want? > > -- Steve > Yes, this is by design. We detect that and bounce the work to a thread outside any locks. Thanks, -- MST -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx103.postini.com [74.125.245.103]) by kanga.kvack.org (Postfix) with SMTP id C79AF6B0075 for ; Sun, 19 May 2013 16:39:00 -0400 (EDT) Date: Sun, 19 May 2013 23:35:51 +0300 From: "Michael S. Tsirkin" Subject: Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep Message-ID: <20130519203551.GA27708@redhat.com> References: <1f85dc8e6a0149677563a2dfb4cef9a9c7eaa391.1368702323.git.mst@redhat.com> <20130516184041.GP19669@dyad.programming.kicks-ass.net> <20130519093526.GD19883@redhat.com> <1368966844.6828.111.camel@gandalf.local.home> <20130519133418.GA24381@redhat.com> <1368979579.6828.114.camel@gandalf.local.home> <20130519164009.GA2434@redhat.com> <1368995002.6828.117.camel@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1368995002.6828.117.camel@gandalf.local.home> Sender: owner-linux-mm@kvack.org List-ID: To: Steven Rostedt Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Catalin Marinas , Will Deacon , David Howells , Hirokazu Takata , Michal Simek , Koichi Yasutake , Benjamin Herrenschmidt , Paul Mackerras , Chris Metcalf , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Arnd Bergmann , linux-arm-kernel@lists.infradead.org, linux-m32r@ml.linux-m32r.org, linux-m32r-ja@ml.linux-m32r.org, microblaze-uclinux@itee.uq.edu.au, linux-am33-list@redhat.com, linuxppc-dev@lists.ozlabs.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org On Sun, May 19, 2013 at 04:23:22PM -0400, Steven Rostedt wrote: > On Sun, 2013-05-19 at 19:40 +0300, Michael S. Tsirkin wrote: > > > OK I get it. So let me correct myself. The simple code > > that does something like this under a spinlock: > > > preempt_disable > > > pagefault_disable > > > error = copy_to_user > > > pagefault_enable > > > preempt_enable > > > > > is not doing anything wrong and should not get a warning, > > as long as error is handled correctly later. > > Right? > > I came in mid thread and I don't know the context. The context is that I want to change might_fault from might_sleep to might_sleep_if(!in_atomic()) so that above does not trigger warnings even with CONFIG_DEBUG_ATOMIC_SLEEP enabled. > Anyway, the above > looks to me as you just don't want to sleep. Exactly. upstream we can just do pagefault_disable but to make this code -rt ready it's best to do preempt_disable as well. > If you try to copy data to > user space that happens not to be currently mapped for any reason, you > will get an error. Even if the address space is completely valid. Is > that what you want? > > -- Steve > Yes, this is by design. We detect that and bounce the work to a thread outside any locks. Thanks, -- MST -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by ozlabs.org (Postfix) with ESMTP id 625E22C007E for ; Mon, 20 May 2013 06:39:38 +1000 (EST) Date: Sun, 19 May 2013 23:35:51 +0300 From: "Michael S. Tsirkin" To: Steven Rostedt Subject: Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep Message-ID: <20130519203551.GA27708@redhat.com> References: <1f85dc8e6a0149677563a2dfb4cef9a9c7eaa391.1368702323.git.mst@redhat.com> <20130516184041.GP19669@dyad.programming.kicks-ass.net> <20130519093526.GD19883@redhat.com> <1368966844.6828.111.camel@gandalf.local.home> <20130519133418.GA24381@redhat.com> <1368979579.6828.114.camel@gandalf.local.home> <20130519164009.GA2434@redhat.com> <1368995002.6828.117.camel@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <1368995002.6828.117.camel@gandalf.local.home> Cc: linux-m32r-ja@ml.linux-m32r.org, kvm@vger.kernel.org, Peter Zijlstra , Catalin Marinas , Will Deacon , David Howells , linux-mm@kvack.org, Paul Mackerras , "H. Peter Anvin" , linux-arch@vger.kernel.org, linux-am33-list@redhat.com, Hirokazu Takata , x86@kernel.org, Ingo Molnar , Arnd Bergmann , microblaze-uclinux@itee.uq.edu.au, Chris Metcalf , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Michal Simek , linux-m32r@ml.linux-m32r.org, linux-kernel@vger.kernel.org, Koichi Yasutake , linuxppc-dev@lists.ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Sun, May 19, 2013 at 04:23:22PM -0400, Steven Rostedt wrote: > On Sun, 2013-05-19 at 19:40 +0300, Michael S. Tsirkin wrote: > > > OK I get it. So let me correct myself. The simple code > > that does something like this under a spinlock: > > > preempt_disable > > > pagefault_disable > > > error = copy_to_user > > > pagefault_enable > > > preempt_enable > > > > > is not doing anything wrong and should not get a warning, > > as long as error is handled correctly later. > > Right? > > I came in mid thread and I don't know the context. The context is that I want to change might_fault from might_sleep to might_sleep_if(!in_atomic()) so that above does not trigger warnings even with CONFIG_DEBUG_ATOMIC_SLEEP enabled. > Anyway, the above > looks to me as you just don't want to sleep. Exactly. upstream we can just do pagefault_disable but to make this code -rt ready it's best to do preempt_disable as well. > If you try to copy data to > user space that happens not to be currently mapped for any reason, you > will get an error. Even if the address space is completely valid. Is > that what you want? > > -- Steve > Yes, this is by design. We detect that and bounce the work to a thread outside any locks. Thanks, -- MST From mboxrd@z Thu Jan 1 00:00:00 1970 From: mst@redhat.com (Michael S. Tsirkin) Date: Sun, 19 May 2013 23:35:51 +0300 Subject: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep In-Reply-To: <1368995002.6828.117.camel@gandalf.local.home> References: <1f85dc8e6a0149677563a2dfb4cef9a9c7eaa391.1368702323.git.mst@redhat.com> <20130516184041.GP19669@dyad.programming.kicks-ass.net> <20130519093526.GD19883@redhat.com> <1368966844.6828.111.camel@gandalf.local.home> <20130519133418.GA24381@redhat.com> <1368979579.6828.114.camel@gandalf.local.home> <20130519164009.GA2434@redhat.com> <1368995002.6828.117.camel@gandalf.local.home> Message-ID: <20130519203551.GA27708@redhat.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Sun, May 19, 2013 at 04:23:22PM -0400, Steven Rostedt wrote: > On Sun, 2013-05-19 at 19:40 +0300, Michael S. Tsirkin wrote: > > > OK I get it. So let me correct myself. The simple code > > that does something like this under a spinlock: > > > preempt_disable > > > pagefault_disable > > > error = copy_to_user > > > pagefault_enable > > > preempt_enable > > > > > is not doing anything wrong and should not get a warning, > > as long as error is handled correctly later. > > Right? > > I came in mid thread and I don't know the context. The context is that I want to change might_fault from might_sleep to might_sleep_if(!in_atomic()) so that above does not trigger warnings even with CONFIG_DEBUG_ATOMIC_SLEEP enabled. > Anyway, the above > looks to me as you just don't want to sleep. Exactly. upstream we can just do pagefault_disable but to make this code -rt ready it's best to do preempt_disable as well. > If you try to copy data to > user space that happens not to be currently mapped for any reason, you > will get an error. Even if the address space is completely valid. Is > that what you want? > > -- Steve > Yes, this is by design. We detect that and bounce the work to a thread outside any locks. Thanks, -- MST