From patchwork Fri Feb 10 16:19:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 9567075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9E15B601C3 for ; Fri, 10 Feb 2017 16:21:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A283284CE for ; Fri, 10 Feb 2017 16:21:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B750285A5; Fri, 10 Feb 2017 16:21:52 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 23682284CE for ; Fri, 10 Feb 2017 16:21:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ccDvB-0002z7-DY; Fri, 10 Feb 2017 16:19:41 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ccDv9-0002z0-NK for xen-devel@lists.xenproject.org; Fri, 10 Feb 2017 16:19:39 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 25/B0-31649-A18ED985; Fri, 10 Feb 2017 16:19:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJIsWRWlGSWpSXmKPExsXiaHS5VVfqxdw Ig0OPhSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozrLVeYC7bzVjw7sou9gXEHdxcjFweLwAk2 iU0f/7GAOEICtxkl+rsOMEI4jYwSfdePsXYxcgKVqUr8mnaMrYuRg4NNQFviWocPSFhEQEWi4 +0PNpB6ZoFeVondS++zgSSEBWIk1vZsB+vlFXCWmHh3DSOILSTgKHGh+xAjRFxQ4uTMJywgNr OAlsSNfy+ZQOYzC0hLLP/HARLmFHCSuHb2J9gYUQE1ia7nc9gnMPLPQtI9C0n3LITuBYzMqxj Vi1OLylKLdM30kooy0zNKchMzc3QNDYz1clOLixPTU3MSk4r1kvNzNzECg7CegYFxB+OVNudD jJIcTEqivAKn50YI8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuCVfw6UEyxKTU+tSMvMAcYDTFqCg 0dJhPfiU6A0b3FBYm5xZjpE6hSjopQ474lnQAkBkERGaR5cGywGLzHKSgnzMjIwMAjxFKQW5W aWoMq/YhTnYFQS5n0EMoUnM68EbvoroMVMQItdH4AtLklESEk1MD7wMUpeaLRQk6H05uH1qr3 WRmvXzoxZyLJbKmDmq7Pp8leO3yy6HKO1KurTte1qs9cuOb96r0P9bokVriqLjhdcO244bcWZ 6OTtbWueFLLfdirZNb1pvsBM3fs/QvM3TPLwFzpYbxmoJBLAfS7Z6M6uhZf2OJTynq3xPRh/7 eCfaUt+vNqQVzlJiaU4I9FQi7moOBEARRGgIrwCAAA= X-Env-Sender: peterz@infradead.org X-Msg-Ref: server-4.tower-31.messagelabs.com!1486743576!26922455!1 X-Originating-IP: [65.50.211.133] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54194 invoked from network); 10 Feb 2017 16:19:38 -0000 Received: from bombadil.infradead.org (HELO bombadil.infradead.org) (65.50.211.133) by server-4.tower-31.messagelabs.com with AES256-GCM-SHA384 encrypted SMTP; 10 Feb 2017 16:19:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jxcwsyDnSK7QBF/emxUoo6W3sQFsNvvKBpKAueTaJSs=; b=hzuF11PIa9L4E2o89bXGtIHqp SlSuYuBn/BcMYENYTOq4lG7T054HLjIUFBWoPSs2xo4nDxXdwCH++8SFWO8uvP5lr3DNYw8SrCPkV sqR5AhNCj63b5gFeIAesTed6uTN+J21wjS1C7h60AXIIZej8vt9UwKNNzzwi4bxoIOAsHHay69tdb RtHjLhIB+iBX61FEL/U0GqLCjW98qym4/eJ0E5NF61jyOUQACPHV9KPokAYcgXKq27GNEQGNvpF8o dbHL2dc8S9T2mzwBrPcMxoOrGSmDFX2/bugRcjrluo/PQ6jL5w2PPkkVzIL+9ZD9ZHYfH/k7eqMjs ScObanPcw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=twins.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1ccDv0-0003vG-7m; Fri, 10 Feb 2017 16:19:30 +0000 Received: by twins.programming.kicks-ass.net (Postfix, from userid 1000) id 9924E1256AA9C; Fri, 10 Feb 2017 17:19:28 +0100 (CET) Date: Fri, 10 Feb 2017 17:19:28 +0100 From: Peter Zijlstra To: Waiman Long Message-ID: <20170210161928.GI6515@twins.programming.kicks-ass.net> References: <1486741389-8513-1-git-send-email-longman@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1486741389-8513-1-git-send-email-longman@redhat.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Cc: linux-arch@vger.kernel.org, Juergen Gross , Jeremy Fitzhardinge , x86@kernel.org, kvm@vger.kernel.org, Radim =?utf-8?B?S3LEjW3DocWZ?= , Boris Ostrovsky , Pan Xinhui , Paolo Bonzini , Rusty Russell , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Chris Wright , Ingo Molnar , "H. Peter Anvin" , xen-devel@lists.xenproject.org, Alok Kataria , Thomas Gleixner Subject: Re: [Xen-devel] [PATCH v2] x86/paravirt: Don't make vcpu_is_preempted() a callee-save function X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Feb 10, 2017 at 10:43:09AM -0500, Waiman Long wrote: > It was found when running fio sequential write test with a XFS ramdisk > on a VM running on a 2-socket x86-64 system, the %CPU times as reported > by perf were as follows: > > 69.75% 0.59% fio [k] down_write > 69.15% 0.01% fio [k] call_rwsem_down_write_failed > 67.12% 1.12% fio [k] rwsem_down_write_failed > 63.48% 52.77% fio [k] osq_lock > 9.46% 7.88% fio [k] __raw_callee_save___kvm_vcpu_is_preempt > 3.93% 3.93% fio [k] __kvm_vcpu_is_preempted > Thinking about this again, wouldn't something like the below also work? diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 099fcba4981d..6aa33702c15c 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -589,6 +589,7 @@ static void kvm_wait(u8 *ptr, u8 val) local_irq_restore(flags); } +#ifdef CONFIG_X86_32 __visible bool __kvm_vcpu_is_preempted(int cpu) { struct kvm_steal_time *src = &per_cpu(steal_time, cpu); @@ -597,6 +598,31 @@ __visible bool __kvm_vcpu_is_preempted(int cpu) } PV_CALLEE_SAVE_REGS_THUNK(__kvm_vcpu_is_preempted); +#else + +extern bool __raw_callee_save___kvm_vcpu_is_preempted(int); + +asm( +".pushsection .text;" +".global __raw_callee_save___kvm_vcpu_is_preempted;" +".type __raw_callee_save___kvm_vcpu_is_preempted, @function;" +"__raw_callee_save___kvm_vcpu_is_preempted:" +FRAME_BEGIN +"push %rdi;" +"push %rdx;" +"movslq %edi, %rdi;" +"movq $steal_time+16, %rax;" +"movq __per_cpu_offset(,%rdi,8), %rdx;" +"cmpb $0, (%rdx,%rax);" +"setne %al;" +"pop %rdx;" +"pop %rdi;" +FRAME_END +"ret;" +".popsection"); + +#endif + /* * Setup pv_lock_ops to exploit KVM_FEATURE_PV_UNHALT if present. */