From patchwork Tue Jul 21 04:17:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 11674923 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9AED0138C for ; Tue, 21 Jul 2020 04:19:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 74361208E4 for ; Tue, 21 Jul 2020 04:19:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AzsTT67X"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FxePU75M" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74361208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=NQTXmtvVXvsqL+0ZsHFYhhVlHKeqHuCFZsvrTlXKho8=; b=AzsTT67XLaOjiQwVyRdsXqO2nh OVOD/e8/gYrunWtpXGX+Ri0EHL6HLVAEqgGAlRN3/jUWixchtofQrClc7xmu/0QV0KsrAFIQ26XLp e0jHf5dlzTIMS2HhuiKuSL6AIU7KcEexyBhf6Etaakr6pN3M8Ep5S7Qqwhaoqbx3+1v7t/rcq9UGb VKx8FainX6pey3sqYiVPXtzzQmdsOPQif3Rv8AXknb+DKBL0wBLUlAqFRMSrZa0OJdcBU9K6M/QeM te9NZbipKUL5addu1GozSWImHzzIPHTl5Ok2ILgE4j2Me1Iq9aLGvC7LzLGXnHKrFpruEnGvgT/dp GytEU/eg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxjj7-0005gu-N7; Tue, 21 Jul 2020 04:18:01 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxjj5-0005gZ-55 for linux-arm-kernel@lists.infradead.org; Tue, 21 Jul 2020 04:17:59 +0000 Received: by mail-pf1-x442.google.com with SMTP id u5so10115025pfn.7 for ; Mon, 20 Jul 2020 21:17:58 -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=G5CZ5PQXkvHazO5Z88OYsCmQNfpdMFyBR9fKNO6ZDnxJSZ/VXAAnPqGt81AL1Ccv5P qqeoJN2gTRmWLkurqWb+EyRRkircFbtlWnNJPooSCUDiQSvedg4FlwPXN8nlNKDPajBY qSdJ4YLok+Q4/LiKX1pDXYXKt18lrJNknHoge32bk/UryXMPjB1xQJil8oV4pAHFto8B qy/EY/7y/rvT9+Vdv76b3qZXfArtAd3YT59Hn+XYqGBWCAAY+YOwc3xn21K/Qv+uza8p Ag4AHQCtAXTE760KEF2vYfcT4ynMNmKZd261fKy9Mv0saWh2voLK2nQBbzIguaX2MGUk DXzA== X-Gm-Message-State: AOAM5302ZA7NNKrBFocLGW5+tIClNhb1O56j6tSOQJDzGOeb4OBf4eTm Kc42t20xHCS+t6FOXyeE19w= X-Google-Smtp-Source: ABdhPJzYY7DsDQI2R2Hw96u5qdwyUqBzumqyzaOhAyEtXxWQuqRgXwtqQViAPRcRnUwjnAvM4sTsoQ== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200721_001759_223624_1AADA25D X-CRM114-Status: GOOD ( 11.56 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [sergey.senozhatsky[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:442 listed in] [list.dnswl.org] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: joelaf@google.com, linux-kernel@vger.kernel.org, Sergey Senozhatsky , suleiman@google.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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