Received: by 2002:a05:7412:8d06:b0:f9:332d:97f1 with SMTP id bj6csp6259rdb; Mon, 18 Dec 2023 07:31:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IEbFYVGwvb+xZe34x+QPW77qcNUcfRqlBLRaMiqZuouCYVJMrVG4I2lP3/4llTAyrqepvoG X-Received: by 2002:a05:6a00:4655:b0:6ce:6a06:1caa with SMTP id kp21-20020a056a00465500b006ce6a061caamr7832867pfb.20.1702913468864; Mon, 18 Dec 2023 07:31:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702913468; cv=none; d=google.com; s=arc-20160816; b=q/KK3Fb2ngxFzNAoqUXwsbTvpAVOeXBhZSMau3q0MTOScvg0zfvKXovj72UmTdkMjx 5G63aFN1+2fz4MorYikQ9wceTqkptb9nNFswT48vqzC5fCl+77teJQ5mumCaI4Ix0EF1 v3TsSqHUFjjgcpTosOJGq6LdIqgIIQab4uUvHIXdyeqWei2qLbu8um/gXElEPG8rmbgC pm7S+DO/IyYZ0PhftWI1q41339idxhTOOaK6yADlok3fgBUu7WhKn6ojym6tKSB9DqID eOFUH/S6KwRhxJAHd4q+6VUrXDkQTY5NCvBMYMzoR8fRFm5VjW2/6AiZqLz5VPp4fGTY otDw== 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=PG0K7UPoSMBYTVf/4BeN4sLj8j0yHDIwZIH4KmzwU1Y=; fh=3BadaO+jpH5S+6vLyve969MJCFWnDAenI/XIGs6TAt4=; b=WzNqUZOObMFDArjZJGLhLXzO4ALxow0tZ8F4fPMMG8j2PaO+Uan8NIqk7aBTq6IqK8 InqO64ESFHM/POR/KHEWHraUxgU7PRhpsTrQiQnwKvqNl4/5b0SCj5qdu/C25asMvYgs 2piR+sA0t+VxqcTvqxJjKF0dcUt3KKzlZxHVc7O5ipOaViA41q6bRl3u2AgPkGQBgeZ0 J7hWuAMGUKxkDSr81lLFztgaI3wpucpGaMzm4fM7vLtXWiLDmBqj0PfjN4PpxvtdBbos GifuvezD+5jqxgfmwtuz2JnIv4JwfVIEwyFaMQ08hDyvn0F/UWsQnIUEQURqL84Pofoy /4WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SsIhLgq3; spf=pass (google.com: domain of linux-kernel+bounces-3928-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3928-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g5-20020a056a0023c500b006d0d83a11bcsi2300128pfc.102.2023.12.18.07.31.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 07:31:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3928-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SsIhLgq3; spf=pass (google.com: domain of linux-kernel+bounces-3928-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3928-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id AD5A4283DB5 for ; Mon, 18 Dec 2023 15:30:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C55823D54E; Mon, 18 Dec 2023 15:30:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="SsIhLgq3" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 52A3C3A1CD for ; Mon, 18 Dec 2023 15:30:26 +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-lf1-f53.google.com with SMTP id 2adb3069b0e04-50e3845abdaso1452993e87.3 for ; Mon, 18 Dec 2023 07:30:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1702913424; x=1703518224; 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=PG0K7UPoSMBYTVf/4BeN4sLj8j0yHDIwZIH4KmzwU1Y=; b=SsIhLgq3qXPkF5uXARxgDujC1uCODid0W4DSZySZesKtxMPo9FDeFxof+FBenHlmPK eq4u2b+VRzb+B0CUxdmR9hyLduRBfiG7AoTqwyPJgADEoUavlCiPpQkFybqLmEuLS0y9 xD+cXrLvByY1sTJy6UNl/5OlONhngiRZJjk1E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702913424; x=1703518224; 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=PG0K7UPoSMBYTVf/4BeN4sLj8j0yHDIwZIH4KmzwU1Y=; b=Em9JniR47csNugHoJs0xn02z0bGzwXtmsS2NVGVvdorZCwfzssKY12bVtd4+7WRLba SmL6/9ZFtEijk0eccZNAekvh18oMF9uZeK+LJQEkUKfdvNI331RJvVKhzje/0R3scnph 7DxHGck0hpn2AzVcBzSgAnj/JtKQvyrzSeJdO86P7lkRyPdFTeOCTXGFDcwQ84qCfn1h KB8NNS2zBT1qqa6NQxvco5cCuTxObgFR9S45p2ZIrL1Tnleve2ZE9J1xyAL7H9c3Suox l8rOcWFkVu7uaqsV5VQvvxkkqLjfuDINNYqCLAHbPQpkpxvCQk/89bQVjocVbeOOBXgb ndjA== X-Gm-Message-State: AOJu0YxzQf1rA7WWRnmI/4IrjSxGVyZFvjRg7XsdjP1o7wj/qNFJh0LH Nt/gZMuwDGQauShx6lXSuHQakyCuz4hvz187usVs4g== X-Received: by 2002:a05:6512:3b87:b0:50e:2cbd:cc50 with SMTP id g7-20020a0565123b8700b0050e2cbdcc50mr2142056lfv.23.1702913424387; Mon, 18 Dec 2023 07:30:24 -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> <2b8f4855-98f4-4515-bd5f-f93983d45714@redhat.com> In-Reply-To: <2b8f4855-98f4-4515-bd5f-f93983d45714@redhat.com> From: David Stevens Date: Mon, 18 Dec 2023 10:30:13 -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 10:18=E2=80=AFAM David Hildenbrand wrote: > > On 18.12.23 16:16, David Stevens wrote: > > 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 recentl= y > >>> 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 problem= s > >>> 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_suspen= d > >>> 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 t= he > >> 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. > > The question is if that behavior for the balloon is really worth it > being configured by user space? It seems to me that the current behavior of completely resetting the virtio balloon in virtballoon_freeze is basically antithetical to the power management integration I'm adding, where power management doesn't interrupt the virtio balloon's operation at all. So if there are any systems that are actually happy with the current power management behavior, they probably don't want suspend to be blocked by inflation/deflation. -David