From patchwork Wed May 22 09:45:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 10955383 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E8F676 for ; Wed, 22 May 2019 09:47:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EE0D28B35 for ; Wed, 22 May 2019 09:47:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82C3128B37; Wed, 22 May 2019 09:47:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1C92E28B35 for ; Wed, 22 May 2019 09:47:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hTNou-0006WW-Rt; Wed, 22 May 2019 09:46:00 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hTNot-0006Vo-Vl for xen-devel@lists.xenproject.org; Wed, 22 May 2019 09:46:00 +0000 X-Inumbo-ID: 63e2fc0c-7c76-11e9-9cbe-4347524bb1c0 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 63e2fc0c-7c76-11e9-9cbe-4347524bb1c0; Wed, 22 May 2019 09:45:54 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2ABA5AF11; Wed, 22 May 2019 09:45:53 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Wed, 22 May 2019 11:45:47 +0200 Message-Id: <20190522094549.28397-2-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190522094549.28397-1-jgross@suse.com> References: <20190522094549.28397-1-jgross@suse.com> Subject: [Xen-devel] [PATCH 1/3] xen: drop in_atomic() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently there is only one user of in_atomic(), and that is in an #ifdef 0 section. This has been so since Xen 4.1, so chances are rather slim we suddenly want to enable it again. Dropping in_atomic() will remove the last user of preempt_count() in non-debug builds enabling further optimizations. Signed-off-by: Juergen Gross Reviewed-by: Andrew Cooper --- xen/arch/x86/hvm/hvm.c | 16 ---------------- xen/common/preempt.c | 5 ----- xen/include/xen/preempt.h | 2 -- 3 files changed, 23 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 8993c2aa57..7b36765b97 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -3185,22 +3185,6 @@ static enum hvm_translation_result __hvm_copy( ASSERT(is_hvm_vcpu(v)); - /* - * XXX Disable for 4.1.0: PV-on-HVM drivers will do grant-table ops - * such as query_size. Grant-table code currently does copy_to/from_guest - * accesses under the big per-domain lock, which this test would disallow. - * The test is not needed until we implement sleeping-on-waitqueue when - * we access a paged-out frame, and that's post 4.1.0 now. - */ -#if 0 - /* - * If the required guest memory is paged out, this function may sleep. - * Hence we bail immediately if called from atomic context. - */ - if ( in_atomic() ) - return HVMTRANS_unhandleable; -#endif - while ( todo > 0 ) { enum hvm_translation_result res; diff --git a/xen/common/preempt.c b/xen/common/preempt.c index 3b4178fd44..20913e20d3 100644 --- a/xen/common/preempt.c +++ b/xen/common/preempt.c @@ -25,11 +25,6 @@ DEFINE_PER_CPU(unsigned int, __preempt_count); -bool_t in_atomic(void) -{ - return preempt_count() || in_irq() || !local_irq_is_enabled(); -} - #ifndef NDEBUG void ASSERT_NOT_IN_ATOMIC(void) { diff --git a/xen/include/xen/preempt.h b/xen/include/xen/preempt.h index bef83135a1..f715ca09bc 100644 --- a/xen/include/xen/preempt.h +++ b/xen/include/xen/preempt.h @@ -26,8 +26,6 @@ DECLARE_PER_CPU(unsigned int, __preempt_count); preempt_count()--; \ } while (0) -bool_t in_atomic(void); - #ifndef NDEBUG void ASSERT_NOT_IN_ATOMIC(void); #else From patchwork Wed May 22 09:45:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 10955387 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E6D6814C0 for ; Wed, 22 May 2019 09:47:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D85A928B36 for ; Wed, 22 May 2019 09:47:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBE0C28B3B; Wed, 22 May 2019 09:47:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 822FD28B36 for ; Wed, 22 May 2019 09:47:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hTNos-0006Vi-I4; Wed, 22 May 2019 09:45:58 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hTNoq-0006VJ-A3 for xen-devel@lists.xenproject.org; Wed, 22 May 2019 09:45:56 +0000 X-Inumbo-ID: 6402ac35-7c76-11e9-8980-bc764e045a96 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 6402ac35-7c76-11e9-8980-bc764e045a96; Wed, 22 May 2019 09:45:54 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 714D6AF21; Wed, 22 May 2019 09:45:53 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Wed, 22 May 2019 11:45:48 +0200 Message-Id: <20190522094549.28397-3-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190522094549.28397-1-jgross@suse.com> References: <20190522094549.28397-1-jgross@suse.com> Subject: [Xen-devel] [PATCH 2/3] xen: drop preempt_count() for non-debug builds X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP preempt_count() and the associated per-cpu variable __preempt_count are tested in debug build only. So drop them for non-debug builds. Signed-off-by: Juergen Gross Reviewed-by: Andrew Cooper , ideally with the --- xen/common/preempt.c | 2 +- xen/include/xen/preempt.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/xen/common/preempt.c b/xen/common/preempt.c index 20913e20d3..3077c51d52 100644 --- a/xen/common/preempt.c +++ b/xen/common/preempt.c @@ -23,9 +23,9 @@ #include #include +#ifndef NDEBUG DEFINE_PER_CPU(unsigned int, __preempt_count); -#ifndef NDEBUG void ASSERT_NOT_IN_ATOMIC(void) { ASSERT(!preempt_count()); diff --git a/xen/include/xen/preempt.h b/xen/include/xen/preempt.h index f715ca09bc..0bf49cc979 100644 --- a/xen/include/xen/preempt.h +++ b/xen/include/xen/preempt.h @@ -12,6 +12,8 @@ #include #include +#ifndef NDEBUG + DECLARE_PER_CPU(unsigned int, __preempt_count); #define preempt_count() (this_cpu(__preempt_count)) @@ -26,9 +28,11 @@ DECLARE_PER_CPU(unsigned int, __preempt_count); preempt_count()--; \ } while (0) -#ifndef NDEBUG void ASSERT_NOT_IN_ATOMIC(void); + #else +#define preempt_disable() barrier(); +#define preempt_enable() barrier(); #define ASSERT_NOT_IN_ATOMIC() ((void)0) #endif From patchwork Wed May 22 09:45:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 10955385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9611576 for ; Wed, 22 May 2019 09:47:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86C3728B35 for ; Wed, 22 May 2019 09:47:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B1F228B37; Wed, 22 May 2019 09:47:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1C0D028B35 for ; Wed, 22 May 2019 09:47:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hTNos-0006Vc-8b; Wed, 22 May 2019 09:45:58 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hTNoq-0006VI-A0 for xen-devel@lists.xenproject.org; Wed, 22 May 2019 09:45:56 +0000 X-Inumbo-ID: 642b236b-7c76-11e9-8980-bc764e045a96 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 642b236b-7c76-11e9-8980-bc764e045a96; Wed, 22 May 2019 09:45:54 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B27E9AF25; Wed, 22 May 2019 09:45:53 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Wed, 22 May 2019 11:45:49 +0200 Message-Id: <20190522094549.28397-4-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190522094549.28397-1-jgross@suse.com> References: <20190522094549.28397-1-jgross@suse.com> Subject: [Xen-devel] [PATCH 3/3] xen: build common/preempt.c only with CONFIG_DEBUG X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP There is nothing left in common/preempt.c in non-debug builds. Signed-off-by: Juergen Gross --- xen/common/Makefile | 2 +- xen/common/preempt.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/xen/common/Makefile b/xen/common/Makefile index 33d03b862f..d6576a3fc3 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -30,7 +30,7 @@ obj-y += notifier.o obj-y += page_alloc.o obj-$(CONFIG_HAS_PDX) += pdx.o obj-$(CONFIG_PERF_COUNTERS) += perfc.o -obj-y += preempt.o +obj-$(CONFIG_DEBUG) += preempt.o obj-y += random.o obj-y += rangeset.o obj-y += radix-tree.o diff --git a/xen/common/preempt.c b/xen/common/preempt.c index 3077c51d52..8bb099e8e8 100644 --- a/xen/common/preempt.c +++ b/xen/common/preempt.c @@ -23,7 +23,6 @@ #include #include -#ifndef NDEBUG DEFINE_PER_CPU(unsigned int, __preempt_count); void ASSERT_NOT_IN_ATOMIC(void) @@ -32,4 +31,3 @@ void ASSERT_NOT_IN_ATOMIC(void) ASSERT(!in_irq()); ASSERT(local_irq_is_enabled()); } -#endif