Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2924568lqp; Mon, 25 Mar 2024 13:15:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVt/rH4o3+UIVXHGUFIB5ZiYhPn/7yhbzIg4shQK6swC5cXlzuS73tmXP0NMii85X1WSHiuUaSIntVr/ltVTiLyvKCvPe1x6VxKguZyDw== X-Google-Smtp-Source: AGHT+IE4wpAnqE6bN/W6/W+kVc4+5f1aXM7FbpGwmqt3kHbrSaQ68Ai5wrGxGmLsnhUKmtGtNWaP X-Received: by 2002:a05:6a00:b83:b0:6e6:88ee:8429 with SMTP id g3-20020a056a000b8300b006e688ee8429mr10906653pfj.11.1711397701622; Mon, 25 Mar 2024 13:15:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711397701; cv=pass; d=google.com; s=arc-20160816; b=yiut1sTJpqitaJbYN7fUJiEkRdYa8HoRWuzBLVZwcZ7CMWvvcx3jsak3Rb+efUe0Zd USODHWy+TtMBUE5Ck74u4Ch9VvW2KQNMC2wJC65fSrPrrp7yra6LWamDn2vWNafqVPcm JpyYhO6IGlVb3YEF6X3YxvJLYUl0X35LD3CTCUcczA3a/5FVWv5uG+i/uBTq7WsfmmY+ BNxVt6GjM9ujY8ITfyNGSdFV0H727krEvTMIpPlPeFLYVEKxuxFV8veo0qRqBT1JDQ6R dNHAOqKJgTQWXEBPpWn1R0/QWcl4zDEvhHsvbgYJyob90FJUqfrfWyr5iDeOVpy4TKJR ws2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:in-reply-to:date:dkim-signature; bh=T2hv5W0oxITVtYMp7qscmbVqdlTYLfE2MA0LIJYCuQE=; fh=Xj1OjELdfhARVjx8MnRqL7JCUZ9XbDj2m5pyhW+LQ1Q=; b=OJZBITtYCwcjUMUWApejoGoPtAHLnpiXQ7DIpawfsjCMjT+L4JD41n4BAIKsUyFltM 21PktM6i2K06LuiZE3V8USwbYxJQSgcTYjJnJKGGCj/7ouzX29Ip+v/lAzRzWkVlD6fk 6kDzGUd4b7obB/pvYJSnIyHNso+6JZBXH/5FblwonSDGKYYU42atkM3U/bK4iXgRxIsc PkeW0es/AaPDZ9fipA0Vxnl0AZVbrK/23/NAEUQBlZvUISkGsMi4K1Y+qaPuUBJRweTQ x3K+ONCHnG/NRJRqZytabC4GFBrNoD/8fc6jhUdzrvsLJT4l4NdOsCaTPlzFIoGi1VjC OPrg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=fujt8Pmp; arc=pass (i=1 spf=pass spfdomain=flex--coltonlewis.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-117898-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117898-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s4-20020a632144000000b005cecc6097f2si8171828pgm.895.2024.03.25.13.15.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 13:15:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117898-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=fujt8Pmp; arc=pass (i=1 spf=pass spfdomain=flex--coltonlewis.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-117898-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117898-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4D5AF304257 for ; Mon, 25 Mar 2024 20:14:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 661C73FB1B; Mon, 25 Mar 2024 20:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fujt8Pmp" Received: from mail-io1-f73.google.com (mail-io1-f73.google.com [209.85.166.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD4CD52F81 for ; Mon, 25 Mar 2024 20:12:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711397528; cv=none; b=dXTPoxm0T3Vu/DzcK6x0yz8RbnSlly2UGmzTeYQQiPi/PdQwKc+6iLPRZV/wvUzJPyqtrve4qxpC/pJL2ZWL02Am5iJvbfy1C8EcGHmsxL1hCyI66HR8moqsjgiAa78+L9x4vuYyLZC4XzWksQCSXU534R8vjKTvVZJor1y3EsM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711397528; c=relaxed/simple; bh=TS58LtBep+V3y21GNNI5AUCkkhJt90huKHWlMzlnjIk=; h=Date:In-Reply-To:Mime-Version:Message-ID:Subject:From:To:Cc: Content-Type; b=ffbZAq5suExqzMt5MHfftyktiFAJkXMobKTyFxcCXowFeZsFNnnzwoZerpt0hV2XIZcNgiu7kXkFzBZTf8StNhfqLph2z5Z0MvtciX1Sz0zmXhkojipXQMUIzAWjSzF9VFceNJsLKjJviFxSjyXftpLuL/AtiXJC2y21C2GJgF8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fujt8Pmp; arc=none smtp.client-ip=209.85.166.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com Received: by mail-io1-f73.google.com with SMTP id ca18e2360f4ac-7c8742bedd4so359500939f.1 for ; Mon, 25 Mar 2024 13:12:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711397526; x=1712002326; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:in-reply-to:date:from:to :cc:subject:date:message-id:reply-to; bh=T2hv5W0oxITVtYMp7qscmbVqdlTYLfE2MA0LIJYCuQE=; b=fujt8PmpE6IgP0LADa3B76CekvZwxzqx55wd5hzGfmvVtN3ZYvCqyFIO7yZYj3279v QgN1NB4y28M4HqMmYzUvqEm7TJsnzLhHavlY2lbpiQB+cAjGM5sMz7MBhJSZ2SCtAEwp Ct6PQQwadFQUZZAp5Kf89PeKPGbJtNIAK2McGRzGou+qdsT8I8aiYzwWbkhmb0spp3mK rIw8lnDZrP6oMpc7fkmxHRB6rNIN6SJSSFLKs1kAlHibSRKBc+wAabrhBMSyl6Usn2a5 vbWZmaIn4wSTG9AwZeKiiuZtw7zZVsxQyz1v7vbhdG3cdQSlnd0gd8n8uj4BLLFRqt7x ySbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711397526; x=1712002326; h=cc:to:from:subject:message-id:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=T2hv5W0oxITVtYMp7qscmbVqdlTYLfE2MA0LIJYCuQE=; b=j7vqtBs7CQujVLm3T55/YjHRAcPs7WDkG1DY+oZMiA5sKqtPdVjSvdqUOCijDSxoKg C50DgIU+jxHmS3yacxD9u+7k61oJpOnPAYCRgKKCoy4bFP70HV1WkHI6PxEXG7SmuOth qIB/C+4lEaKEhNyz4mkZ+Uklo5Mlwy1JdyFTwCI/D/8FLqHXH8Dks0wXwbTyWPaUzPZo FfU7IyDM6m98QyNlT/X5I2wlV50w1xxLu6x2CZxHyN0eEnpWCC8vCNMMeKAG7MEJHkcE LSLsiD3ekm7sgxJ6JzSNUyoFzRHJlaKB5ly0cIpGYOW5Ugg2mwksbe4iUwUpv5dlLTn/ y1FQ== X-Forwarded-Encrypted: i=1; AJvYcCX76Ggcq3f3ACy8o3u/1YugAG+JD4olfobtpUpc74mnT5hV28B1S2fET8GzMFi1Rm2zD3E+7NZAeq2H9/2K0CAa5w+kxnB0wRDaC7ke X-Gm-Message-State: AOJu0YyL6HpRAS+iwWo12PED10Q+Zc1TuR+RIYDwNGhk0DIJJMZhlKR4 uaupP55es4hleKAXs30aKjyYOD38h2VpeEX8lZRPPVcni9V6w3YFEk/h8CnqFZEKemBzSQuI74r FqaTnquy7fEjhLBW9fYwGYQ== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:14ce]) (user=coltonlewis job=sendgmr) by 2002:a05:6638:3724:b0:47c:125e:7f3e with SMTP id k36-20020a056638372400b0047c125e7f3emr304187jav.3.1711397526087; Mon, 25 Mar 2024 13:12:06 -0700 (PDT) Date: Mon, 25 Mar 2024 20:12:04 +0000 In-Reply-To: (message from Quentin Perret on Fri, 22 Mar 2024 14:34:35 +0000) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Message-ID: Subject: Re: [PATCH v2] KVM: arm64: Add KVM_CAP to control WFx trapping From: Colton Lewis To: Quentin Perret Cc: kvm@vger.kernel.org, maz@kernel.org, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, pbonzini@redhat.com, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes Thanks for the feedback. Quentin Perret writes: > On Friday 22 Mar 2024 at 14:24:35 (+0000), Quentin Perret wrote: >> On Tuesday 19 Mar 2024 at 16:43:41 (+0000), Colton Lewis wrote: >> > Add a KVM_CAP to control WFx (WFI or WFE) trapping based on scheduler >> > runqueue depth. This is so they can be passed through if the runqueue >> > is shallow or the CPU has support for direct interrupt injection. They >> > may be always trapped by setting this value to 0. Technically this >> > means traps will be cleared when the runqueue depth is 0, but that >> > implies nothing is running anyway so there is no reason to care. The >> > default value is 1 to preserve previous behavior before adding this >> > option. >> I recently discovered that this was enabled by default, but it's not >> obvious to me everyone will want this enabled, so I'm in favour of >> figuring out a way to turn it off (in fact we might want to make this >> feature opt in as the status quo used to be to always trap). Setting the introduced threshold to zero will cause it to trap whenever something is running. Is there a problem with doing it that way? I'd also be interested to get more input before changing the current default behavior. >> There are a few potential issues I see with having this enabled: >> - a lone vcpu thread on a CPU will completely screw up the host >> scheduler's load tracking metrics if the vCPU actually spends a >> significant amount of time in WFI (the PELT signal will no longer >> be a good proxy for "how much CPU time does this task need"); >> - the scheduler's decision will impact massively the behaviour of the >> vcpu task itself. Co-scheduling a task with a vcpu task (or not) will >> impact massively the perceived behaviour of the vcpu task in a way >> that is entirely unpredictable to the scheduler; >> - while the above problems might be OK for some users, I don't think >> this will always be true, e.g. when running on big.LITTLE systems the >> above sounds nightmare-ish; >> - the guest spending long periods of time in WFI prevents the host from >> being able to enter deeper idle states, which will impact power very >> negatively; >> And probably a whole bunch of other things. >> > Think about his option as a threshold. The instruction will be trapped >> > if the runqueue depth is higher than the threshold. >> So talking about the exact interface, I'm not sure exposing this to >> userspace is really appropriate. The current rq depth is next to >> impossible for userspace to control well. Using runqueue depth is going off of a suggestion from Oliver [1], who I've also talked to internally at Google a few times about this. But hearing your comment makes me lean more towards having some enumeration of behaviors like TRAP_ALWAYS, TRAP_NEVER, TRAP_IF_MULTIPLE_TASKS. >> My gut feeling tells me we might want to gate all of this on >> PREEMPT_FULL instead, since PREEMPT_FULL is pretty much a way to say >> "I'm willing to give up scheduler tracking accuracy to gain throughput >> when I've got a task running alone on a CPU". Thoughts? > And obviously I meant s/PREEMPT_FULL/NOHZ_FULL, but hopefully that was > clear :-) Sounds good to me but I've not touched anything scheduling related before. [1] https://lore.kernel.org/kvmarm/Zbgx8hZgWCmtzMjH@linux.dev/