Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp418555ybh; Mon, 20 Jul 2020 21:18:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyf0MgiLUjEjwT82KYqQrNxOXuVZZzXspOks2sWXqf9CZOk6kV3GXWrIX8Y3+Ov1yXcGqcY X-Received: by 2002:a17:906:2e83:: with SMTP id o3mr23846494eji.261.1595305131948; Mon, 20 Jul 2020 21:18:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595305131; cv=none; d=google.com; s=arc-20160816; b=czQCKYIny6SlfZcpohoxqN+8w0JX4I4z+pvq4vsPE67jxecoSHc1KtowLhL0+H+vwE eZTQT5uI5Myc37fyHs+w6cfLqjJBnV1cpX0uthDoZlQo4MYNaXt4UIy3I9jOzlAvd5fd EKFifA/CA0t9LAFvvqS5Qf5hsJxdDBuN3eK7ltww7Jwu+ILDj+DVyX59UKChZwx62yTJ XZqmDnGWtUC6ykDla+lZstqKI4ERaiRhjg3TXDFrV8En+bjjGqRUJ87Ktl6W2PVDm8Tm R+JCj7+wmKMMsW2iQ/wPxDv6Aszl911Mz6lDt7IFkO0ip+ivL0AsN9Yftw2fr5Ma3lNf yihA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=NGaATuKDW25tfXnjy17rADeTuRjp0tV/vbWKKeWM86k=; b=Phjz9AlFRrDzIkvNzDvZegZ+ZS8ldc2EufnQofmrOc1aKcLlXf/SSmSxgWV1DPTO8H 0ckak5DtsEQKSAvyI0jcir53fIsrtJy0QwOlL4Ee/5511xxnrDPCHbjWnV43ERhA+d2j F7Pa3PBU8h8X0vwI639JiFOWhXk5b4TAE+8FpgocKqDeWv7OjUTk6apXsN6rFyTKPHG7 68XlufgKeqwCM6U08EkoECTwvmzwjR2UDA7h1oqX2sMa8xqinnxqeukG3OFj0ZZbV3nZ UgBv9kZo7ohyzyTi/0ISQxEY/oZ6UNADh08kxCJ+rZL3/6crZP/NJRFjJB/9HTdEYpuE t3hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FxePU75M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o10si11918201edr.168.2020.07.20.21.18.10; Mon, 20 Jul 2020 21:18:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FxePU75M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726109AbgGUER6 (ORCPT + 99 others); Tue, 21 Jul 2020 00:17:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725294AbgGUER6 (ORCPT ); Tue, 21 Jul 2020 00:17:58 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D00B2C061794 for ; Mon, 20 Jul 2020 21:17:57 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id m22so11320191pgv.9 for ; Mon, 20 Jul 2020 21:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NGaATuKDW25tfXnjy17rADeTuRjp0tV/vbWKKeWM86k=; b=FxePU75MyL2vEbevw6TtpxAoZ7al858qTZLgnulsvLtPDHAZfRUGdWc8xDb2P2/S9/ bBc/PZv5oRmBtHu48J57hkDZoUPQczKHwLfygAQtWJAsbxUuyNPgQOhqoO7hnGwY2S1l BjCPVh9MaV1iO0wYglWEBL4YpgbhAKblNLO+R5ajQ6JgPxXfHsi5f7SvrdmclWZhjMtz Y+YCcQoTX72YN/GxWylHQAn1hpHmYUVKeFMHkT/mb0j446hxYU+dM2N7Iccf+4Enn9/u /BVQr+laVTtELgg68bMcctbJvSPmcvK0ISINvHZSf6qmhX8LdfPhs54QE7ulpgedx3ty BEOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NGaATuKDW25tfXnjy17rADeTuRjp0tV/vbWKKeWM86k=; b=asnypfmAePEPL43ZuR3dW1XpZ9sRVQZGLBZNWyRiewxe2uYvkJSKMpuRct5xka1dOB 4MO4Cw0dSiI3bK8GqcGUMhCEfIq2RJdDJ4D0Zner1X3OkmloffmizcvhqIi6NXooi+kf Mlfqtzkf4o4okT7yzZth6wtGtuVkQQBGxDTEv3MwRYn7SSEDd7qpOsGKmHsyR+ug7sJw ixsLM+TsFVeIgIultRZILCU+fDigbnvVIIv3gblMEnmgF+jKRPsoiehuT5oLyE3yy7+Z YmSnikf1REdaXLEFqIXYi0v06IjmEZlVa31d8s887URPmEs17X0nO2/kF0Z8vMjpaDpx W0zQ== X-Gm-Message-State: AOAM532ZEzJXy6HQyRxAjRfYfXFYS9owTvRsZpPwI3a9e0ggcW39fzGD Fl+PBiXZTdhJ6yefe2wDOHw= X-Received: by 2002:a63:6884:: with SMTP id d126mr20548484pgc.341.1595305077188; Mon, 20 Jul 2020 21:17:57 -0700 (PDT) Received: from localhost.localdomain ([2409:10:2e40:5100:6e29:95ff:fe2d:8f34]) by smtp.gmail.com with ESMTPSA id e28sm18467270pfm.177.2020.07.20.21.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 21:17:56 -0700 (PDT) From: Sergey Senozhatsky To: Will Deacon , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose Cc: suleiman@google.com, joelaf@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [RFC][PATCH 0/4] arm64:kvm: teach guest sched that VCPUs can be preempted Date: Tue, 21 Jul 2020 13:17:38 +0900 Message-Id: <20200721041742.197354-1-sergey.senozhatsky@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, RFC We noticed that in a number of cases when we wake_up_process() on arm64 guest we end up enqueuing that task on a preempted VCPU. The culprit appears to be the fact that arm64 guests are not aware of VCPU preemption as such, so when sched picks up an idle VCPU it always assumes that VCPU is available: wake_up_process() try_to_wake_up() select_task_rq_fair() available_idle_cpu() vcpu_is_preempted() // return false; Which is, obviously, not the case. This RFC patch set adds a simple vcpu_is_preempted() implementation so that scheduler can make better decisions when it search for the idle (v)CPU. I ran a number of sched benchmarks please refer to [0] for more details. [0] https://github.com/sergey-senozhatsky/arm64-vcpu_is_preempted Sergey Senozhatsky (4): arm64:kvm: define pv_state SMCCC HV calls arm64: add guest pvstate support arm64: add host pvstate support arm64: do not use dummy vcpu_is_preempted() anymore arch/arm64/include/asm/kvm_host.h | 23 ++++++ arch/arm64/include/asm/paravirt.h | 15 ++++ arch/arm64/include/asm/spinlock.h | 17 +++-- arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/paravirt-state.c | 117 +++++++++++++++++++++++++++++ arch/arm64/kernel/paravirt.c | 4 +- arch/arm64/kernel/time.c | 1 + arch/arm64/kvm/Makefile | 2 +- arch/arm64/kvm/arm.c | 4 + arch/arm64/kvm/hypercalls.c | 11 +++ arch/arm64/kvm/pvstate.c | 58 ++++++++++++++ include/linux/arm-smccc.h | 18 +++++ 12 files changed, 262 insertions(+), 10 deletions(-) create mode 100644 arch/arm64/kernel/paravirt-state.c create mode 100644 arch/arm64/kvm/pvstate.c -- 2.27.0