From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755337Ab3EVLJI (ORCPT ); Wed, 22 May 2013 07:09:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34677 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753055Ab3EVLJG (ORCPT ); Wed, 22 May 2013 07:09:06 -0400 Date: Wed, 22 May 2013 14:07:29 +0300 From: "Michael S. Tsirkin" To: Peter Zijlstra Cc: Arnd Bergmann , 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, 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 00/10] uaccess: better might_sleep/might_fault behavior Message-ID: <20130522110729.GB5643@redhat.com> References: <201305221125.36284.arnd@arndb.de> <20130522101916.GM18810@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130522101916.GM18810@twins.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 22, 2013 at 12:19:16PM +0200, Peter Zijlstra wrote: > On Wed, May 22, 2013 at 11:25:36AM +0200, Arnd Bergmann wrote: > > Calling might_fault() for every __get_user/__put_user is rather expensive > > because it turns what should be a single instruction (plus fixup) into an > > external function call. > > We could hide it all behind CONFIG_DEBUG_ATOMIC_SLEEP just like > might_sleep() is. I'm not sure there's a point to might_fault() when > might_sleep() is a NOP. The patch that you posted gets pretty close. E.g. I'm testing this now: +#define might_fault() do { \ + if (_might_fault()) \ + __might_sleep(__FILE__, __LINE__, 0); \ + might_resched(); \ +} while(0) So if might_sleep is a NOP, __might_sleep and might_resched are NOPs so compiler will optimize this all out. However, in a related thread, you pointed out that might_sleep is not a NOP if CONFIG_PREEMPT_VOLUNTARY is set, even without CONFIG_DEBUG_ATOMIC_SLEEP. Do you think we should drop the preemption point in might_fault? Only copy_XX_user? Only __copy_XXX_user ? -- MST From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCH v2 00/10] uaccess: better might_sleep/might_fault behavior Date: Wed, 22 May 2013 14:07:29 +0300 Message-ID: <20130522110729.GB5643@redhat.com> References: <201305221125.36284.arnd@arndb.de> <20130522101916.GM18810@twins.programming.kicks-ass.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20130522101916.GM18810@twins.programming.kicks-ass.net> Sender: owner-linux-mm@kvack.org To: Peter Zijlstra Cc: Arnd Bergmann , 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, 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@ List-Id: linux-arch.vger.kernel.org On Wed, May 22, 2013 at 12:19:16PM +0200, Peter Zijlstra wrote: > On Wed, May 22, 2013 at 11:25:36AM +0200, Arnd Bergmann wrote: > > Calling might_fault() for every __get_user/__put_user is rather expensive > > because it turns what should be a single instruction (plus fixup) into an > > external function call. > > We could hide it all behind CONFIG_DEBUG_ATOMIC_SLEEP just like > might_sleep() is. I'm not sure there's a point to might_fault() when > might_sleep() is a NOP. The patch that you posted gets pretty close. E.g. I'm testing this now: +#define might_fault() do { \ + if (_might_fault()) \ + __might_sleep(__FILE__, __LINE__, 0); \ + might_resched(); \ +} while(0) So if might_sleep is a NOP, __might_sleep and might_resched are NOPs so compiler will optimize this all out. However, in a related thread, you pointed out that might_sleep is not a NOP if CONFIG_PREEMPT_VOLUNTARY is set, even without CONFIG_DEBUG_ATOMIC_SLEEP. Do you think we should drop the preemption point in might_fault? Only copy_XX_user? Only __copy_XXX_user ? -- 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 (na3sys010amx189.postini.com [74.125.245.189]) by kanga.kvack.org (Postfix) with SMTP id 379766B00A1 for ; Wed, 22 May 2013 07:08:08 -0400 (EDT) Date: Wed, 22 May 2013 14:07:29 +0300 From: "Michael S. Tsirkin" Subject: Re: [PATCH v2 00/10] uaccess: better might_sleep/might_fault behavior Message-ID: <20130522110729.GB5643@redhat.com> References: <201305221125.36284.arnd@arndb.de> <20130522101916.GM18810@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130522101916.GM18810@twins.programming.kicks-ass.net> Sender: owner-linux-mm@kvack.org List-ID: To: Peter Zijlstra Cc: Arnd Bergmann , 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, 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 Wed, May 22, 2013 at 12:19:16PM +0200, Peter Zijlstra wrote: > On Wed, May 22, 2013 at 11:25:36AM +0200, Arnd Bergmann wrote: > > Calling might_fault() for every __get_user/__put_user is rather expensive > > because it turns what should be a single instruction (plus fixup) into an > > external function call. > > We could hide it all behind CONFIG_DEBUG_ATOMIC_SLEEP just like > might_sleep() is. I'm not sure there's a point to might_fault() when > might_sleep() is a NOP. The patch that you posted gets pretty close. E.g. I'm testing this now: +#define might_fault() do { \ + if (_might_fault()) \ + __might_sleep(__FILE__, __LINE__, 0); \ + might_resched(); \ +} while(0) So if might_sleep is a NOP, __might_sleep and might_resched are NOPs so compiler will optimize this all out. However, in a related thread, you pointed out that might_sleep is not a NOP if CONFIG_PREEMPT_VOLUNTARY is set, even without CONFIG_DEBUG_ATOMIC_SLEEP. Do you think we should drop the preemption point in might_fault? Only copy_XX_user? Only __copy_XXX_user ? -- 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 F37732C0087 for ; Wed, 22 May 2013 21:08:48 +1000 (EST) Date: Wed, 22 May 2013 14:07:29 +0300 From: "Michael S. Tsirkin" To: Peter Zijlstra Subject: Re: [PATCH v2 00/10] uaccess: better might_sleep/might_fault behavior Message-ID: <20130522110729.GB5643@redhat.com> References: <201305221125.36284.arnd@arndb.de> <20130522101916.GM18810@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <20130522101916.GM18810@twins.programming.kicks-ass.net> Cc: linux-m32r-ja@ml.linux-m32r.org, kvm@vger.kernel.org, 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 Wed, May 22, 2013 at 12:19:16PM +0200, Peter Zijlstra wrote: > On Wed, May 22, 2013 at 11:25:36AM +0200, Arnd Bergmann wrote: > > Calling might_fault() for every __get_user/__put_user is rather expensive > > because it turns what should be a single instruction (plus fixup) into an > > external function call. > > We could hide it all behind CONFIG_DEBUG_ATOMIC_SLEEP just like > might_sleep() is. I'm not sure there's a point to might_fault() when > might_sleep() is a NOP. The patch that you posted gets pretty close. E.g. I'm testing this now: +#define might_fault() do { \ + if (_might_fault()) \ + __might_sleep(__FILE__, __LINE__, 0); \ + might_resched(); \ +} while(0) So if might_sleep is a NOP, __might_sleep and might_resched are NOPs so compiler will optimize this all out. However, in a related thread, you pointed out that might_sleep is not a NOP if CONFIG_PREEMPT_VOLUNTARY is set, even without CONFIG_DEBUG_ATOMIC_SLEEP. Do you think we should drop the preemption point in might_fault? Only copy_XX_user? Only __copy_XXX_user ? -- MST From mboxrd@z Thu Jan 1 00:00:00 1970 From: mst@redhat.com (Michael S. Tsirkin) Date: Wed, 22 May 2013 14:07:29 +0300 Subject: [PATCH v2 00/10] uaccess: better might_sleep/might_fault behavior In-Reply-To: <20130522101916.GM18810@twins.programming.kicks-ass.net> References: <201305221125.36284.arnd@arndb.de> <20130522101916.GM18810@twins.programming.kicks-ass.net> Message-ID: <20130522110729.GB5643@redhat.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Wed, May 22, 2013 at 12:19:16PM +0200, Peter Zijlstra wrote: > On Wed, May 22, 2013 at 11:25:36AM +0200, Arnd Bergmann wrote: > > Calling might_fault() for every __get_user/__put_user is rather expensive > > because it turns what should be a single instruction (plus fixup) into an > > external function call. > > We could hide it all behind CONFIG_DEBUG_ATOMIC_SLEEP just like > might_sleep() is. I'm not sure there's a point to might_fault() when > might_sleep() is a NOP. The patch that you posted gets pretty close. E.g. I'm testing this now: +#define might_fault() do { \ + if (_might_fault()) \ + __might_sleep(__FILE__, __LINE__, 0); \ + might_resched(); \ +} while(0) So if might_sleep is a NOP, __might_sleep and might_resched are NOPs so compiler will optimize this all out. However, in a related thread, you pointed out that might_sleep is not a NOP if CONFIG_PREEMPT_VOLUNTARY is set, even without CONFIG_DEBUG_ATOMIC_SLEEP. Do you think we should drop the preemption point in might_fault? Only copy_XX_user? Only __copy_XXX_user ? -- MST