From patchwork Fri Apr 24 16:50:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11508649 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 727E881 for ; Fri, 24 Apr 2020 16:52:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 476F420728 for ; Fri, 24 Apr 2020 16:52:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RE2S7v1K" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 476F420728 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:44684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jS1Yv-0003B4-C5 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 24 Apr 2020 12:52:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57258) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jS1Wo-00087j-1T for qemu-devel@nongnu.org; Fri, 24 Apr 2020 12:50:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jS1Wn-0000o7-HG for qemu-devel@nongnu.org; Fri, 24 Apr 2020 12:50:13 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:34710) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jS1Wn-0000mN-3a for qemu-devel@nongnu.org; Fri, 24 Apr 2020 12:50:13 -0400 Received: by mail-pf1-x442.google.com with SMTP id x15so5072115pfa.1 for ; Fri, 24 Apr 2020 09:50:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=XWQH+WqkRfp4wJIRuWJ29KttjuuuSpzbvrw8QWn/fPk=; b=RE2S7v1K6xmMobGdD+T0/61rZlmenR1uTKY2g1z1qGjzKAysz5jtSFNw/rQx3YAOKS eV8oVuy3/68YQ2wuAHm3SO4zHNlrOqty36Yog0JqRbq4OsXlWwJjrQmmehyyO4CW0Zpl y2CANZIYqrlYygCRqXZxDJ5lxDw4JVw+V/AJVBJtuoWOuM51TCPBW0fRAjvZg4/Ot4ux sq2qlTpeZl0RHwqfLP9C0qPyjAVk0esY4e501S8cXXenAKfqWM43AFU5pg756fMyY3Pw yD0WuRGh05t2ljECeZEc9rpUmIi862mGW16mCDAylbiub1Vbak3SPkRzyiGePaSksq9y uOYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=XWQH+WqkRfp4wJIRuWJ29KttjuuuSpzbvrw8QWn/fPk=; b=ABvw1R+yeO8YWGdLnLsq7FNCUlObZwSP3BP3sHStZ9+pXxrN0ijQ0RrmA3Ox+GWCf0 VMpf6ChMAu86rpz6ah63ut8Npvr/DB9CmFdrHqaUobsZRCtwkCUfjjmInRGSVEthiX6i np65Gee9JNGokTx0RJmjwdRyURpUgUgISlm9XbGShxUZxWfi7wRcV+L7Ab0B7ntSIncN TvrH2RWo/Ok/Y73ESG8LFOIzabznT7IIuG7kvZl4xBBlY/ZlXjUEFLVnJ2bIB6za0b5G Wryztpe/6JYo7gKD6ID0fTHvWU27Eq4RSZCdD4YIavUi+e/8+pzzdvf9QvaKqEstSlOL NKZQ== X-Gm-Message-State: AGi0PuZBet61JFqLW0hEMRwioBkSWBeVFMrwXrbRvpRh/Nhk+MjiGGeA pS6TyYvUnmgI+KYbbhk5ViE= X-Google-Smtp-Source: APiQypKMCIo2GluA5DZ7F0doTygsVSKd7t2kU+ExSPzxBfYN0ypcfY5WIwc0cLQyeNRyV+PePXC9ug== X-Received: by 2002:a63:6fce:: with SMTP id k197mr10011919pgc.431.1587747010474; Fri, 24 Apr 2020 09:50:10 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id k63sm5216833pjb.6.2020.04.24.09.50.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Apr 2020 09:50:09 -0700 (PDT) Subject: [PATCH v22 QEMU 1/5] linux-headers: Update to allow renaming of free_page_report_cmd_id From: Alexander Duyck To: david@redhat.com, mst@redhat.com Date: Fri, 24 Apr 2020 09:50:09 -0700 Message-ID: <20200424165009.10723.14503.stgit@localhost.localdomain> In-Reply-To: <20200424164239.10723.58352.stgit@localhost.localdomain> References: <20200424164239.10723.58352.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::442; envelope-from=alexander.duyck@gmail.com; helo=mail-pf1-x442.google.com X-detected-operating-system: by eggs.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2607:f8b0:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Alexander Duyck Sync to the latest upstream changes for free page hinting. To be replaced by a full linux header sync. Signed-off-by: Alexander Duyck --- include/standard-headers/linux/virtio_balloon.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/standard-headers/linux/virtio_balloon.h b/include/standard-headers/linux/virtio_balloon.h index 9375ca2a70de..af0a6b59dab2 100644 --- a/include/standard-headers/linux/virtio_balloon.h +++ b/include/standard-headers/linux/virtio_balloon.h @@ -47,8 +47,15 @@ struct virtio_balloon_config { uint32_t num_pages; /* Number of pages we've actually got in balloon. */ uint32_t actual; - /* Free page report command id, readonly by guest */ - uint32_t free_page_report_cmd_id; + /* + * Free page hint command id, readonly by guest. + * Was previously name free_page_report_cmd_id so we + * need to carry that name for legacy support. + */ + union { + uint32_t free_page_hint_cmd_id; + uint32_t free_page_report_cmd_id; /* deprecated */ + }; /* Stores PAGE_POISON if page poisoning is in use */ uint32_t poison_val; }; From patchwork Fri Apr 24 16:50:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11508645 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 2F95481 for ; Fri, 24 Apr 2020 16:51:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 0499120774 for ; Fri, 24 Apr 2020 16:51:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EemRzCDb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0499120774 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:44592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jS1Xl-000117-VO for patchwork-qemu-devel@patchwork.kernel.org; Fri, 24 Apr 2020 12:51:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57294) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jS1Wv-0008EN-QX for qemu-devel@nongnu.org; Fri, 24 Apr 2020 12:50:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jS1Wu-00010v-1J for qemu-devel@nongnu.org; Fri, 24 Apr 2020 12:50:21 -0400 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]:38030) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jS1Wt-0000uF-IC for qemu-devel@nongnu.org; Fri, 24 Apr 2020 12:50:19 -0400 Received: by mail-pj1-x1043.google.com with SMTP id t40so4099636pjb.3 for ; Fri, 24 Apr 2020 09:50:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=r3DmuhsjF9XmFz6gfXOOjELEtTu/H+9BPOkgH77BTws=; b=EemRzCDbaKqy/dqcEAMINbh5h5JcMSn3eS9kMoP69WvnKQlJpjesk9oBwX34vwLKBx kcPopUunra27JbogMZ1tS3ivZr6EmxTAqMLIHzjJZM7PDznNlgQc616R/kx/A+u9EUhm slEd89EX2NjIsnj7nfcN18HNhVdsXg51YPqofjKmBvXiV483MwJ8ohhq0L9S/w1eBC30 cdUIOgYAsq5Al0stzT0uQgPDmZtbPlKLWCm6svKOajMZ6UgWb1ADW6BvSXrAmwrmUG/Z 77SkSv1YAmysTAIgsK1lP9G31TEcTBM5t57WP6mBpapq6oY/413h2wFCqtJKtJCMjjGO YsFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=r3DmuhsjF9XmFz6gfXOOjELEtTu/H+9BPOkgH77BTws=; b=TjXG0L+VGD9fCb63G+ocJ/iF3CRUau+4/Q4ivthdP7OGMqCBtzA3FeKZ0wEuiO4Vd0 sQ43d2cDPlOS1rEenAWx0RDstnpux8kgEOgIxt4qGpCMCY70mCE6KKl5g+ht9g+5VzyX yIAc4XJrRkcvWCtimee68AwcLtJxrzvKTClHNDXhF825cKYNc0/N00VMsd+JOAoq8UIa 0u2UEP4F3eWXPesPQHWOrPAJ0u7WkzZOQGqpeLFsCsF69c/zWrhy4bDSUDKjKPCzVsVu XokRmWCP7UM5QOlQsB7FAeCP3znR8QfsmnehiNwO8Cu4IU/2ohgBS7NIm9HQ4lekgIJc 51qA== X-Gm-Message-State: AGi0PuYTxXSzA+R+NGnk68Vrt+YpYwYZA3IbW4mLiBVHJQUQOT981KTK XS9wwNyayWrOuTNGwwY143A= X-Google-Smtp-Source: APiQypIszAxIZwIRFgdPQnOSjTPbv9Hloe/QAXMfuVF9EOxxavegxTGMkpzjcnluy4FMDbIfX1Be/Q== X-Received: by 2002:a17:90a:7482:: with SMTP id p2mr7037094pjk.151.1587747016776; Fri, 24 Apr 2020 09:50:16 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id v64sm6321768pfb.20.2020.04.24.09.50.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Apr 2020 09:50:16 -0700 (PDT) Subject: [PATCH v22 QEMU 2/5] linux-headers: update to contain virito-balloon free page reporting From: Alexander Duyck To: david@redhat.com, mst@redhat.com Date: Fri, 24 Apr 2020 09:50:15 -0700 Message-ID: <20200424165015.10723.78092.stgit@localhost.localdomain> In-Reply-To: <20200424164239.10723.58352.stgit@localhost.localdomain> References: <20200424164239.10723.58352.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1043; envelope-from=alexander.duyck@gmail.com; helo=mail-pj1-x1043.google.com X-detected-operating-system: by eggs.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2607:f8b0:4864:20::1043 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Alexander Duyck Sync the latest upstream changes for free page reporting. To be replaced by a full linux header sync. Signed-off-by: Alexander Duyck --- include/standard-headers/linux/virtio_balloon.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/standard-headers/linux/virtio_balloon.h b/include/standard-headers/linux/virtio_balloon.h index af0a6b59dab2..af3b7a1fa263 100644 --- a/include/standard-headers/linux/virtio_balloon.h +++ b/include/standard-headers/linux/virtio_balloon.h @@ -36,6 +36,7 @@ #define VIRTIO_BALLOON_F_DEFLATE_ON_OOM 2 /* Deflate balloon on OOM */ #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 */ /* Size of a PFN in the balloon interface. */ #define VIRTIO_BALLOON_PFN_SHIFT 12 From patchwork Fri Apr 24 16:50:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11508653 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 52DC815AB for ; Fri, 24 Apr 2020 16:54:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 16ED020728 for ; Fri, 24 Apr 2020 16:54:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CzBCcAA3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 16ED020728 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:44746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jS1aU-0005Cs-6d for patchwork-qemu-devel@patchwork.kernel.org; Fri, 24 Apr 2020 12:54:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57346) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jS1X4-0008K5-NA for qemu-devel@nongnu.org; Fri, 24 Apr 2020 12:50:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jS1X2-0001RJ-Ot for qemu-devel@nongnu.org; Fri, 24 Apr 2020 12:50:30 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:44658) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jS1X2-0001DA-7r for qemu-devel@nongnu.org; Fri, 24 Apr 2020 12:50:28 -0400 Received: by mail-pl1-x642.google.com with SMTP id h11so3926221plr.11 for ; Fri, 24 Apr 2020 09:50:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=mSyVumY+G1lhjcOjTvpRtoDaIP5xgSPm/bkTD//eEcw=; b=CzBCcAA3U4FgYi77yOVE1OH861SoyiOzobGjHtG/aKOvPVShHI/ZmRzKw2DmBO/rnP QrahlyeNMdmmL2ptkedRvazWu364uWRMl8iAUVwDJsJBrtSCodwgfLyzE/KUbgRan7xp fHQlPKwhlXABFFngS94su/1FytigHLZfRGxtrLwzaI9YF5JSFzvVM2SerJ9P5MrsU2A+ IXxcl2nha7Ks88LkPvWiNUmCN36MEDOzFVvI+HzG52806LbGR/xjuVnfNdM4pO0p1j+W IRuXd1e7yFe0PTrnlal0A4MZrACpBrXwle4LtC1EPHZsl1CzMPu3htug4q+9YMfpl6Xt EXrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=mSyVumY+G1lhjcOjTvpRtoDaIP5xgSPm/bkTD//eEcw=; b=B1vqBzSNk7k9OxtjU6SIzJC36ildZfqwbUVGW2k9r7bDsJZ1td/Td/a608MHQJo4ea xcuHrXwiDdp2xHZyEm7DDVrAIK0F46tmZhxV7ZAsGe2LwuT3cBmirXMmDNfGgsa6yWgo 0QHWgBJppp/tI2CfE+ofZTMPVCpGGILRExQ6I0iP/D08bBtDRQF4s0+PG8ZqeuUm9FKi VAeIZGYLLbv9jtdBsYHJtoDL4q0kqV/F7nvOezA0RUpwn3zO+lR35poOJlZASX1wB8yB FtVbiLmz+ekuPpJUvDv9aTpGZrhgHZRQr3Wrqi3Jsi9/UHdwRKMXiVHnHDwXCYApitqg eJnQ== X-Gm-Message-State: AGi0Pua1Ps4lM8vQggoXoPFhapeJnggiVKBJPrA2yPAh9phm2zmC9h+8 tyW8shMzIuV9Q+UF4Vo3F78= X-Google-Smtp-Source: APiQypJ3wqp47S0KZPfiNAdXfEW2jo5o1nfAUfjXun9YzCEbiCOJWHgKwOEX1xjybXQ/VIZuAhzfTQ== X-Received: by 2002:a17:902:8546:: with SMTP id d6mr10221417plo.280.1587747022965; Fri, 24 Apr 2020 09:50:22 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id u12sm6259967pfc.15.2020.04.24.09.50.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Apr 2020 09:50:22 -0700 (PDT) Subject: [PATCH v22 QEMU 3/5] virtio-balloon: Replace free page hinting references to 'report' with 'hint' From: Alexander Duyck To: david@redhat.com, mst@redhat.com Date: Fri, 24 Apr 2020 09:50:21 -0700 Message-ID: <20200424165021.10723.14111.stgit@localhost.localdomain> In-Reply-To: <20200424164239.10723.58352.stgit@localhost.localdomain> References: <20200424164239.10723.58352.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::642; envelope-from=alexander.duyck@gmail.com; helo=mail-pl1-x642.google.com X-detected-operating-system: by eggs.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2607:f8b0:4864:20::642 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Alexander Duyck In an upcoming patch a feature named Free Page Reporting is about to be added. In order to avoid any confusion we should drop the use of the word 'report' when referring to Free Page Hinting. So what this patch does is go through and replace all instances of 'report' with 'hint" when we are referring to free page hinting. Acked-by: David Hildenbrand Signed-off-by: Alexander Duyck --- hw/virtio/virtio-balloon.c | 74 ++++++++++++++++++------------------ include/hw/virtio/virtio-balloon.h | 20 +++++----- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index a4729f7fc930..a1d6fb52c876 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -466,21 +466,21 @@ static bool get_free_page_hints(VirtIOBalloon *dev) ret = false; goto out; } - if (id == dev->free_page_report_cmd_id) { - dev->free_page_report_status = FREE_PAGE_REPORT_S_START; + if (id == dev->free_page_hint_cmd_id) { + dev->free_page_hint_status = FREE_PAGE_HINT_S_START; } else { /* * Stop the optimization only when it has started. This * avoids a stale stop sign for the previous command. */ - if (dev->free_page_report_status == FREE_PAGE_REPORT_S_START) { - dev->free_page_report_status = FREE_PAGE_REPORT_S_STOP; + if (dev->free_page_hint_status == FREE_PAGE_HINT_S_START) { + dev->free_page_hint_status = FREE_PAGE_HINT_S_STOP; } } } if (elem->in_num) { - if (dev->free_page_report_status == FREE_PAGE_REPORT_S_START) { + if (dev->free_page_hint_status == FREE_PAGE_HINT_S_START) { qemu_guest_free_page_hint(elem->in_sg[0].iov_base, elem->in_sg[0].iov_len); } @@ -506,11 +506,11 @@ static void virtio_ballloon_get_free_page_hints(void *opaque) qemu_mutex_unlock(&dev->free_page_lock); virtio_notify(vdev, vq); /* - * Start to poll the vq once the reporting started. Otherwise, continue + * Start to poll the vq once the hinting started. Otherwise, continue * only when there are entries on the vq, which need to be given back. */ } while (continue_to_get_hints || - dev->free_page_report_status == FREE_PAGE_REPORT_S_START); + dev->free_page_hint_status == FREE_PAGE_HINT_S_START); virtio_queue_set_notification(vq, 1); } @@ -531,14 +531,14 @@ static void virtio_balloon_free_page_start(VirtIOBalloon *s) return; } - if (s->free_page_report_cmd_id == UINT_MAX) { - s->free_page_report_cmd_id = - VIRTIO_BALLOON_FREE_PAGE_REPORT_CMD_ID_MIN; + if (s->free_page_hint_cmd_id == UINT_MAX) { + s->free_page_hint_cmd_id = + VIRTIO_BALLOON_FREE_PAGE_HINT_CMD_ID_MIN; } else { - s->free_page_report_cmd_id++; + s->free_page_hint_cmd_id++; } - s->free_page_report_status = FREE_PAGE_REPORT_S_REQUESTED; + s->free_page_hint_status = FREE_PAGE_HINT_S_REQUESTED; virtio_notify_config(vdev); } @@ -546,18 +546,18 @@ static void virtio_balloon_free_page_stop(VirtIOBalloon *s) { VirtIODevice *vdev = VIRTIO_DEVICE(s); - if (s->free_page_report_status != FREE_PAGE_REPORT_S_STOP) { + if (s->free_page_hint_status != FREE_PAGE_HINT_S_STOP) { /* * The lock also guarantees us that the * virtio_ballloon_get_free_page_hints exits after the - * free_page_report_status is set to S_STOP. + * free_page_hint_status is set to S_STOP. */ qemu_mutex_lock(&s->free_page_lock); /* * The guest hasn't done the reporting, so host sends a notification * to the guest to actively stop the reporting. */ - s->free_page_report_status = FREE_PAGE_REPORT_S_STOP; + s->free_page_hint_status = FREE_PAGE_HINT_S_STOP; qemu_mutex_unlock(&s->free_page_lock); virtio_notify_config(vdev); } @@ -567,15 +567,15 @@ static void virtio_balloon_free_page_done(VirtIOBalloon *s) { VirtIODevice *vdev = VIRTIO_DEVICE(s); - s->free_page_report_status = FREE_PAGE_REPORT_S_DONE; + s->free_page_hint_status = FREE_PAGE_HINT_S_DONE; virtio_notify_config(vdev); } static int -virtio_balloon_free_page_report_notify(NotifierWithReturn *n, void *data) +virtio_balloon_free_page_hint_notify(NotifierWithReturn *n, void *data) { VirtIOBalloon *dev = container_of(n, VirtIOBalloon, - free_page_report_notify); + free_page_hint_notify); VirtIODevice *vdev = VIRTIO_DEVICE(dev); PrecopyNotifyData *pnd = data; @@ -624,7 +624,7 @@ static size_t virtio_balloon_config_size(VirtIOBalloon *s) if (virtio_has_feature(features, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) { return offsetof(struct virtio_balloon_config, poison_val); } - return offsetof(struct virtio_balloon_config, free_page_report_cmd_id); + return offsetof(struct virtio_balloon_config, free_page_hint_cmd_id); } static void virtio_balloon_get_config(VirtIODevice *vdev, uint8_t *config_data) @@ -635,14 +635,14 @@ static void virtio_balloon_get_config(VirtIODevice *vdev, uint8_t *config_data) config.num_pages = cpu_to_le32(dev->num_pages); config.actual = cpu_to_le32(dev->actual); - if (dev->free_page_report_status == FREE_PAGE_REPORT_S_REQUESTED) { - config.free_page_report_cmd_id = - cpu_to_le32(dev->free_page_report_cmd_id); - } else if (dev->free_page_report_status == FREE_PAGE_REPORT_S_STOP) { - config.free_page_report_cmd_id = + if (dev->free_page_hint_status == FREE_PAGE_HINT_S_REQUESTED) { + config.free_page_hint_cmd_id = + cpu_to_le32(dev->free_page_hint_cmd_id); + } else if (dev->free_page_hint_status == FREE_PAGE_HINT_S_STOP) { + config.free_page_hint_cmd_id = cpu_to_le32(VIRTIO_BALLOON_CMD_ID_STOP); - } else if (dev->free_page_report_status == FREE_PAGE_REPORT_S_DONE) { - config.free_page_report_cmd_id = + } else if (dev->free_page_hint_status == FREE_PAGE_HINT_S_DONE) { + config.free_page_hint_cmd_id = cpu_to_le32(VIRTIO_BALLOON_CMD_ID_DONE); } @@ -743,14 +743,14 @@ static int virtio_balloon_post_load_device(void *opaque, int version_id) return 0; } -static const VMStateDescription vmstate_virtio_balloon_free_page_report = { +static const VMStateDescription vmstate_virtio_balloon_free_page_hint = { .name = "virtio-balloon-device/free-page-report", .version_id = 1, .minimum_version_id = 1, .needed = virtio_balloon_free_page_support, .fields = (VMStateField[]) { - VMSTATE_UINT32(free_page_report_cmd_id, VirtIOBalloon), - VMSTATE_UINT32(free_page_report_status, VirtIOBalloon), + VMSTATE_UINT32(free_page_hint_cmd_id, VirtIOBalloon), + VMSTATE_UINT32(free_page_hint_status, VirtIOBalloon), VMSTATE_END_OF_LIST() } }; @@ -766,7 +766,7 @@ static const VMStateDescription vmstate_virtio_balloon_device = { VMSTATE_END_OF_LIST() }, .subsections = (const VMStateDescription * []) { - &vmstate_virtio_balloon_free_page_report, + &vmstate_virtio_balloon_free_page_hint, NULL } }; @@ -797,12 +797,12 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp) VIRTIO_BALLOON_F_FREE_PAGE_HINT)) { s->free_page_vq = virtio_add_queue(vdev, VIRTQUEUE_MAX_SIZE, virtio_balloon_handle_free_page_vq); - s->free_page_report_status = FREE_PAGE_REPORT_S_STOP; - s->free_page_report_cmd_id = - VIRTIO_BALLOON_FREE_PAGE_REPORT_CMD_ID_MIN; - s->free_page_report_notify.notify = - virtio_balloon_free_page_report_notify; - precopy_add_notifier(&s->free_page_report_notify); + s->free_page_hint_status = FREE_PAGE_HINT_S_STOP; + s->free_page_hint_cmd_id = + VIRTIO_BALLOON_FREE_PAGE_HINT_CMD_ID_MIN; + s->free_page_hint_notify.notify = + virtio_balloon_free_page_hint_notify; + precopy_add_notifier(&s->free_page_hint_notify); if (s->iothread) { object_ref(OBJECT(s->iothread)); s->free_page_bh = aio_bh_new(iothread_get_aio_context(s->iothread), @@ -827,7 +827,7 @@ static void virtio_balloon_device_unrealize(DeviceState *dev, Error **errp) if (virtio_balloon_free_page_support(s)) { qemu_bh_delete(s->free_page_bh); virtio_balloon_free_page_stop(s); - precopy_remove_notifier(&s->free_page_report_notify); + precopy_remove_notifier(&s->free_page_hint_notify); } balloon_stats_destroy_timer(s); qemu_remove_balloon_handler(s); diff --git a/include/hw/virtio/virtio-balloon.h b/include/hw/virtio/virtio-balloon.h index d1c968d2376e..108cff97e71a 100644 --- a/include/hw/virtio/virtio-balloon.h +++ b/include/hw/virtio/virtio-balloon.h @@ -23,7 +23,7 @@ #define VIRTIO_BALLOON(obj) \ OBJECT_CHECK(VirtIOBalloon, (obj), TYPE_VIRTIO_BALLOON) -#define VIRTIO_BALLOON_FREE_PAGE_REPORT_CMD_ID_MIN 0x80000000 +#define VIRTIO_BALLOON_FREE_PAGE_HINT_CMD_ID_MIN 0x80000000 typedef struct virtio_balloon_stat VirtIOBalloonStat; @@ -33,20 +33,20 @@ typedef struct virtio_balloon_stat_modern { uint64_t val; } VirtIOBalloonStatModern; -enum virtio_balloon_free_page_report_status { - FREE_PAGE_REPORT_S_STOP = 0, - FREE_PAGE_REPORT_S_REQUESTED = 1, - FREE_PAGE_REPORT_S_START = 2, - FREE_PAGE_REPORT_S_DONE = 3, +enum virtio_balloon_free_page_hint_status { + FREE_PAGE_HINT_S_STOP = 0, + FREE_PAGE_HINT_S_REQUESTED = 1, + FREE_PAGE_HINT_S_START = 2, + FREE_PAGE_HINT_S_DONE = 3, }; typedef struct VirtIOBalloon { VirtIODevice parent_obj; VirtQueue *ivq, *dvq, *svq, *free_page_vq; - uint32_t free_page_report_status; + uint32_t free_page_hint_status; uint32_t num_pages; uint32_t actual; - uint32_t free_page_report_cmd_id; + uint32_t free_page_hint_cmd_id; uint64_t stats[VIRTIO_BALLOON_S_NR]; VirtQueueElement *stats_vq_elem; size_t stats_vq_offset; @@ -55,7 +55,7 @@ typedef struct VirtIOBalloon { QEMUBH *free_page_bh; /* * Lock to synchronize threads to access the free page reporting related - * fields (e.g. free_page_report_status). + * fields (e.g. free_page_hint_status). */ QemuMutex free_page_lock; QemuCond free_page_cond; @@ -64,7 +64,7 @@ typedef struct VirtIOBalloon { * stopped. */ bool block_iothread; - NotifierWithReturn free_page_report_notify; + NotifierWithReturn free_page_hint_notify; int64_t stats_last_update; int64_t stats_poll_interval; uint32_t host_features; From patchwork Fri Apr 24 16:50:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11508651 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 0C5FF81 for ; Fri, 24 Apr 2020 16:52:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 D5A5320774 for ; Fri, 24 Apr 2020 16:52:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="txOOSUbC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D5A5320774 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:44694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jS1Z3-0003TC-Uj for patchwork-qemu-devel@patchwork.kernel.org; Fri, 24 Apr 2020 12:52:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57360) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jS1X6-0008M5-UF for qemu-devel@nongnu.org; Fri, 24 Apr 2020 12:50:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jS1X5-0001S3-Ro for qemu-devel@nongnu.org; Fri, 24 Apr 2020 12:50:32 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:45464) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jS1X4-0001Rc-Is for qemu-devel@nongnu.org; Fri, 24 Apr 2020 12:50:30 -0400 Received: by mail-pg1-x544.google.com with SMTP id s18so2209256pgl.12 for ; Fri, 24 Apr 2020 09:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=qQSE9xY+bZPeugIwTDjDoRQwhyskSjNL7bLb7JxZBUU=; b=txOOSUbCrcSxcHyz0lNQnTgdMetnff6fJWt/CwoPZFzSWsaN1kjdH4ALqqP9xymigj +GKPLpdpS2wnABc296nsFWNmm8cUkcmPDM5FG2Ndmh2N7b2NqwEfnbIcs445nIHxYFEn F0DAfIb8Sy5r44L2SL/3okcgO3VyCEr70rwCbdP4jApKg9PVA6P4lA+mfO//dnAg7Otw 1kaP+HscGE99N4ry3ReHb1FPx774s3xYZiSW4BcCnKSpItDSXXBJ9LATq287+eeZ+EWn +kRwUHDMmN1hlEyZjoomG+RBtoPA0Uk9hq86Keu2ctiWK9KDy8UFSOh8P2BXDjF3rxjZ VRnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=qQSE9xY+bZPeugIwTDjDoRQwhyskSjNL7bLb7JxZBUU=; b=Iv7YSYQG4Wn2ZgzCo+KvvhQxMVQoJ6ssEHXr4jL/WteV3/h/Yd3JnxAxsBJnFaK9vk 4GUmsAnHaI1q0sFSx3boRvCIiGc5UagmD8z9HV56MO9P4wr4+f+3LWKsSqvgJTKB4vXq CC1vaw0Yuf8/fDe4FYfmnW7Qi7pKTADvyECzd2wSrN+l0mTJNc6G1in7BYbX1yPlhSHU zXYBsKKxlFbS7GGAvJ0CKSJgHz9r4RI2ap9N2cy00wqE7U2C9NJ/z+PkEIloKNKzEmct abD9Kxlm6fAXOmwtE3i+cpMqeibLNkaPpV2UdBKtPHoEqihNQ6d0LE7gpGDHdQeSIK0g YGow== X-Gm-Message-State: AGi0Pub4Pocwky6/QLMri9tUcEr8hPJZ2vx5lfOu5v3+xBVK2JGfg+Ac T+O3YDy9rrzgz5khxXPjw4s= X-Google-Smtp-Source: APiQypKyCJyYueGFrNNHqX16f/Mf33XfCx8nkzMqjLW3orXtZeJM1t4QEUTRMvNAluEAUshN9ZeegQ== X-Received: by 2002:a63:5044:: with SMTP id q4mr10173130pgl.5.1587747029193; Fri, 24 Apr 2020 09:50:29 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id w3sm6112817pfn.115.2020.04.24.09.50.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Apr 2020 09:50:28 -0700 (PDT) Subject: [PATCH v22 QEMU 4/5] virtio-balloon: Implement support for page poison reporting feature From: Alexander Duyck To: david@redhat.com, mst@redhat.com Date: Fri, 24 Apr 2020 09:50:28 -0700 Message-ID: <20200424165028.10723.60530.stgit@localhost.localdomain> In-Reply-To: <20200424164239.10723.58352.stgit@localhost.localdomain> References: <20200424164239.10723.58352.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::544; envelope-from=alexander.duyck@gmail.com; helo=mail-pg1-x544.google.com X-detected-operating-system: by eggs.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2607:f8b0:4864:20::544 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Alexander Duyck We need to make certain to advertise support for page poison reporting if we want to actually get data on if the guest will be poisoning pages. Add a value for reporting the poison value being used if page poisoning is enabled in the guest. With this we can determine if we will need to skip free page reporting when it is enabled in the future. The value currently has no impact on existing balloon interfaces. In the case of existing balloon interfaces the onus is on the guest driver to reapply whatever poison is in place. When we add free page reporting the poison value is used to determine if we can perform in-place page reporting. The expectation is that a reported page will already contain the value specified by the poison, and the reporting of the page should not change that value. Signed-off-by: Alexander Duyck Acked-by: David Hildenbrand --- hw/virtio/virtio-balloon.c | 29 +++++++++++++++++++++++++++++ include/hw/virtio/virtio-balloon.h | 1 + 2 files changed, 30 insertions(+) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index a1d6fb52c876..c1c76ec09c95 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -634,6 +634,7 @@ static void virtio_balloon_get_config(VirtIODevice *vdev, uint8_t *config_data) config.num_pages = cpu_to_le32(dev->num_pages); config.actual = cpu_to_le32(dev->actual); + config.poison_val = cpu_to_le32(dev->poison_val); if (dev->free_page_hint_status == FREE_PAGE_HINT_S_REQUESTED) { config.free_page_hint_cmd_id = @@ -683,6 +684,14 @@ static ram_addr_t get_current_ram_size(void) return size; } +static bool virtio_balloon_page_poison_support(void *opaque) +{ + VirtIOBalloon *s = opaque; + VirtIODevice *vdev = VIRTIO_DEVICE(s); + + return virtio_vdev_has_feature(vdev, VIRTIO_BALLOON_F_PAGE_POISON); +} + static void virtio_balloon_set_config(VirtIODevice *vdev, const uint8_t *config_data) { @@ -697,6 +706,10 @@ static void virtio_balloon_set_config(VirtIODevice *vdev, qapi_event_send_balloon_change(vm_ram_size - ((ram_addr_t) dev->actual << VIRTIO_BALLOON_PFN_SHIFT)); } + dev->poison_val = 0; + if (virtio_balloon_page_poison_support(dev)) { + dev->poison_val = le32_to_cpu(config.poison_val); + } trace_virtio_balloon_set_config(dev->actual, oldactual); } @@ -755,6 +768,17 @@ static const VMStateDescription vmstate_virtio_balloon_free_page_hint = { } }; +static const VMStateDescription vmstate_virtio_balloon_page_poison = { + .name = "vitio-balloon-device/page-poison", + .version_id = 1, + .minimum_version_id = 1, + .needed = virtio_balloon_page_poison_support, + .fields = (VMStateField[]) { + VMSTATE_UINT32(poison_val, VirtIOBalloon), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_virtio_balloon_device = { .name = "virtio-balloon-device", .version_id = 1, @@ -767,6 +791,7 @@ static const VMStateDescription vmstate_virtio_balloon_device = { }, .subsections = (const VMStateDescription * []) { &vmstate_virtio_balloon_free_page_hint, + &vmstate_virtio_balloon_page_poison, NULL } }; @@ -854,6 +879,8 @@ static void virtio_balloon_device_reset(VirtIODevice *vdev) g_free(s->stats_vq_elem); s->stats_vq_elem = NULL; } + + s->poison_val = 0; } static void virtio_balloon_set_status(VirtIODevice *vdev, uint8_t status) @@ -916,6 +943,8 @@ static Property virtio_balloon_properties[] = { VIRTIO_BALLOON_F_DEFLATE_ON_OOM, false), DEFINE_PROP_BIT("free-page-hint", VirtIOBalloon, host_features, VIRTIO_BALLOON_F_FREE_PAGE_HINT, false), + DEFINE_PROP_BIT("page-poison", VirtIOBalloon, host_features, + VIRTIO_BALLOON_F_PAGE_POISON, true), /* QEMU 4.0 accidentally changed the config size even when free-page-hint * 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 108cff97e71a..3ca2a78e1aca 100644 --- a/include/hw/virtio/virtio-balloon.h +++ b/include/hw/virtio/virtio-balloon.h @@ -70,6 +70,7 @@ typedef struct VirtIOBalloon { uint32_t host_features; bool qemu_4_0_config_size; + uint32_t poison_val; } VirtIOBalloon; #endif From patchwork Fri Apr 24 16:50:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11508657 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 AF5F281 for ; Fri, 24 Apr 2020 16:55:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 8020020728 for ; Fri, 24 Apr 2020 16:55:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KCdJaVqI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8020020728 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:44844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jS1c8-0007Dh-Je for patchwork-qemu-devel@patchwork.kernel.org; Fri, 24 Apr 2020 12:55:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57382) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jS1XD-0008RL-C2 for qemu-devel@nongnu.org; Fri, 24 Apr 2020 12:50:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jS1XC-0001Ys-MU for qemu-devel@nongnu.org; Fri, 24 Apr 2020 12:50:39 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:36192) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jS1XA-0001U4-Ol for qemu-devel@nongnu.org; Fri, 24 Apr 2020 12:50:37 -0400 Received: by mail-pg1-x541.google.com with SMTP id o185so4894170pgo.3 for ; Fri, 24 Apr 2020 09:50:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=zRe3flV69ukHMRo3ykRmy9P5zrt+GuLYq1apPrMhoTM=; b=KCdJaVqIRC0Jm270akEwrbeMI3VbqeZcUXr3J4oVbIly5HLVBqqB1oooUu1XvOjKZD pfYeRe7/PcWl/SDzpLzeYm1dWSdyf/l9RT1p5s69ch+SbAZU16hjRGg9bS45Yll55840 f+JG6LQnGk5TT9NRa/C5dxQwG8NRhzNMI/J4SUoI2wKMyBbfY0Be/cSmV2B3JZwzhDKE iXfTwbFXpOMtXTR9ni8relsCtirr3vUJbLP6arMyoANLtP86dZecMsEFMuFuO9YYOEcM y/rIp9zziLwE5louhiZhJ6Ns0+gydlHVVoKB12KrUHJqRPIjYNRQmydtqPvSl9oS7eRQ AUsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=zRe3flV69ukHMRo3ykRmy9P5zrt+GuLYq1apPrMhoTM=; b=ega7VZfZqurzizOhKF2/M3FqqK1KkbxKQvaa/IMLPHOdhuQlJVfGEwvMReIOyH+GYX xUbzaPPqJmZ1UEOnlDe+i7A7mGsRpO6yV1TDvzNuIRiJ9z/Hfo2S9wbDqXy3VjxpEc9j aqvWQyeVjeK2vrbO1eiOA5DjrbP/vBCGEA8eUlGErZ6zxW/SaU291o12Le0jP/R0PsJr cHTAIPYTPv52odTaXfUYMi8dg2ES/YENhU0TQ3yU0z7jnwYoWNaZRqDjQwOfFnt5JuOA hQn15Ui5zmPobmR6z7fk55xSjjLztblrZ9JxxPSBjtOel5h863QvdmTIGmByoDi0u0Zj RJEA== X-Gm-Message-State: AGi0PuYjtiDIL00lzIrkdnN2voSIFt8hgRIBfP1n6/DWQxkTef/ts2A/ IjFnfUBgzCZpb7DoKDbJBi4= X-Google-Smtp-Source: APiQypI4yfQjEsWf2gRFzcbIyJSg/Gfb4deHf9R3c7W+vdxrmnpzL+sWXA1tjMdkpMzA3miiVXtXvw== X-Received: by 2002:a63:e34e:: with SMTP id o14mr10614108pgj.52.1587747035405; Fri, 24 Apr 2020 09:50:35 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id w66sm6187487pfw.50.2020.04.24.09.50.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Apr 2020 09:50:34 -0700 (PDT) Subject: [PATCH v22 QEMU 5/5] virtio-balloon: Provide an interface for free page reporting From: Alexander Duyck To: david@redhat.com, mst@redhat.com Date: Fri, 24 Apr 2020 09:50:34 -0700 Message-ID: <20200424165034.10723.77728.stgit@localhost.localdomain> In-Reply-To: <20200424164239.10723.58352.stgit@localhost.localdomain> References: <20200424164239.10723.58352.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::541; envelope-from=alexander.duyck@gmail.com; helo=mail-pg1-x541.google.com X-detected-operating-system: by eggs.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2607:f8b0:4864:20::541 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Alexander Duyck Add support for free page reporting. The idea is to function very similar to how the balloon works in that we basically end up madvising the page as not being used. However we don't really need to bother with any deflate type logic since the page will be faulted back into the guest when it is read or written to. This provides a new way of letting the guest proactively report free pages to the hypervisor, so the hypervisor can reuse them. In contrast to inflate/deflate that is triggered via the hypervisor explicitly. Signed-off-by: Alexander Duyck Acked-by: David Hildenbrand --- hw/virtio/virtio-balloon.c | 67 ++++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio-balloon.h | 2 + 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index c1c76ec09c95..2ce56c6c0794 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -321,6 +321,67 @@ static void balloon_stats_set_poll_interval(Object *obj, Visitor *v, balloon_stats_change_timer(s, 0); } +static void virtio_balloon_handle_report(VirtIODevice *vdev, VirtQueue *vq) +{ + VirtIOBalloon *dev = VIRTIO_BALLOON(vdev); + VirtQueueElement *elem; + + while ((elem = virtqueue_pop(vq, sizeof(VirtQueueElement)))) { + unsigned int i; + + /* + * When we discard the page it has the effect of removing the page + * from the hypervisor itself and causing it to be zeroed when it + * is returned to us. So we must not discard the page if it is + * accessible by another device or process, or if the guest is + * expecting it to retain a non-zero value. + */ + if (qemu_balloon_is_inhibited() || dev->poison_val) { + goto skip_element; + } + + for (i = 0; i < elem->in_num; i++) { + void *addr = elem->in_sg[i].iov_base; + size_t size = elem->in_sg[i].iov_len; + ram_addr_t ram_offset; + RAMBlock *rb; + + /* + * There is no need to check the memory section to see if + * it is ram/readonly/romd like there is for handle_output + * below. If the region is not meant to be written to then + * address_space_map will have allocated a bounce buffer + * and it will be freed in address_space_unmap and trigger + * and unassigned_mem_write before failing to copy over the + * buffer. If more than one bad descriptor is provided it + * will return NULL after the first bounce buffer and fail + * to map any resources. + */ + rb = qemu_ram_block_from_host(addr, false, &ram_offset); + if (!rb) { + trace_virtio_balloon_bad_addr(elem->in_addr[i]); + continue; + } + + /* + * For now we will simply ignore unaligned memory regions, or + * regions that overrun the end of the RAMBlock. + */ + if (!QEMU_IS_ALIGNED(ram_offset | size, qemu_ram_pagesize(rb)) || + (ram_offset + size) > qemu_ram_get_used_length(rb)) { + continue; + } + + ram_block_discard_range(rb, ram_offset, size); + } + +skip_element: + virtqueue_push(vq, elem, 0); + virtio_notify(vdev, vq); + g_free(elem); + } +} + static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq) { VirtIOBalloon *s = VIRTIO_BALLOON(vdev); @@ -818,6 +879,10 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp) s->dvq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output); s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats); + if (virtio_has_feature(s->host_features, VIRTIO_BALLOON_F_REPORTING)) { + s->rvq = virtio_add_queue(vdev, 32, virtio_balloon_handle_report); + } + if (virtio_has_feature(s->host_features, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) { s->free_page_vq = virtio_add_queue(vdev, VIRTQUEUE_MAX_SIZE, @@ -945,6 +1010,8 @@ static Property virtio_balloon_properties[] = { VIRTIO_BALLOON_F_FREE_PAGE_HINT, false), DEFINE_PROP_BIT("page-poison", VirtIOBalloon, host_features, VIRTIO_BALLOON_F_PAGE_POISON, true), + DEFINE_PROP_BIT("free-page-reporting", VirtIOBalloon, host_features, + VIRTIO_BALLOON_F_REPORTING, false), /* QEMU 4.0 accidentally changed the config size even when free-page-hint * 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 3ca2a78e1aca..ac4013d51010 100644 --- a/include/hw/virtio/virtio-balloon.h +++ b/include/hw/virtio/virtio-balloon.h @@ -42,7 +42,7 @@ enum virtio_balloon_free_page_hint_status { typedef struct VirtIOBalloon { VirtIODevice parent_obj; - VirtQueue *ivq, *dvq, *svq, *free_page_vq; + VirtQueue *ivq, *dvq, *svq, *free_page_vq, *rvq; uint32_t free_page_hint_status; uint32_t num_pages; uint32_t actual;