From nobody Fri Mar 29 15:44:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1685053299; cv=none; d=zohomail.com; s=zohoarc; b=K5TvPsJ7JN87ARFwPaEpN03hjcOHOZPi1WUcP/0VVz1dHJ4CxTAz9ZTO8EOmzbx9DAugSbFtDCUWciEc8Tc5EUG2r//2Tnu9rlWAeIxcpSQ/E+yo8Gxsr1H5t806Uinc5d1CYMtI6uB9EC+sVtMUNeub8vQEqqk6nRSeXlpJaOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685053299; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Dv9d85KFKaQHX4RsIMVaW+2xqVbQVw6mV3FxWbA0cOI=; b=f+TgFhXGPyNIdU+I/a/GLxkpaPaMxWvxFX8DXu5F9AoaG75oozvaRAD2LQU3FSprWV4wifycGwE7b23K+Up3OJ0+OxC8jSZ3chgaEFgqVDbbZgHsvOGBtJwr508jKSkBhT5ntmKTCGm4VzWZI5X/SKph9Qv+7C/Vjwz4mCPxNSE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685053299830596.317319427127; Thu, 25 May 2023 15:21:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2JJr-000258-N0; Thu, 25 May 2023 18:20:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3Jt9vZAgKCs0Ct4D5utDz77z4x.v759x5D-wxEx4676z6D.7Az@flex--talumbau.bounces.google.com>) id 1q2JJp-00024b-K5 for qemu-devel@nongnu.org; Thu, 25 May 2023 18:20:25 -0400 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3Jt9vZAgKCs0Ct4D5utDz77z4x.v759x5D-wxEx4676z6D.7Az@flex--talumbau.bounces.google.com>) id 1q2JJn-0004QV-SO for qemu-devel@nongnu.org; Thu, 25 May 2023 18:20:25 -0400 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5659a7d4c38so4626317b3.2 for ; Thu, 25 May 2023 15:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685053222; x=1687645222; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Dv9d85KFKaQHX4RsIMVaW+2xqVbQVw6mV3FxWbA0cOI=; b=4VAvlwLwju1iK8+pH/BjOZVytzAUejA/Y7wzk8/SqP1YvIRTE1J4SIU3Z1741/by0/ Uch/dGmtH3Lqu6mlPl5wmldvu2UHdkahzh+cbBSyOV/twy6bOHlU59JFxEpm63bPXfWr oZuO13139A/zw+GMBHAZ50XSrzPAyq+bdJnOZ41urgvUcU8bloGxxN8R0Oz5noxWbebn dNWWeJXcy/GGtzypHBEkcM29ZXmV8kEyHhwrHCswwQDygSvxsQrDvnX36EVJHRz7PMFR 0XJpYY5qoLTrWEbD5NhPf1W+aII5TpqZIQDFQGlHuRC6Z5+SN7XiN9kQ0/F8n+w09v82 yAOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685053222; x=1687645222; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Dv9d85KFKaQHX4RsIMVaW+2xqVbQVw6mV3FxWbA0cOI=; b=caM5sI63B/8NqHWYkr5RCJF/rD9ibSI5rnT86QBKa6l2gnB4XGluJTC/mAROMcbdGn /rW3h8gQVQvmgX3rHKlXxjBAvHMctWqIi66ccY4FbluHsTeGwMTEYkfxQ/XrzAbtrYj2 Z3TeqvovT441AzT6vgc/6OxFXoHzmbOiqNnATvLGTI+R9vzIjWTKjqM0IRZqZ+0xJ8Ar 5HXawEqMYjpmBQpj8kitqFFb+WR1Ps4e5IKpZ9M8Fi51RwSpwd1K1cFLLoCstnNPZESL RhfTEZPb9MJYKOYs+gmq53ruyWUHwvQaulOegSIU2t/QxNABitIu441D32Rt7rxAmqaj b5jA== X-Gm-Message-State: AC+VfDyOvrNZ4Fifi4T0msrNMM/JV4pfPf7/g23tAdNB3Hw8R1tAXe/1 3ukd2ysaH9632obGwOrVOTHWMc+otHbZ54SdNKyl7PiWSSEOPWMz7q2R+ztv2T2slVIgoZDcTqw 6ERKCgQAmOfMwSAhsXrx0skXuL3WSMFlBUP3jG2vinoUW+4kIBXeEGhMfWNu+ju6sOQ== X-Google-Smtp-Source: ACHHUZ5xQOY1D/rxFcpqnJbIaXfAtG2/DP2sd0Ssl5UCe77ZCGfu12X4Dg2cZ9ER8kYUcQbc4ORlwqhkJ8TZKQ== X-Received: from talumbau.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:90d]) (user=talumbau job=sendgmr) by 2002:a81:b615:0:b0:565:ab37:33a1 with SMTP id u21-20020a81b615000000b00565ab3733a1mr8100ywh.3.1685053222001; Thu, 25 May 2023 15:20:22 -0700 (PDT) Date: Thu, 25 May 2023 22:20:12 +0000 In-Reply-To: <20230525222016.35333-1-talumbau@google.com> Mime-Version: 1.0 References: <20230525222016.35333-1-talumbau@google.com> Message-ID: <20230525222016.35333-2-talumbau@google.com> Subject: [RFC PATCH v2 1/5] virtio-balloon: Add Working Set Reporting feature From: "T.J. Alumbaugh" To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , David Hildenbrand , Yuanchu Xie , Yu Zhao , "Dr. David Alan Gilbert" , Markus Armbruster , Eduardo Habkost , Marcel Apfelbaum , "=?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?=" , Yanan Wang , Eric Blake , "T.J. Alumbaugh" Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::114a; envelope-from=3Jt9vZAgKCs0Ct4D5utDz77z4x.v759x5D-wxEx4676z6D.7Az@flex--talumbau.bounces.google.com; helo=mail-yw1-x114a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1685053301637100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Balloon header includes: - feature bit for Working Set Reporting - number of Working Set bins member in balloon config - types for communicating Working Set information Signed-off-by: T.J. Alumbaugh --- .../standard-headers/linux/virtio_balloon.h | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/standard-headers/linux/virtio_balloon.h b/include/stan= dard-headers/linux/virtio_balloon.h index f343bfefd8..df61eaceee 100644 --- a/include/standard-headers/linux/virtio_balloon.h +++ b/include/standard-headers/linux/virtio_balloon.h @@ -37,6 +37,7 @@ #define VIRTIO_BALLOON_F_FREE_PAGE_HINT 3 /* VQ to report free pages */ #define VIRTIO_BALLOON_F_PAGE_POISON 4 /* Guest is using page poisoning */ #define VIRTIO_BALLOON_F_REPORTING 5 /* Page reporting virtqueue */ +#define VIRTIO_BALLOON_F_WS_REPORTING 6 /* Working set report virtqueues */ =20 /* Size of a PFN in the balloon interface. */ #define VIRTIO_BALLOON_PFN_SHIFT 12 @@ -59,6 +60,9 @@ struct virtio_balloon_config { }; /* Stores PAGE_POISON if page poisoning is in use */ uint32_t poison_val; + /* Stores the number of histogram bins if WS reporting in use */ + uint8_t working_set_num_bins; + uint8_t padding[3]; }; =20 #define VIRTIO_BALLOON_S_SWAP_IN 0 /* Amount of memory swapped in */ @@ -116,4 +120,20 @@ struct virtio_balloon_stat { __virtio64 val; } QEMU_PACKED; =20 +enum virtio_balloon_working_set_op { + VIRTIO_BALLOON_WS_REQUEST =3D 1, /* a Working Set request from the hos= t */ + VIRTIO_BALLOON_WS_CONFIG =3D 2, /* a Working Set config from the host= */ +}; + +struct virtio_balloon_working_set { + /* A tag for additional metadata */ + __virtio16 tag; + /* The NUMA node for this report. */ + __virtio16 node_id; + uint8_t reserved[4]; + __virtio64 idle_age_ms; + /* A bin each for anonymous and file-backed memory. */ + __virtio64 memory_size_bytes[2]; +} QEMU_PACKED; + #endif /* _LINUX_VIRTIO_BALLOON_H */ --=20 2.41.0.rc0.172.g3f132b7071-goog From nobody Fri Mar 29 15:44:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1685053301; cv=none; d=zohomail.com; s=zohoarc; b=eHUEKY3STmPa8U6fofOXLWEhjFiUXrt+8ok5lMYlzLcfOsX7sslEd0Ro4kq67nv+lpBT0zR8k0jP8It1ioOFViRvkzr5GqvXgIpqPDhnkkjO09umy4n6c0qh/MVK2IJojS4OR2BMXsrM7/X0R1wVVQYBIq2U4c2ZLg4V4oCW4IY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685053301; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y0fzL/+svKRfui1lk596I4QM9Yoz7EeoVyPyltQze/Y=; b=i1WOREgQDIoqDd2qYMUj5irPlalUSNJYjMb7ohkF8JkSC84f6I9649WiVkhePmlNBbTVmXUpOvjSvTlUdQBB652St5PoPm3rJj+bBlXke+XIuJJYApNxTeLvMnRL0K/pwC3GqEhY4lL5/bIl9fWPcN/AIIUVKcuZ6RmJUotu34I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685053301658155.20093947384657; Thu, 25 May 2023 15:21:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2JJr-00025Q-Vb; Thu, 25 May 2023 18:20:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3Jt9vZAgKCs0Ct4D5utDz77z4x.v759x5D-wxEx4676z6D.7Az@flex--talumbau.bounces.google.com>) id 1q2JJq-00024p-7X for qemu-devel@nongnu.org; Thu, 25 May 2023 18:20:26 -0400 Received: from mail-io1-xd4a.google.com ([2607:f8b0:4864:20::d4a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3Jt9vZAgKCs0Ct4D5utDz77z4x.v759x5D-wxEx4676z6D.7Az@flex--talumbau.bounces.google.com>) id 1q2JJo-0004R1-2Q for qemu-devel@nongnu.org; Thu, 25 May 2023 18:20:25 -0400 Received: by mail-io1-xd4a.google.com with SMTP id ca18e2360f4ac-772d796bbe5so15828939f.2 for ; Thu, 25 May 2023 15:20:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685053223; x=1687645223; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Y0fzL/+svKRfui1lk596I4QM9Yoz7EeoVyPyltQze/Y=; b=Dl4icuFiLdPlv6UEgxtS5UdRjWmbQrwaoSkEU9ey4Zt7xymLd/Be9o5z+9WAl2l0b9 /TdvnI+7Ox1KqKW7FKonO+NFo7MIjdIW0dhM+lZmfOmOHCnUldYp7oDN6dPI0qoM2VmX BRJSyOmAq4pJFlx3GhK5r8E6RoTxc0p/dM1nKMtv/+gDdadnjwvNCMShtHGWxbCxtCto gzVhUtWL6QP0oB/PaMclMAu4qTNo9L1eUQuq6OIWpReybkOwn8szfx+HI6sIDPxSh3U1 Ok/Xl5MWi/CXZVU3qm6spAqMtkCO3fQtTra5iYrgCh2lv4vjhNdV5dBloTW0ynPFM12n PSlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685053223; x=1687645223; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Y0fzL/+svKRfui1lk596I4QM9Yoz7EeoVyPyltQze/Y=; b=DwEpfpPEMQ14dWCF4HAhxOfBt0P4Ymavm3CLfVtcO3CjFsC3IxZnZ/3k3wRghtL92D KI67n1cb5IxcMXxvP4yjikOA581MrkTTI6wT6yhosS0zCOKiOnlIsLRMCCLZtnbhKLgh ATxl4RdX7AP3E0eoJswKlGgFmVaDSILa2ctca7TUHs+sgBceSNbPxUMlIGp9NwaovmeU X4XmsG7HtMXoYw46v6Fb6XRiPUCLrN34XySgwUjG1Di/z4a31bfX+ACAR25b3ckDu9vq H8hxGpC8LjbzPj+eEmIW0iTi8LRRB239Ma0kI3pQtsQQIZZ8gP5wbHa00OsMYrsx0mmz wnJw== X-Gm-Message-State: AC+VfDzq/GdhUW+PUNVtbhVRjghR/2BsBntuxKkL1E7JGC9HCKqk5BeW K/h80r9MOxAxSjVscUge43BCyzSRu/MnDvfuBFODox9QB0ZXPod6lx3uxDAsKsrntS5hJAfw9u9 AY/AciT3REuT/efcxLxzcLjPklnEu72kNtSFDxM/PfBoEUycJ7rZ6xRKZGrDlScfYRw== X-Google-Smtp-Source: ACHHUZ56oBqZ0JpgvPYGOmieGOIEKAdkODLKSMwXCArw+EkqnPO9r3gabaZEHvF9+ALabPuy0oqZnJlUGqfECg== X-Received: from talumbau.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:90d]) (user=talumbau job=sendgmr) by 2002:a6b:e30b:0:b0:775:3e80:4e3b with SMTP id u11-20020a6be30b000000b007753e804e3bmr679636ioc.2.1685053222906; Thu, 25 May 2023 15:20:22 -0700 (PDT) Date: Thu, 25 May 2023 22:20:13 +0000 In-Reply-To: <20230525222016.35333-1-talumbau@google.com> Mime-Version: 1.0 References: <20230525222016.35333-1-talumbau@google.com> Message-ID: <20230525222016.35333-3-talumbau@google.com> Subject: [RFC PATCH v2 2/5] virtio-balloon: device has Working Set Reporting From: "T.J. Alumbaugh" To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , David Hildenbrand , Yuanchu Xie , Yu Zhao , "Dr. David Alan Gilbert" , Markus Armbruster , Eduardo Habkost , Marcel Apfelbaum , "=?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?=" , Yanan Wang , Eric Blake , "T.J. Alumbaugh" Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::d4a; envelope-from=3Jt9vZAgKCs0Ct4D5utDz77z4x.v759x5D-wxEx4676z6D.7Az@flex--talumbau.bounces.google.com; helo=mail-io1-xd4a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1685053302293100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" - working_set_vq to receive Working Set reports from guest - notification_vq to send config or request to guest - add working set as object property on device Signed-off-by: T.J. Alumbaugh --- hw/virtio/virtio-balloon.c | 164 ++++++++++++++++++++++++++++- include/hw/virtio/virtio-balloon.h | 13 ++- qapi/misc.json | 26 +++++ 3 files changed, 200 insertions(+), 3 deletions(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index d004cf29d2..23481e51b8 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -27,6 +27,7 @@ #include "exec/address-spaces.h" #include "qapi/error.h" #include "qapi/qapi-events-machine.h" +#include "qapi/qapi-visit-misc.h" #include "qapi/visitor.h" #include "trace.h" #include "qemu/error-report.h" @@ -169,6 +170,119 @@ static void balloon_deflate_page(VirtIOBalloon *ballo= on, } } =20 +/* + * reset_working_set - Mark all items in the array as unset + * + * This function needs to be called at device initialization and + * whenever a new Working Set config is specified. + */ +static inline void reset_working_set(VirtIOBalloon *dev) +{ + int i; + for (i =3D 0; i < VIRTIO_BALLOON_WS_NR_BINS; i++) { + dev->ws[i].idle_age =3D 0; + if (dev->ws[i].memory_size_bytes) { + dev->ws[i].memory_size_bytes->anon =3D 0; + dev->ws[i].memory_size_bytes->file =3D 0; + } else { + dev->ws[i].memory_size_bytes =3D g_malloc0(sizeof(MemoryBin)); + } + } +} + +static void virtio_balloon_receive_working_set(VirtIODevice *vdev, + VirtQueue *vq) +{ + VirtIOBalloon *s =3D VIRTIO_BALLOON(vdev); + VirtQueueElement *elem; + VirtIOBalloonWorkingSet ws; + size_t offset =3D 0; + int count =3D 0; + + elem =3D virtqueue_pop(vq, sizeof(VirtQueueElement)); + if (!elem) { + return; + } + + if (s->working_set_vq_elem !=3D NULL) { + /* This should never happen if the driver follows the spec. */ + virtqueue_push(vq, s->working_set_vq_elem, 0); + virtio_notify(vdev, vq); + g_free(s->working_set_vq_elem); + } + + s->working_set_vq_elem =3D elem; + + /* Initialize the Working Set to get rid of any stale values. */ + reset_working_set(s); + + while (iov_to_buf(elem->out_sg, elem->out_num, offset, &ws, + sizeof(ws)) =3D=3D sizeof(ws)) { + uint64_t idle_age_ms =3D virtio_tswap64(vdev, ws.idle_age_ms); + uint64_t bytes_anon =3D virtio_tswap64(vdev, ws.memory_size_bytes[= 0]); + uint64_t bytes_file =3D virtio_tswap64(vdev, ws.memory_size_bytes[= 1]); + s->ws[count].idle_age =3D idle_age_ms; + s->ws[count].memory_size_bytes->anon =3D bytes_anon; + s->ws[count].memory_size_bytes->file =3D bytes_file; + offset +=3D sizeof(ws); + count++; + } +} + +static __attribute__((unused)) void virtio_balloon_send_working_set_reques= t( + VirtIODevice *vdev, VirtQueue *vq) +{ + VirtQueueElement *elem; + size_t sz =3D 0; + uint16_t tag =3D 0; + + elem =3D virtqueue_pop(vq, sizeof(VirtQueueElement)); + if (!elem) { + return; + } + tag =3D VIRTIO_BALLOON_WS_REQUEST; + sz =3D iov_from_buf(elem->in_sg, elem->in_num, 0, &tag, sizeof(tag)); + assert(sz =3D=3D sizeof(tag)); + virtqueue_push(vq, elem, sz); + virtio_notify(vdev, vq); + g_free(elem); +} + +static __attribute__((unused)) void virtio_balloon_send_working_set_config( + VirtIODevice *vdev, VirtQueue *vq, + uint64_t i0, uint64_t i1, uint64_t i2, + uint64_t refresh, uint64_t report) +{ + VirtIOBalloon *s =3D VIRTIO_BALLOON(vdev); + VirtQueueElement *elem; + uint16_t tag =3D 0; + size_t sz =3D 0; + elem =3D virtqueue_pop(vq, sizeof(VirtQueueElement)); + if (!elem) { + return; + } + + tag =3D VIRTIO_BALLOON_WS_CONFIG; + s->ws_intervals[0] =3D i0; + s->ws_intervals[1] =3D i1; + s->ws_intervals[2] =3D i2; + s->ws_refresh_threshold =3D refresh; + s->ws_report_threshold =3D report; + + sz =3D iov_from_buf(elem->in_sg, elem->in_num, 0, &tag, sizeof(tag)); + assert(sz =3D=3D sizeof(uint16_t)); + sz +=3D iov_from_buf(elem->in_sg, elem->in_num, sz, s->ws_intervals, + (VIRTIO_BALLOON_WS_NR_BINS - 1) * \ + sizeof(s->ws_intervals[0])); + sz +=3D iov_from_buf(elem->in_sg, elem->in_num, sz, &s->ws_refresh_thr= eshold, + sizeof(uint64_t)); + sz +=3D iov_from_buf(elem->in_sg, elem->in_num, sz, &s->ws_report_thre= shold, + sizeof(uint64_t)); + virtqueue_push(vq, elem, sz); + virtio_notify(vdev, vq); + g_free(elem); +} + static const char *balloon_stat_names[] =3D { [VIRTIO_BALLOON_S_SWAP_IN] =3D "stat-swap-in", [VIRTIO_BALLOON_S_SWAP_OUT] =3D "stat-swap-out", @@ -697,8 +811,11 @@ static size_t virtio_balloon_config_size(VirtIOBalloon= *s) if (s->qemu_4_0_config_size) { return sizeof(struct virtio_balloon_config); } + if (virtio_has_feature(features, VIRTIO_BALLOON_F_WS_REPORTING)) { + return sizeof(struct virtio_balloon_config); + } if (virtio_has_feature(features, VIRTIO_BALLOON_F_PAGE_POISON)) { - return sizeof(struct virtio_balloon_config); + return offsetof(struct virtio_balloon_config, working_set_num_bins= ); } if (virtio_has_feature(features, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) { return offsetof(struct virtio_balloon_config, poison_val); @@ -714,6 +831,7 @@ static void virtio_balloon_get_config(VirtIODevice *vde= v, uint8_t *config_data) config.num_pages =3D cpu_to_le32(dev->num_pages); config.actual =3D cpu_to_le32(dev->actual); config.poison_val =3D cpu_to_le32(dev->poison_val); + config.working_set_num_bins =3D (uint8_t) VIRTIO_BALLOON_WS_NR_BINS; =20 if (dev->free_page_hint_status =3D=3D FREE_PAGE_HINT_S_REQUESTED) { config.free_page_hint_cmd_id =3D @@ -748,6 +866,14 @@ static bool virtio_balloon_page_poison_support(void *o= paque) return virtio_vdev_has_feature(vdev, VIRTIO_BALLOON_F_PAGE_POISON); } =20 +static bool virtio_balloon_working_set_reporting_support(void *opaque) +{ + VirtIOBalloon *s =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(s); + + return virtio_vdev_has_feature(vdev, VIRTIO_BALLOON_F_WS_REPORTING); +} + static void virtio_balloon_set_config(VirtIODevice *vdev, const uint8_t *config_data) { @@ -766,6 +892,10 @@ static void virtio_balloon_set_config(VirtIODevice *vd= ev, if (virtio_balloon_page_poison_support(dev)) { dev->poison_val =3D le32_to_cpu(config.poison_val); } + dev->working_set_num_bins =3D 0; + if (virtio_balloon_working_set_reporting_support(dev)) { + dev->working_set_num_bins =3D config.working_set_num_bins; + } trace_virtio_balloon_set_config(dev->actual, oldactual); } =20 @@ -775,6 +905,7 @@ static uint64_t virtio_balloon_get_features(VirtIODevic= e *vdev, uint64_t f, VirtIOBalloon *dev =3D VIRTIO_BALLOON(vdev); f |=3D dev->host_features; virtio_add_feature(&f, VIRTIO_BALLOON_F_STATS_VQ); + virtio_add_feature(&f, VIRTIO_BALLOON_F_WS_REPORTING); =20 return f; } @@ -896,6 +1027,13 @@ static void virtio_balloon_device_realize(DeviceState= *dev, Error **errp) virtio_balloon_handle_report); } =20 + if (virtio_has_feature(s->host_features, VIRTIO_BALLOON_F_WS_REPORTING= )) { + s->working_set_vq =3D virtio_add_queue(vdev, 32, + virtio_balloon_receive_working_set); + s->notification_vq =3D virtio_add_queue(vdev, 32, NULL); + } + + reset_working_set(s); reset_stats(s); } =20 @@ -922,6 +1060,12 @@ static void virtio_balloon_device_unrealize(DeviceSta= te *dev) if (s->reporting_vq) { virtio_delete_queue(s->reporting_vq); } + if (s->working_set_vq) { + virtio_delete_queue(s->working_set_vq); + } + if (s->notification_vq) { + virtio_delete_queue(s->notification_vq); + } virtio_cleanup(vdev); } =20 @@ -938,7 +1082,11 @@ static void virtio_balloon_device_reset(VirtIODevice = *vdev) g_free(s->stats_vq_elem); s->stats_vq_elem =3D NULL; } - + if (s->working_set_vq_elem !=3D NULL) { + virtqueue_unpop(s->working_set_vq, s->working_set_vq_elem, 0); + g_free(s->working_set_vq_elem); + s->working_set_vq_elem =3D NULL; + } s->poison_val =3D 0; } =20 @@ -953,6 +1101,16 @@ static void virtio_balloon_set_status(VirtIODevice *v= dev, uint8_t status) virtio_balloon_receive_stats(vdev, s->svq); } =20 + if (!s->working_set_vq_elem && vdev->vm_running && + (status & VIRTIO_CONFIG_S_DRIVER_OK) && + virtqueue_rewind(s->working_set_vq, 1)) { + /* + * poll working set queue for the element we have discarded when t= he VM + * was stopped + */ + virtio_balloon_receive_working_set(vdev, s->working_set_vq); + } + if (virtio_balloon_free_page_support(s)) { /* * The VM is woken up and the iothread was blocked, so signal it to @@ -1011,6 +1169,8 @@ static Property virtio_balloon_properties[] =3D { VIRTIO_BALLOON_F_PAGE_POISON, true), DEFINE_PROP_BIT("free-page-reporting", VirtIOBalloon, host_features, VIRTIO_BALLOON_F_REPORTING, false), + DEFINE_PROP_BIT("working-set", VirtIOBalloon, host_features, + VIRTIO_BALLOON_F_WS_REPORTING, true), /* QEMU 4.0 accidentally changed the config size even when free-page-h= int * is disabled, resulting in QEMU 3.1 migration incompatibility. This * property retains this quirk for QEMU 4.1 machine types. diff --git a/include/hw/virtio/virtio-balloon.h b/include/hw/virtio/virtio-= balloon.h index 5139cf8ab6..a7a6655f50 100644 --- a/include/hw/virtio/virtio-balloon.h +++ b/include/hw/virtio/virtio-balloon.h @@ -17,6 +17,7 @@ =20 #include "standard-headers/linux/virtio_balloon.h" #include "hw/virtio/virtio.h" +#include "qapi/qapi-types-misc.h" #include "sysemu/iothread.h" #include "qom/object.h" =20 @@ -25,7 +26,10 @@ OBJECT_DECLARE_SIMPLE_TYPE(VirtIOBalloon, VIRTIO_BALLOON) =20 #define VIRTIO_BALLOON_FREE_PAGE_HINT_CMD_ID_MIN 0x80000000 =20 +#define VIRTIO_BALLOON_WS_NR_BINS 4 /* Number of bins in Working Set repo= rt */ + typedef struct virtio_balloon_stat VirtIOBalloonStat; +typedef struct virtio_balloon_working_set VirtIOBalloonWorkingSet; =20 typedef struct virtio_balloon_stat_modern { uint16_t tag; @@ -42,13 +46,19 @@ enum virtio_balloon_free_page_hint_status { =20 struct VirtIOBalloon { VirtIODevice parent_obj; - VirtQueue *ivq, *dvq, *svq, *free_page_vq, *reporting_vq; + VirtQueue *ivq, *dvq, *svq, *free_page_vq, *reporting_vq, *working_set= _vq, + *notification_vq; uint32_t free_page_hint_status; uint32_t num_pages; uint32_t actual; uint32_t free_page_hint_cmd_id; uint64_t stats[VIRTIO_BALLOON_S_NR]; + WorkingSetInfo ws[VIRTIO_BALLOON_WS_NR_BINS]; + uint64_t ws_intervals[VIRTIO_BALLOON_WS_NR_BINS - 1]; + uint64_t ws_refresh_threshold; + uint64_t ws_report_threshold; VirtQueueElement *stats_vq_elem; + VirtQueueElement *working_set_vq_elem; size_t stats_vq_offset; QEMUTimer *stats_timer; IOThread *iothread; @@ -71,6 +81,7 @@ struct VirtIOBalloon { =20 bool qemu_4_0_config_size; uint32_t poison_val; + uint8_t working_set_num_bins; }; =20 #endif diff --git a/qapi/misc.json b/qapi/misc.json index ff070ec828..4ba8c74b64 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -550,6 +550,32 @@ 'returns': ['CommandLineOptionInfo'], 'allow-preconfig': true} =20 +## +# @MemoryBin: +# +# A bin of memory with a size in bytes. File-backed and +# anonymous memory are tracked separately. +# +# @anon: number of bytes of anonymous memory +# @file: number of bytes of file-backed memory +## +{ 'struct': 'MemoryBin', + 'data': { 'anon': 'uint64', + 'file': 'uint64' } } + +## +# @WorkingSetInfo: +# +# A bin of memory of the given size that has been idle at most `idle-age` = ms +# +# @idle-age: guest-relative time (in milliseconds) +# +# @memory-size-bytes: A MemoryBin with file and anon info. +## +{ 'struct': 'WorkingSetInfo', + 'data': { 'idle-age': 'uint64', + 'memory-size-bytes': 'MemoryBin' } } + ## # @RTC_CHANGE: # --=20 2.41.0.rc0.172.g3f132b7071-goog From nobody Fri Mar 29 15:44:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1685053280; cv=none; d=zohomail.com; s=zohoarc; b=mDJezkFnJl14S8VywJWA8PipB0GREL9yrTHEX88us+iyV6YgyiVGv5VSVq6HMCbW7DQ3hhAEXX77768/aPUyiSWQofslYJKp1t36dTgNmCJeICETQ4v31DyTaYhXLoIXIzz3wGn2HDa1u3hPZ0P1pd0nxUXzefrBmQ73ZP2kQjI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685053280; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ubBrZ8nAFimVTuMHp6nxPEPus94HZpyzs0dejBNFzO8=; b=QrKgn2Y6y/llqiNP8lrsThPTGsd2ZE8U02QnwKxCkuVYhYivKEBLpwrb1qcqvbx5aJ/yLtyUnN9972/Xtp5T6vU9SYzgGHXZUGqgwV3vqsVGgjuu8hsrYDzDtYUOTMTol5iCme4bzrAOhA6KUoYN059UwbbGxpvika9+MFjfRmo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168505328025960.416598782444794; Thu, 25 May 2023 15:21:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2JJt-00026A-An; Thu, 25 May 2023 18:20:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3J99vZAgKCs4Du5E6vuE08805y.w86Ay6E-xyFy578707E.8B0@flex--talumbau.bounces.google.com>) id 1q2JJr-00025D-Oy for qemu-devel@nongnu.org; Thu, 25 May 2023 18:20:27 -0400 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3J99vZAgKCs4Du5E6vuE08805y.w86Ay6E-xyFy578707E.8B0@flex--talumbau.bounces.google.com>) id 1q2JJp-0004RX-Kb for qemu-devel@nongnu.org; Thu, 25 May 2023 18:20:27 -0400 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5653213f5c0so4263957b3.1 for ; Thu, 25 May 2023 15:20:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685053224; x=1687645224; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ubBrZ8nAFimVTuMHp6nxPEPus94HZpyzs0dejBNFzO8=; b=AK4H1JjLe5gTLfzqHg1BtFZKQi/zr7zix6xMHvV0NeuHVzmAk7V+3Ind0cFHKMfaB5 I7Oh1fQy4xofsDyBVlInP/D6U3kjth7rgZmNfdPYuqYqhFqbE0bI625m+VCF2N4BfUN4 ng+ERCmiyBM6i0gr+gLPE5lGiB1OdfWDIpR3Y8kYUnVGL+PLDfxZlaE8xf/0j+Dpcb+j fqJ1LKQjQ5tYyaqSM6cEYm+e7xDZwmyIBBeYiCHhKUUwkNV6imXHp50+QkDKpr7BTSb2 W4MyU+NvMvTRv/D3UTX/4ZLl2rtdnozOngnmqXAS97mt/3puxSU4QvOttRV6XftLpaTT TPdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685053224; x=1687645224; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ubBrZ8nAFimVTuMHp6nxPEPus94HZpyzs0dejBNFzO8=; b=Ks93OJ330uNekzt4rGMGWiKZZWkOqMd5F9wLmKayBQexQ5zenjLEiIW54ik2NAJY5t 6AVQRVr4nj49+82paLJ3z6BtQA2G6y7xGAG2sja+5yjqiLRabrHGYI15Hx6LeIwYfXuK QrI86zmlBU1+tELuckS+VD3txFb/D3JrberJZF9Vlc7FB8HIUWoyjIlDkRoRiNo7jjNw eQWHi9ebcJOmdA9iCP4TXEKPMzhGKZT0pZQdFRT60oks9R8hxfDjCP7F7+j+k1ggkbKW oWaXGfczPiPPw9GueIWUI8/YxE8wQv3frhK3DrCAb5u1k92LeXj+aDcnN8v/MHQTWASJ yBww== X-Gm-Message-State: AC+VfDwDbGXsdy9mDDglCFIpCXAIbQpJqAVRx2qrAqOUiHKElS3UnKwy 8lS7j3NjcqpZo4sJvVXYne+osOBCiXqeqo1Yjx3v9GIVgEOlFRUepY2K1d20OBnm7dQA2OU8S5X Twd4gUfnwAg7nlP7OB30pnq+Do+1z7me9HgoPMqci3UTzVIk3bZcFhWesvVC4djsb2Q== X-Google-Smtp-Source: ACHHUZ5JVlUlU+5wCi9Z5u/PMrQm7zDS3WBItQthIFah5CX+c88JqRlG2X6T304HtQVogPD1MZ6gYKlzTKwLrw== X-Received: from talumbau.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:90d]) (user=talumbau job=sendgmr) by 2002:a81:e707:0:b0:55a:5aa0:ffe9 with SMTP id x7-20020a81e707000000b0055a5aa0ffe9mr612608ywl.7.1685053223961; Thu, 25 May 2023 15:20:23 -0700 (PDT) Date: Thu, 25 May 2023 22:20:14 +0000 In-Reply-To: <20230525222016.35333-1-talumbau@google.com> Mime-Version: 1.0 References: <20230525222016.35333-1-talumbau@google.com> Message-ID: <20230525222016.35333-4-talumbau@google.com> Subject: [RFC PATCH v2 3/5] virtio-balloon: Add QMP functions for Working Set From: "T.J. Alumbaugh" To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , David Hildenbrand , Yuanchu Xie , Yu Zhao , "Dr. David Alan Gilbert" , Markus Armbruster , Eduardo Habkost , Marcel Apfelbaum , "=?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?=" , Yanan Wang , Eric Blake , "T.J. Alumbaugh" Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::114a; envelope-from=3J99vZAgKCs4Du5E6vuE08805y.w86Ay6E-xyFy578707E.8B0@flex--talumbau.bounces.google.com; helo=mail-yw1-x114a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1685053282312100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" - Adds QMP function 'working-set-config' - Adds QMP function 'working-set-request' - Retrieve working set via 'guest-working-set' property on balloon >> cat script.py NAME =3D "name" SOCKET =3D 'vm.sock' BALLOON =3D "/machine/peripheral/balloon0" import json import asyncio from qemu.qmp import QMPClient async def main(): client =3D QMPClient(NAME) await client.connect(SOCKET) config =3D { "i0": 200, "i1": 800, "i2": 3000, "refresh": 750, "report"= : 1000 } await client.execute('working-set-config', config) await client.execute('working-set-request') property =3D {"path":BALLOON, "property":"guest-working-set"} res =3D await client.execute('qom-get', property) return res if __name__ =3D=3D "__main__": ret =3D asyncio.run(main()) print(json.dumps(ret, indent=3D2)) >> (Execute qemu with flag '-qmp unix:path=3Dvm.sock,server=3Don,wait=3Doff' >> (Perform normal activities on VM to exercise MM code) >> python3 script.py { "working_set": { "ws3": { "memory-size-bytes": { "anon": 890478592, "file": 1285832704 }, "idle-age": 4294967292 }, "ws2": { "memory-size-bytes": { "anon": 173465600, "file": 83353600 }, "idle-age": 3000 }, "ws1": { "memory-size-bytes": { "anon": 44236800, "file": 20889600 }, "idle-age": 800 }, "ws0": { "memory-size-bytes": { "anon": 14540800, "file": 6963200 }, "idle-age": 200 } } } Signed-off-by: T.J. Alumbaugh --- hw/virtio/virtio-balloon-pci.c | 2 + hw/virtio/virtio-balloon.c | 67 ++++++++++++++++++++++++++++++++-- include/sysemu/balloon.h | 9 ++++- monitor/monitor.c | 1 + qapi/machine.json | 66 +++++++++++++++++++++++++++++++++ softmmu/balloon.c | 31 +++++++++++++++- 6 files changed, 170 insertions(+), 6 deletions(-) diff --git a/hw/virtio/virtio-balloon-pci.c b/hw/virtio/virtio-balloon-pci.c index ce2645ba71..7b781c8bab 100644 --- a/hw/virtio/virtio-balloon-pci.c +++ b/hw/virtio/virtio-balloon-pci.c @@ -68,6 +68,8 @@ static void virtio_balloon_pci_instance_init(Object *obj) object_property_add_alias(obj, "guest-stats-polling-interval", OBJECT(&dev->vdev), "guest-stats-polling-interval"); + object_property_add_alias(obj, "guest-working-set", OBJECT(&dev->vdev), + "guest-working-set"); } =20 static const VirtioPCIDeviceTypeInfo virtio_balloon_pci_info =3D { diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 23481e51b8..a124d95534 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -229,7 +229,7 @@ static void virtio_balloon_receive_working_set(VirtIODe= vice *vdev, } } =20 -static __attribute__((unused)) void virtio_balloon_send_working_set_reques= t( +static void virtio_balloon_send_working_set_request( VirtIODevice *vdev, VirtQueue *vq) { VirtQueueElement *elem; @@ -248,7 +248,7 @@ static __attribute__((unused)) void virtio_balloon_send= _working_set_request( g_free(elem); } =20 -static __attribute__((unused)) void virtio_balloon_send_working_set_config( +static void virtio_balloon_send_working_set_config( VirtIODevice *vdev, VirtQueue *vq, uint64_t i0, uint64_t i1, uint64_t i2, uint64_t refresh, uint64_t report) @@ -353,6 +353,43 @@ static void balloon_stats_poll_cb(void *opaque) s->stats_vq_elem =3D NULL; } =20 +static void balloon_working_set_get_all(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + Error *err =3D NULL; + VirtIOBalloon *s =3D VIRTIO_BALLOON(obj); + char ws_buf[4]; + WorkingSetInfo *wsinfo; + int i; + + if (!visit_start_struct(v, name, NULL, 0, &err)) { + goto out; + } + + if (!visit_start_struct(v, "working_set", NULL, 0, &err)) { + goto out_end; + } + for (i =3D 0; i < VIRTIO_BALLOON_WS_NR_BINS; i++) { + wsinfo =3D s->ws + i; + sprintf(ws_buf, "ws%d", i); + if (!visit_type_WorkingSetInfo(v, ws_buf, &wsinfo, &err)) { + goto out_nested; + } + } + visit_check_struct(v, &err); +out_nested: + visit_end_struct(v, NULL); + + if (!err) { + visit_check_struct(v, &err); + } +out_end: + visit_end_struct(v, NULL); +out: + error_propagate(errp, err); +} + static void balloon_stats_get_all(Object *obj, Visitor *v, const char *nam= e, void *opaque, Error **errp) { @@ -917,6 +954,25 @@ static void virtio_balloon_stat(void *opaque, BalloonI= nfo *info) VIRTIO_BALLOON_PFN_SHIFT); } =20 +static void virtio_balloon_working_set_request(void *opaque) +{ + VirtIOBalloon *dev =3D VIRTIO_BALLOON(opaque); + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + + virtio_balloon_send_working_set_request(vdev, dev->notification_vq); +} + +static void virtio_balloon_working_set_config(void *opaque, uint64_t i0, + uint64_t i1, uint64_t i2, + uint64_t refresh, uint64_t r= eport) +{ + VirtIOBalloon *dev =3D VIRTIO_BALLOON(opaque); + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + + virtio_balloon_send_working_set_config(vdev, dev->notification_vq, i0,= i1, + i2, refresh, report); +} + static void virtio_balloon_to_target(void *opaque, ram_addr_t target) { VirtIOBalloon *dev =3D VIRTIO_BALLOON(opaque); @@ -992,7 +1048,9 @@ static void virtio_balloon_device_realize(DeviceState = *dev, Error **errp) virtio_init(vdev, VIRTIO_ID_BALLOON, virtio_balloon_config_size(s)); =20 ret =3D qemu_add_balloon_handler(virtio_balloon_to_target, - virtio_balloon_stat, s); + virtio_balloon_stat, + virtio_balloon_working_set_request, + virtio_balloon_working_set_config, s); =20 if (ret < 0) { error_setg(errp, "Only one balloon device is supported"); @@ -1148,6 +1206,9 @@ static void virtio_balloon_instance_init(Object *obj) balloon_stats_get_poll_interval, balloon_stats_set_poll_interval, NULL, NULL); + + object_property_add(obj, "guest-working-set", "guest working set", + balloon_working_set_get_all, NULL, NULL, NULL); } =20 static const VMStateDescription vmstate_virtio_balloon =3D { diff --git a/include/sysemu/balloon.h b/include/sysemu/balloon.h index 867687b73a..1f504d1a31 100644 --- a/include/sysemu/balloon.h +++ b/include/sysemu/balloon.h @@ -18,10 +18,17 @@ #include "qapi/qapi-types-machine.h" =20 typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target); +typedef void (QEMUBalloonWorkingSetRequest)(void *opaque); +typedef void (QEMUBalloonWorkingSetConfig)(void *opaque, uint64_t i0, + uint64_t i1, uint64_t i2, uint64_t refre= sh, + uint64_t report); typedef void (QEMUBalloonStatus)(void *opaque, BalloonInfo *info); =20 int qemu_add_balloon_handler(QEMUBalloonEvent *event_func, - QEMUBalloonStatus *stat_func, void *opaque); + QEMUBalloonStatus *stat_func, + QEMUBalloonWorkingSetRequest *ws_func, + QEMUBalloonWorkingSetConfig *config_func, + void *opaque); void qemu_remove_balloon_handler(void *opaque); =20 #endif diff --git a/monitor/monitor.c b/monitor/monitor.c index 602535696c..fad1b4aed5 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -333,6 +333,7 @@ static MonitorQAPIEventConf monitor_qapi_event_conf[QAP= I_EVENT__MAX] =3D { [QAPI_EVENT_QUORUM_FAILURE] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_VSERPORT_CHANGE] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE] =3D { 1000 * SCALE_MS }, + [QAPI_EVENT_WORKING_SET_EVENT] =3D { 1000 * SCALE_MS }, }; =20 /* diff --git a/qapi/machine.json b/qapi/machine.json index 37660d8f2a..5e03ff21e2 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1055,6 +1055,57 @@ ## { 'command': 'balloon', 'data': {'value': 'int'} } =20 +## +# @working-set-config: +# +# Specify the config parameters for Working Set reporting. +# +# @i0: the endpoint of the first interval (in ms) +# +# @i1: the endpoint of the second interval (in ms) +# +# @i2: the endpoint of the third interval (in ms) +# +# @refresh: the refresh threshold (in ms) for Working Set reporting +# +# @report: the report threshold (in ms) for Working Set reporting +# +# Returns: - Nothing on success +# - If no balloon device is present, DeviceNotActive +# +# Example: +# +# -> { "execute": "working-set-config", +# "arguments": { "i0": 100, +# "i1": 500, +# "i2": 2000, +# "refresh": 750, +# "report": 1000 } } +# <- { "return": {} } +# +## +{ 'command': 'working-set-config', 'data': {'i0': 'uint64', + 'i1': 'uint64', + 'i2': 'uint64', + 'refresh': 'uint64', + 'report': 'uint64'} } +## +# @working-set-request: +# +# Request the Working Set report from the guest. +# +# Returns: - Nothing on success +# - If no balloon device is present, DeviceNotActive +# +# Example: +# +# -> { "execute": "working-set-request", "arguments": {} } +# <- { "return": {} } +# +## +{ 'command': 'working-set-request', 'data': {} } + + ## # @BalloonInfo: # @@ -1113,6 +1164,21 @@ { 'event': 'BALLOON_CHANGE', 'data': { 'actual': 'int' } } =20 +## +# @WORKING_SET_EVENT: +# +# Emitted when the guest sends a new Working Set report. +# +# Note: this event is rate-limited. +# +# Example: +# +# <- { "event": "WORKING_SET_EVENT", +# "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } +# +## +{ 'event': 'WORKING_SET_EVENT' } + ## # @MemoryInfo: # diff --git a/softmmu/balloon.c b/softmmu/balloon.c index e0e8969a4b..f27852949a 100644 --- a/softmmu/balloon.c +++ b/softmmu/balloon.c @@ -35,6 +35,8 @@ =20 static QEMUBalloonEvent *balloon_event_fn; static QEMUBalloonStatus *balloon_stat_fn; +static QEMUBalloonWorkingSetRequest *balloon_ws_request_fn; +static QEMUBalloonWorkingSetConfig *balloon_ws_config_fn; static void *balloon_opaque; =20 static bool have_balloon(Error **errp) @@ -53,9 +55,13 @@ static bool have_balloon(Error **errp) } =20 int qemu_add_balloon_handler(QEMUBalloonEvent *event_func, - QEMUBalloonStatus *stat_func, void *opaque) + QEMUBalloonStatus *stat_func, + QEMUBalloonWorkingSetRequest *ws_request_func, + QEMUBalloonWorkingSetConfig *ws_config_func, + void *opaque) { - if (balloon_event_fn || balloon_stat_fn || balloon_opaque) { + if (balloon_event_fn || balloon_stat_fn || balloon_ws_request_fn \ + || balloon_ws_config_fn || balloon_opaque) { /* We're already registered one balloon handler. How many can * a guest really have? */ @@ -63,6 +69,8 @@ int qemu_add_balloon_handler(QEMUBalloonEvent *event_func, } balloon_event_fn =3D event_func; balloon_stat_fn =3D stat_func; + balloon_ws_request_fn =3D ws_request_func; + balloon_ws_config_fn =3D ws_config_func; balloon_opaque =3D opaque; return 0; } @@ -104,3 +112,22 @@ void qmp_balloon(int64_t target, Error **errp) trace_balloon_event(balloon_opaque, target); balloon_event_fn(balloon_opaque, target); } + +void qmp_working_set_request(Error **errp) +{ + if (!have_balloon(errp)) { + return; + } + + balloon_ws_request_fn(balloon_opaque); +} + +void qmp_working_set_config(uint64_t i0, uint64_t i1, uint64_t i2, + uint64_t refresh, uint64_t report, Error **err= p) +{ + if (!have_balloon(errp)) { + return; + } + + balloon_ws_config_fn(balloon_opaque, i0, i1, i2, refresh, report); +} --=20 2.41.0.rc0.172.g3f132b7071-goog From nobody Fri Mar 29 15:44:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1685053312; cv=none; d=zohomail.com; s=zohoarc; b=cDbvpFR3lQx3bHUrwzVXoCoEx8Z2btxsPh5ADhz1qhkgQ5sS/foqj5HOSbr2+c9l2JLwPh3Zf2SfNx7w4DRo0Drz0mCul4jauLQjZbtEMIhVVWbTWI2t7Vq1OrvjPuE2IKP4TbJ4Svd/9VdF2MI3AWfY8c+5+UMMpwKzmziHhb0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685053312; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4cMvgGN5jzGaGfRSZF3eild5fkvOSBVOFI0ZHu7w7Hw=; b=VPdPRIucTd/s3eiW3qWOg4ntgOx2KgBcUIIwrJEIZRgcZp4grYgCWzXY1CQA5mPfLkrrrIXGoD2Z7S7TfaceF42Oj8yvvV3M5chpBrD+RnsYmuxMxOp8DzUjVi/LhJsOQb12+KtLlRBJUQfigHvPNcozqzmg0wVnR4F1dLtp9l8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685053312243911.1428587691006; Thu, 25 May 2023 15:21:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2JJu-00027U-9P; Thu, 25 May 2023 18:20:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3Kd9vZAgKCtAFw7G8xwG2AA270.yA8C08G-z0H079A929G.AD2@flex--talumbau.bounces.google.com>) id 1q2JJs-00025n-JK for qemu-devel@nongnu.org; Thu, 25 May 2023 18:20:28 -0400 Received: from mail-io1-xd49.google.com ([2607:f8b0:4864:20::d49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3Kd9vZAgKCtAFw7G8xwG2AA270.yA8C08G-z0H079A929G.AD2@flex--talumbau.bounces.google.com>) id 1q2JJq-0004SJ-Th for qemu-devel@nongnu.org; Thu, 25 May 2023 18:20:28 -0400 Received: by mail-io1-xd49.google.com with SMTP id ca18e2360f4ac-76c5c78bc24so31556439f.2 for ; Thu, 25 May 2023 15:20:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685053225; x=1687645225; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=4cMvgGN5jzGaGfRSZF3eild5fkvOSBVOFI0ZHu7w7Hw=; b=J+NKjPtLyljqS7tpbK6nNpA5igNAy3Kyp4N11DqBWNqtHhLVMcbpftBk1J+5t8Fnp5 iLODQY4jMS48+wbk3M3qjuEO4pQgGXK2cjIXpxv0LUSZwcgvBqSZCSxnAHfRQLYOIM7P NWiaDbncu9arR05XhhAfVl0g11edH4gh9m1KvLdITijYzOR1fpUNXL/ai10omIUQ2pA5 iKvi70CuT1Mgnc9fAU1r39sCB1ppAKZjCtSEhk0KkzNN5yIPaz545OBLj0zxl2Tu4S6N uaOl9TUnNCJXThJQh98hAIh6/lLpAj+tuQcoOx7EYSQT1MtYWmL7O/s7bt3nbAKGQ08h 8HUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685053225; x=1687645225; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4cMvgGN5jzGaGfRSZF3eild5fkvOSBVOFI0ZHu7w7Hw=; b=dNOTUvCh4EImRCi8TyA/bTESijReUst3v2COMdC9W/T8JdfKJmbtlOjVKEgjB4z/87 uMXtnLN+xg9AvjvoJiasGpXmYAVl4iMTjmM9Vq1YtfMk0JYhNIfZLwQX9aJQn1q11lX8 xGW02JVGKKGcUFOLJ1AqQd2JNrECgKKh7qjqPpWXXHQbtQ5pOPn0W9RxzoP+ZqfOQkmY iXgg2pshxYWR3BKNq3SqA8LBavNVjNWcJyiux7UIFLM6WEmlNiOMfaU3Fs2e5KK3AT6F 7GiDuNeEwGJ9l3126/pmhVSA2OncUU4w+t54ILffUi1V+MQhtBsq6wZ1UkdrW2DVL8KF i1bw== X-Gm-Message-State: AC+VfDw/a+jl+AnQxCPFManps7sK+k3I58e8I2FkaEJdb/L9KirYF0Iu QbQ7apn9HsFhOl9GEmwvBWmmq8WjuzbKApRq6vM5KknUDNVDTA3Gmu+2fr06qAX7ZHpByFB0nTX rnWpoINEVeGkbcTpNWYAUpN4YHb2SPK0MkengLMEMAUMhOaW5dmWnX2ivh8lfyZXhHQ== X-Google-Smtp-Source: ACHHUZ5gSsYihOU/xjt27sq6scp7ahHAdVFG82Kj2KENmUDu43KeiKxciNBupPs6j+hBQ8/VJK0hcR15S6GNdw== X-Received: from talumbau.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:90d]) (user=talumbau job=sendgmr) by 2002:a92:cb44:0:b0:335:479a:8eaa with SMTP id f4-20020a92cb44000000b00335479a8eaamr13163675ilq.6.1685053225074; Thu, 25 May 2023 15:20:25 -0700 (PDT) Date: Thu, 25 May 2023 22:20:15 +0000 In-Reply-To: <20230525222016.35333-1-talumbau@google.com> Mime-Version: 1.0 References: <20230525222016.35333-1-talumbau@google.com> Message-ID: <20230525222016.35333-5-talumbau@google.com> Subject: [RFC PATCH v2 4/5] virtio-balloon: Add HMP functions for Working Set From: "T.J. Alumbaugh" To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , David Hildenbrand , Yuanchu Xie , Yu Zhao , "Dr. David Alan Gilbert" , Markus Armbruster , Eduardo Habkost , Marcel Apfelbaum , "=?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?=" , Yanan Wang , Eric Blake , "T.J. Alumbaugh" Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::d49; envelope-from=3Kd9vZAgKCtAFw7G8xwG2AA270.yA8C08G-z0H079A929G.AD2@flex--talumbau.bounces.google.com; helo=mail-io1-xd49.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1685053313306100007 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" - Adds 'working_set_request', 'working_set_config' HMP functions Start qemu with '-monitor telnet:127.0.0.1:4444,server=3Don,wait=3Doff' >> telnet localhost 4444 (qemu) working_set_config 200 800 3000 750 1000 (qemu) working_set_request (qemu) qom-get /machine/peripheral/balloon0 guest-working-set { "working_set": { "ws3": { "memory-size-bytes": { "anon": 298287104, "file": 647041024 }, "idle-age": 4294967292 }, "ws2": { "memory-size-bytes": { "anon": 4505600, "file": 2252800 }, "idle-age": 3000 }, "ws1": { "memory-size-bytes": { "anon": 1228800, "file": 614400 }, "idle-age": 800 }, "ws0": { "memory-size-bytes": { "anon": 409600, "file": 204800 }, "idle-age": 200 } } } Signed-off-by: T.J. Alumbaugh --- hmp-commands.hx | 26 ++++++++++++++++++++++++++ hw/core/machine-hmp-cmds.c | 21 +++++++++++++++++++++ include/monitor/hmp.h | 2 ++ 3 files changed, 49 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 2cbd0f77a0..8ed044b23f 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1398,6 +1398,32 @@ SRST Request VM to change its memory allocation to *value* (in MB). ERST =20 + { + .name =3D "working_set_config", + .args_type =3D "i0:i,i1:i,i2:i,refresh:i,report:i", + .params =3D "bin intervals 0-2, refresh and report thresholds", + .help =3D "Working Set intervals, refresh/report thresholds = (ms)", + .cmd =3D hmp_working_set_config, + }, + +SRST +``working_set_config`` + Set the intervals (in ms), refresh, report thresholds for Working Set re= porting +ERST + + { + .name =3D "working_set_request", + .args_type =3D "", + .params =3D "", + .help =3D "Request the Working Set of the guest.", + .cmd =3D hmp_working_set_request, + }, + +SRST +``working_set_request`` + Request the Working Set from the guest. +ERST + { .name =3D "set_link", .args_type =3D "name:s,up:b", diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c index c3e55ef9e9..3c0a7694a2 100644 --- a/hw/core/machine-hmp-cmds.c +++ b/hw/core/machine-hmp-cmds.c @@ -237,6 +237,27 @@ void hmp_balloon(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, err); } =20 +void hmp_working_set_request(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + + qmp_working_set_request(&err); + hmp_handle_error(mon, err); +} + +void hmp_working_set_config(Monitor *mon, const QDict *qdict) +{ + uint64_t i0 =3D qdict_get_int(qdict, "i0"); + uint64_t i1 =3D qdict_get_int(qdict, "i1"); + uint64_t i2 =3D qdict_get_int(qdict, "i2"); + uint64_t refresh =3D qdict_get_int(qdict, "refresh"); + uint64_t report =3D qdict_get_int(qdict, "report"); + Error *err =3D NULL; + + qmp_working_set_config(i0, i1, i2, refresh, report, &err); + hmp_handle_error(mon, err); +} + void hmp_info_memory_devices(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 13f9a2dedb..a1e6c5e92a 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -59,6 +59,8 @@ void hmp_nmi(Monitor *mon, const QDict *qdict); void hmp_info_network(Monitor *mon, const QDict *qdict); void hmp_set_link(Monitor *mon, const QDict *qdict); void hmp_balloon(Monitor *mon, const QDict *qdict); +void hmp_working_set_config(Monitor *mon, const QDict *qdict); +void hmp_working_set_request(Monitor *mon, const QDict *qdict); void hmp_loadvm(Monitor *mon, const QDict *qdict); void hmp_savevm(Monitor *mon, const QDict *qdict); void hmp_delvm(Monitor *mon, const QDict *qdict); --=20 2.41.0.rc0.172.g3f132b7071-goog From nobody Fri Mar 29 15:44:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1685053312; cv=none; d=zohomail.com; s=zohoarc; b=HPhatjCeV2HSRFKSGUl0ORgot6I5RzsjFvneZYnrd3hmZToX1Br6d9MZAMr0OirG+TaB2CQ+IkNdGlA7emR/vJaMUJWcoBV3dSrKAL29RxfvfhvyaINJpNWNd0vu9kYzwluugCfKIENU0E7CS/B1MfIxdensyPR7HXOSrGTY/s4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685053312; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dXTJKsxDTe67YZh46ME8kW+SA4qfuw4NaZ0bmQilNWE=; b=EEXqUF969KhVXesI4KmD9iHGZcvmpJFFFz1EdhyhVGlZ/wcGGeDtMJptoefKun/JfFagcYoLzFbsnKPVPVEo6TQIBS8jlPeY+4WeKx++pRQgRYbAKZqqpvDQkNmbdR9mdaFuhudr3d8cVtgh/SLHK6e6ex4GB4eVMzwbq8EIpzE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685053312902643.0336016307848; Thu, 25 May 2023 15:21:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2JJu-00027t-VZ; Thu, 25 May 2023 18:20:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3Kt9vZAgKCtEGx8H9yxH3BB381.zB9D19H-01I18ABA3AH.BE3@flex--talumbau.bounces.google.com>) id 1q2JJt-00026C-CQ for qemu-devel@nongnu.org; Thu, 25 May 2023 18:20:29 -0400 Received: from mail-io1-xd4a.google.com ([2607:f8b0:4864:20::d4a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3Kt9vZAgKCtEGx8H9yxH3BB381.zB9D19H-01I18ABA3AH.BE3@flex--talumbau.bounces.google.com>) id 1q2JJr-0004Sm-Ss for qemu-devel@nongnu.org; Thu, 25 May 2023 18:20:29 -0400 Received: by mail-io1-xd4a.google.com with SMTP id ca18e2360f4ac-76c63aadc10so22417739f.0 for ; Thu, 25 May 2023 15:20:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685053226; x=1687645226; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=dXTJKsxDTe67YZh46ME8kW+SA4qfuw4NaZ0bmQilNWE=; b=UOu2xcjFJYAQuNiI7eLotxMiEeM3EaSyQY01FvDz1ndyblg897FZXJNyFvPS/5/F+O 5Djubuq+huZGzB7g+6pVqUTd1RgUmfs3sexIHtS5HYSZDvhr+HedFKzXsV1fjtbW1P9Z Z1Bw5nHw3pNuZ6QCBjpfd+dLgE3hZYx5F12UVhONpIeN5Qn9PNUuq0wsScyvhIZdQb0a FotNn3cvSfRu6RsIPXHMS/NgislhRtbldTyBX6+cnHiYWJ7YjkpVM4FAF72aPmifPX3+ A28ocO3erReX32C6XmCfnKXxURIYjNSHC69dOQ1/2oFT9lxDttP+nTfGDPYWUeD1FY2S jOdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685053226; x=1687645226; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dXTJKsxDTe67YZh46ME8kW+SA4qfuw4NaZ0bmQilNWE=; b=LYDAR4SRK6d0wyFcJq2BatSXeBIRaaAaPryye7584jy1Jiki3zbPyP/eIEGiJUYmTI 68ZoriwkTavN3SryF2gRnPERym5ODA/EN4XVQrt2hKUp1UD4Xp3OH+w1OwHd6l9OgS20 yP5/RmyI0tUJfjO6YdCDfsUlkhA6N/0FFxSLjIZ5B+ermUNwhtYLRull2E/Gyqc1Itp9 WmbpBpbJdm6ZxBnHbzOZLUaWiEhFNxibKZcd1QVS+Z1FRODKO6Dd2TVkZ3TqxEZXyLbR ftzZSwgLpGEtUxyL5inuTdYMV3lUb8zeKreryJqwU6Bsm+kkMXFAlcw5szECJDCEl4Gp vrqw== X-Gm-Message-State: AC+VfDyINCt36j9AhMbpFy9KWNOJdz/MMhtvPqpGc7HAZ7e+bSr9/IOL RFj1/43euq2HzJCNwHhqnLOvGxiti/3FoYxI6EJtiDyhv2gqpOikI/PoUiko9hfJOWKuNHW+dxJ MJeLsrgMaTJ8ldmYbG6klOucw13huaIic0II3NMOGTnnDxBGA5WeHLb+WzZC+shH/fQ== X-Google-Smtp-Source: ACHHUZ4E1/FJae49eWgTywoEBwfGC/2mWQAU+7bv29m97Dhc3Q88IAbO6poIfSPDN5nYV5V7sVkmOvDNhGqXyg== X-Received: from talumbau.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:90d]) (user=talumbau job=sendgmr) by 2002:a6b:8d57:0:b0:774:89bd:c6cc with SMTP id p84-20020a6b8d57000000b0077489bdc6ccmr879670iod.2.1685053226152; Thu, 25 May 2023 15:20:26 -0700 (PDT) Date: Thu, 25 May 2023 22:20:16 +0000 In-Reply-To: <20230525222016.35333-1-talumbau@google.com> Mime-Version: 1.0 References: <20230525222016.35333-1-talumbau@google.com> Message-ID: <20230525222016.35333-6-talumbau@google.com> Subject: [RFC PATCH v2 5/5] virtio-balloon: Migration of working set config From: "T.J. Alumbaugh" To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , David Hildenbrand , Yuanchu Xie , Yu Zhao , "Dr. David Alan Gilbert" , Markus Armbruster , Eduardo Habkost , Marcel Apfelbaum , "=?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?=" , Yanan Wang , Eric Blake , "T.J. Alumbaugh" Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::d4a; envelope-from=3Kt9vZAgKCtEGx8H9yxH3BB381.zB9D19H-01I18ABA3AH.BE3@flex--talumbau.bounces.google.com; helo=mail-io1-xd4a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1685053314151100009 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Migrate working_set_num_bins through VMStateDescription. Signed-off-by: T.J. Alumbaugh --- hw/virtio/virtio-balloon.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index a124d95534..6e1646abfd 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -1022,6 +1022,17 @@ static const VMStateDescription vmstate_virtio_ballo= on_page_poison =3D { } }; =20 +static const VMStateDescription vmstate_virtio_balloon_working_set_reporti= ng =3D { + .name =3D "virtio-balloon-device/working-set-report", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D virtio_balloon_working_set_reporting_support, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(working_set_num_bins, VirtIOBalloon), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_virtio_balloon_device =3D { .name =3D "virtio-balloon-device", .version_id =3D 1, @@ -1035,6 +1046,7 @@ static const VMStateDescription vmstate_virtio_balloo= n_device =3D { .subsections =3D (const VMStateDescription * []) { &vmstate_virtio_balloon_free_page_hint, &vmstate_virtio_balloon_page_poison, + &vmstate_virtio_balloon_working_set_reporting, NULL } }; --=20 2.41.0.rc0.172.g3f132b7071-goog