Received: by 2002:a05:7412:a9a3:b0:f9:327e:43ab with SMTP id o35csp165421rdh; Mon, 18 Dec 2023 07:17:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3SrjY+SmHdJxNLN2AJvLJyY3yZN/GYRAvB2PK8JjOf61W6dSHkeh9MNX/8ifZJG8vQte5 X-Received: by 2002:a05:620a:388a:b0:76f:d65:af24 with SMTP id qp10-20020a05620a388a00b0076f0d65af24mr16555262qkn.27.1702912670606; Mon, 18 Dec 2023 07:17:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702912670; cv=none; d=google.com; s=arc-20160816; b=QmgjNaFZZOyQPyp3IpZWnKHee4CloTWZGJ4O0uzb0Ty+y2NDMOUSfRUumsDEkiiQxs eiUnA5dscvrYvnawSexRGpGhoTJXaqC8T8aMHSVTzgrC2252V3sZAutsa5CZhv3CGQsX G+lFPyc631Ap9fyc+vyRBxqFG/od3theSmw+VRJQGomvefzcwqzMKwFq4u1iQYgc8mQx WzFncFUcWQM5Zia39T2HsryUETD35KA22o7PZBSPPT7QGXpoG+q947tgFgHnnzQGrSAc H3PFrb3s0R3dgdsEqW+LJ9F5Pm4gGTMppqrqg/+Hvz2Vx3xb5jOKtOHZXUbtzDdFXrUZ w7yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=PY60PN5C+lwGGC6WWMv45aexAZDh9La78/eVT3cI7Yo=; fh=3BadaO+jpH5S+6vLyve969MJCFWnDAenI/XIGs6TAt4=; b=vZ3ybpHQzasAasJtHmwI1RN+igqD7mdYgMNs7IIqcMAB7/SPbyP/rQDHJB2k4Cx9zW 3dMnE7qcvUedVaA2NXuY6wFNQbaTU8P+CCuVUxSH9bo0KlV57WrdQP2GqbixLuoManVB u/p72WzLXexgpAUrCD4biwPUPoKkunAWKtpCqPAm4lvPCicHPDDEJ930EbDTg/JFkcGb 942IkWnjZ8ugCl4IGmxOPawyLm0JMZOlpVooIipuO99avGPjuwIv1NrWZbi+GNVOhVNw d4SKBYOfMwU+e56LFGn7zTdoRskCT6O6N7JHx1LCORfb8+V2BQmnln64rIQhhKh+mrQF YjfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KGuuxqfn; spf=pass (google.com: domain of linux-kernel+bounces-3912-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3912-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z11-20020a05620a260b00b007742286b280si26142318qko.457.2023.12.18.07.17.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 07:17:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3912-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KGuuxqfn; spf=pass (google.com: domain of linux-kernel+bounces-3912-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3912-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5A0461C23DAA for ; Mon, 18 Dec 2023 15:17:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58A2E42375; Mon, 18 Dec 2023 15:16:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="KGuuxqfn" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 556F83D568 for ; Mon, 18 Dec 2023 15:16:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2cc6eecd319so15462771fa.1 for ; Mon, 18 Dec 2023 07:16:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1702912596; x=1703517396; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PY60PN5C+lwGGC6WWMv45aexAZDh9La78/eVT3cI7Yo=; b=KGuuxqfnE2Fl9AWYcrhHSiYQ+vtdOHIwxPZExWiiadgMJw7pOrsbnrQosVW/DVt1D2 g2XgiwedLoyts7jYZ1FUiBqXsHsBMo4Tp7w84vqjHS0YzhzsHnrxbm0YELq5bK2gYmKy VXRLhhKdKlN/28FBFPCJW75sV2/ZSeZIhxj2E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702912596; x=1703517396; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PY60PN5C+lwGGC6WWMv45aexAZDh9La78/eVT3cI7Yo=; b=wqpNqlHfqeCZUTvrrl9urKSw3VmAj0frg+b89fCMlJ0WJFRIBxCvXyiD9OhYwN+0Yo EFUuqtlMCjrlBXol3Zhj4XK8K90nMSEuooNyimSKJoSvQbO9oRahWijEEU0AdQfBtDNy c/zXiy1oV7rEPRNkq1xUkJSIac8kSlRsqcEkHewwTXWVzuhOIV5Ci8FYGTw/dy8EsWpe +FDUROI2rnfnxxfrTBirOgqELW7uvNrcXMff22Im1TAybW+FbkWXu8nmLDJLlW3GbCk2 9EL+SNxPEuA+pmZTJjA5jPJl+BGqZu5dIpwtuM0+6Ie20qNX8UVa9Kap+YFtLIaT51V+ bxzw== X-Gm-Message-State: AOJu0YwaujTvDIVJdrUsCmKB9hpl7uM1w4AmHVzX1IAOsyHa/rLdUHUF ypYg1RAuJWn1Cz6jY+iGSZ0YeOWebCR+JLDu74ZZzRZ02ij8LeoN X-Received: by 2002:a2e:95d8:0:b0:2cc:67ad:4153 with SMTP id y24-20020a2e95d8000000b002cc67ad4153mr1326894ljh.25.1702912596293; Mon, 18 Dec 2023 07:16:36 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231211114346.1132386-1-stevensd@google.com> <2146e48d-5fb3-4444-81c5-9c8d8cb18811@redhat.com> In-Reply-To: From: David Stevens Date: Mon, 18 Dec 2023 10:16:24 -0500 Message-ID: Subject: Re: [PATCH] virtio_balloon: stay awake while adjusting balloon To: David Hildenbrand Cc: "Michael S . Tsirkin" , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Dec 18, 2023 at 6:37=E2=80=AFAM David Hildenbrand wrote: > > On 14.12.23 05:13, David Stevens wrote: > > On Wed, Dec 13, 2023 at 5:44=E2=80=AFPM David Hildenbrand wrote: > >> > >> On 11.12.23 12:43, David Stevens wrote: > >>> From: David Stevens > >>> > >> > >> Hi David, > >> > >>> Add a wakeup event for when the balloon is inflating or deflating. > >>> Userspace can enable this wakeup event to prevent the system from > >>> suspending while the balloon is being adjusted. This allows > >>> /sys/power/wakeup_count to be used without breaking virtio_balloon's > >>> cooperative memory management. > >> > >> Can you add/share some more details > > > > I'm working on enabling support for Linux s2Idle in our Android > > virtual machine, to restrict apps from running in the background > > without holding an Android partial wakelock. With the patch I recently > > sent out [1], since crosvm advertises native PCI power management for > > virtio devices, the Android guest can properly enter s2idle, and it > > can be woken up by incoming IO. However, one of the remaining problems > > is that when the host needs to reclaim memory from the guest via the > > virtio-balloon, there is nothing preventing the guest from entering > > s2idle before the balloon driver finishes returning memory to the > > host. > > Thanks for the information. So you also want to wakeup the VM when > wanting to get more memory from the VM? > > Using which mechanism would that wakeup happen? Likely not the device > itself? The wakeup would happen via the parent device's interrupt. I've sent a new version of this patch that uses the parent device's wakeup event instead of adding a new one. > > > > One alternative to this approach would be to add a virtballoon_suspend > > callback to abort suspend if the balloon is inflating/adjusting. > > However, it seems cleaner to just prevent suspend in the first place. > > Also, the PM notifier could also be used with very high priority, so the > device would respond early to PM_SUSPEND_PREPARE. One drawback of blocking suspend via a PM notifier is that the behavior isn't configurable by userspace, whereas wakeup events can be enabled/disabled by userspace. -David