From patchwork Tue Apr 28 00:53:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 1278107 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=GxFs0X3X; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 49B37l5XMMz9sSk for ; Tue, 28 Apr 2020 10:54:27 +1000 (AEST) Received: from localhost ([::1]:37572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTEW1-0007Hk-KM for incoming@patchwork.ozlabs.org; Mon, 27 Apr 2020 20:54:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58790) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTEVR-0007CM-KK for qemu-devel@nongnu.org; Mon, 27 Apr 2020 20:53:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTEVR-0006rp-28 for qemu-devel@nongnu.org; Mon, 27 Apr 2020 20:53:49 -0400 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]:55662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jTEVQ-0006rg-Kj for qemu-devel@nongnu.org; Mon, 27 Apr 2020 20:53:48 -0400 Received: by mail-pj1-x1043.google.com with SMTP id a32so371951pje.5 for ; Mon, 27 Apr 2020 17:53:48 -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=GxFs0X3XZme5IomZ99ooY9/c9kRD8U100og5CsVy/rSU4jCn8Ln+UPhSln9jvVRLSR P4j3hTi0gAnMFOJypepYk8A2zwyhBO1boGC+9EtrhhFqJAGulSEVCbSmfzbHU9tkOlCI j75RT19Nj3s4OZT0YbQ6db9R018MAPDQ92WX+OhT9g6Iq66iKU+Mq0YRy4zr9pNwlo+7 QEFjJ/zZ/xuZjscFk5VQPkSCkVrEOJoUx220beZceIeg/pbp3FMdDdI8lWV2KbnbDugJ Z6BsGmYHV6W6tlSL/XCeiwwkSlWnAa0APJsHngjVZ7V/DTyYuWICvvqiCNLa8jlyxHr2 AYYw== 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=MyVMFr/xKLzfIc74cO9DTklzCtNlMrBgGaFjL0VjbdIthJbR/dBbCVQsJgq/1nXCFX dqw1z10Cyh7LAkPWm+2SfRrVZGzKB+JFsY/1oZ6cfjAaGihqK0JeTaffZ8PAGLU6+uyA mGH5GyIFpIu9P996lZC6WAqKaHqtuhSCJMBwmh2ujEU0X2X20ea9MjJeVXXJTZ6lIVGp UGjBSQmiy/AwCZFcKeA31Sg/DrWhnuqwO5rQDNVN+A8UrOWaSSjGMHK9lL3NgFo3dYAo o/OIVQXcdWa4nqxMwZJH+Vb1nJR3+6igLnP9h49p4PGP78alVFUUXfGEta24JQ4de3/7 uEXw== X-Gm-Message-State: AGi0PuaBN7RQXnU6XdynDbqaOXxRiEnutU85lvqw6daprOGGbM5vfMS1 itQYEnyU0vvIyos5hKQn6xc= X-Google-Smtp-Source: APiQypLeZPzZ5OKMKU0qQr5r1HwbCnMpVGuz8DZlc02RJUpubo5hpCjNhgOlLiDdPmBpKO7G+9PiBg== X-Received: by 2002:a17:902:a586:: with SMTP id az6mr9889237plb.201.1588035227098; Mon, 27 Apr 2020 17:53:47 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id r128sm14127101pfc.141.2020.04.27.17.53.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Apr 2020 17:53:46 -0700 (PDT) Subject: [PATCH v23 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: Mon, 27 Apr 2020 17:53:45 -0700 Message-ID: <20200428005345.6158.57376.stgit@localhost.localdomain> In-Reply-To: <20200428005134.6158.88521.stgit@localhost.localdomain> References: <20200428005134.6158.88521.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+incoming=patchwork.ozlabs.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 Tue Apr 28 00:53:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 1278109 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=lsaseBYz; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 49B39h2L8pz9sSJ for ; Tue, 28 Apr 2020 10:56:08 +1000 (AEST) Received: from localhost ([::1]:37690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTEXe-00021v-8J for incoming@patchwork.ozlabs.org; Mon, 27 Apr 2020 20:56:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58848) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTEVX-0007Te-HD for qemu-devel@nongnu.org; Mon, 27 Apr 2020 20:53:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTEVX-0006yY-3D for qemu-devel@nongnu.org; Mon, 27 Apr 2020 20:53:55 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:44690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jTEVW-0006vS-My for qemu-devel@nongnu.org; Mon, 27 Apr 2020 20:53:54 -0400 Received: by mail-pf1-x441.google.com with SMTP id p25so9845141pfn.11 for ; Mon, 27 Apr 2020 17:53:54 -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=lsaseBYznHAItZy3mUNs7I850MNJ9ER5+vLx+h/cQxBB1YwdtiU+XEgzhh5ozuzwZE Ahudjvk3q+PWAqpkZh9CqMx+/1WUbexSapKQTvXVssj9nlTit4ein6/oiUpteTdd+oWq dZdFGwbnAddKLzPxikj9Wjw8KV6pLzJXXqMWg8mo3h9wt9araAj4EpROTuIPKoObwUOW F3pzoKdI78VYRlAVCu+UfSpRmcqPdwnCZVDnJDk2tCfNDIElLgdCXMaUKm/cb++GXcYo DI6hN4Mq/cl/tNwag0OW8aHPLdv0N+IKPGu6HK3MLnZABV+FsBQaE17N+pnwAlUsXLIl +ahw== 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=rRFAtQy+acqy/paDncnO14vD9NsBV6d/lhuLNqN9tqgHI9gzZIrlK2bR+a3l0SNF6Q pb0c6/93r7pLadKwrh42GcmGEqMm/9gqBobyaIXRhdiKzLfqKR85XkvMIdOM3NCPm3oi OoeIGwcEQwonVJRelPBq7w2gGZKk8upTUCNJgYOtlz/7u2bZ1qTR8dPGQVRijXHNAB/p WMWC5WWJu7ntvME3Xe+VxnHzaekIeEukpqO65mOplTUkNzM+l/r+hTqTU2nP/kDFTqCK xyf285Cah7zmqjHDkSWPX7683bDda1bsxiNFUtllcisyLxed5vbXQfsHoYQZRhKBjFWh VDFQ== X-Gm-Message-State: AGi0PubxCNi8s10G7GEIcBN8PjcrkrC/W7A0JA1XUOLctKcyNa3cPovO 51PzUMiaGo0ihjQuTNu0XaU= X-Google-Smtp-Source: APiQypINBTZ+cCSIuU4rTlFONBkwozUgxthDK3GWeGE5MooBgkUB3dBOIu3hUzObt5kfEm9KGs7/Pw== X-Received: by 2002:aa7:9589:: with SMTP id z9mr27059873pfj.247.1588035233315; Mon, 27 Apr 2020 17:53:53 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id t7sm13519001pfh.143.2020.04.27.17.53.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Apr 2020 17:53:52 -0700 (PDT) Subject: [PATCH v23 QEMU 2/5] linux-headers: update to contain virito-balloon free page reporting From: Alexander Duyck To: david@redhat.com, mst@redhat.com Date: Mon, 27 Apr 2020 17:53:52 -0700 Message-ID: <20200428005352.6158.18830.stgit@localhost.localdomain> In-Reply-To: <20200428005134.6158.88521.stgit@localhost.localdomain> References: <20200428005134.6158.88521.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=alexander.duyck@gmail.com; helo=mail-pf1-x441.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::441 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+incoming=patchwork.ozlabs.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 Tue Apr 28 00:53:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 1278108 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=fC/VAB8l; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 49B38J1P9Gz9sSK for ; Tue, 28 Apr 2020 10:54:56 +1000 (AEST) Received: from localhost ([::1]:37610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTEWU-0008WG-1n for incoming@patchwork.ozlabs.org; Mon, 27 Apr 2020 20:54:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58902) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTEVf-0007iJ-Sv for qemu-devel@nongnu.org; Mon, 27 Apr 2020 20:54:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTEVe-0007H5-0f for qemu-devel@nongnu.org; Mon, 27 Apr 2020 20:54:03 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:38783) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jTEVd-0007Br-Gs for qemu-devel@nongnu.org; Mon, 27 Apr 2020 20:54:01 -0400 Received: by mail-pl1-x642.google.com with SMTP id w3so7666463plz.5 for ; Mon, 27 Apr 2020 17:54:00 -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=9FgnM4HvErXKWZJbbQvfcjSzozlq0cqUHZYYv5AzslI=; b=fC/VAB8lBsZlb18inIvhMBhcSiJ35XGETryBYVCOXrWdY9fOpf+p1f66F2pwytntRh lJLUChw7MUlI/ju65ks68FB+0R736dDukarSpfc3TM9fj2VL0XxTc72Grd0qNJaJW6Fx Kj85JWn/K/S+70A3zd+xGseyN2UT9voUCsoPnmeNAbnEvoNDQ/OPjmCbmaiRx2s0w2dE /bKjuPPRTHat9QnF9/fUnenBZPe6WCsTk6RDwU+OhNbQjTfTP+T6zoPiCrE53okS3hOu Lp9cFjJwCrjVFsBrkJDeuKVhtCHd8rQgFW0mIASXgalc9a6GPGKAFp7Zy0M6VZUrhM/p 7xnw== 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=9FgnM4HvErXKWZJbbQvfcjSzozlq0cqUHZYYv5AzslI=; b=YLZsEWAVAdAoJXiZhz4+VG1Ux7lSBgiTmQzDzZQvmCrhk6dvIvOm4rZ/1T8xnBKusu EZnz1TDPQZ/jM4ijxyJRw4ZACilm9y9vHwEfkM/MuckTsDqu8xRbSc4SwUDHeDMqR8+f 2ozdiZQ43WqCYBKQP8SIWYccypDB3rCXs6L0M/IMeSh6N/ZGJmrlnmBIe2mu985nMQad fMCCjaZ8Dji4UicjXvyi3pABprbLjRj7pt/0+XnhFv8yG9HDlmqffyDyJb59Xeyg9Afp xyT/XnKuwlDCqPe3dbe6qOhA9HiBgcHvE0j2PbKHtZQr1qcsD4O1AIxlZ+xKs1FcvxFh m5bQ== X-Gm-Message-State: AGi0PubP+n4aYFI9Zf822tGCVPDjVSkW0XRC5VAMHiE0pkGLkotUd77I Ewck4NZGDAkwHPZ0JLxlaHc= X-Google-Smtp-Source: APiQypIE+5e36IJ+32l2laknrspbcxX7sbnim0PteZ/7159B8W+3Yg2zIYajiKeGZ0SpCmHfGo5w0w== X-Received: by 2002:a17:902:bd81:: with SMTP id q1mr16611569pls.46.1588035239608; Mon, 27 Apr 2020 17:53:59 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id u9sm12857569pfn.197.2020.04.27.17.53.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Apr 2020 17:53:59 -0700 (PDT) Subject: [PATCH v23 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: Mon, 27 Apr 2020 17:53:58 -0700 Message-ID: <20200428005358.6158.80784.stgit@localhost.localdomain> In-Reply-To: <20200428005134.6158.88521.stgit@localhost.localdomain> References: <20200428005134.6158.88521.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+incoming=patchwork.ozlabs.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 | 78 ++++++++++++++++++------------------ include/hw/virtio/virtio-balloon.h | 20 +++++---- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index a4729f7fc930..a209706b4d8d 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. + * The guest isn't done hinting, so send a notification + * to the guest to actively stop the hinting. */ - 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 Tue Apr 28 00:54:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 1278110 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=oIMWNVx9; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 49B3B96yQ0z9sSJ for ; Tue, 28 Apr 2020 10:56:33 +1000 (AEST) Received: from localhost ([::1]:37716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTEY3-0002So-Sb for incoming@patchwork.ozlabs.org; Mon, 27 Apr 2020 20:56:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58940) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTEVk-0007me-S7 for qemu-devel@nongnu.org; Mon, 27 Apr 2020 20:54:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTEVj-0007ce-KD for qemu-devel@nongnu.org; Mon, 27 Apr 2020 20:54:08 -0400 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]:51064) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jTEVj-0007cN-7D for qemu-devel@nongnu.org; Mon, 27 Apr 2020 20:54:07 -0400 Received: by mail-pj1-x1043.google.com with SMTP id t9so380783pjw.0 for ; Mon, 27 Apr 2020 17:54:06 -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=laUA0WV/zZpUpt8ipNHNbKBDzKaLa3YmXKOYKtnN0Mg=; b=oIMWNVx9k3KHUNQAcwwx/U0TUJ/c/wmmz9HilJzKQ214JrDlKAYvVIEd1AsiZHs8Qd W7kqnspiH7SaPvxNYyCCHl8knzy/4P3VY1+TvdGJv0PlO6bL5f4bIMwkDZ34aDFdS/T1 tKqc+Yp2z/oSW34P1fcTBjsUixJDei7oF4uPVw8StSCJ0bubvged45fdWZQ28R5ZB7bt TWjPpdNH1TBxNkOed7KP4h1XHuIsIDN/SgGRkf5jm4mmDIcJnpiMuKjhViyMI4Y0dFkt Ev6nzqOclN0ahpcx/8GgW5n7IXtVXtVbQR05qrG6yMd9kg/hYPjYMFNQ5rl21fQ3ZDls OuJw== 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=laUA0WV/zZpUpt8ipNHNbKBDzKaLa3YmXKOYKtnN0Mg=; b=NVORNOmEz+slj8YWnEomMHhaMZeHYEibdAZGaMxtLtsWkNuPGZkGB1vm2bVpSLcid6 Iy2Yvn7dObpHjSsO98cz45JdxIzFJENdo3WrdihCIyH/n/T8BMZ3GIZgSaerbehBTiKF j4h4hgA7Sev1TZM7oGtFKfoo64jwy2Nh2xHWHjDDanC7y3qOvkeLgMXxNz6sV5RGFjWF Z8mfyjBWOcE0zCBYbhgpj+tSF3Rze/NKQpL/h47LTqDfs9fYZrssOZev8aW/hqME82Pd O/GiJMFcV2qeuLuYGXeStL6PiLLlx/boXR/Y09EMlwmKupzg8Sx5zAV0d8A2VbEOWM0M PkLQ== X-Gm-Message-State: AGi0Pua1hLSxzJ8B6twutgGx58xvfV2whuT0CrvWqJjvvaOhOQspF5vV WDCypSrfRDXfKQUmVYJpoWk= X-Google-Smtp-Source: APiQypK7G6NGwFnsoY7LOTh+2beJKSE6Y7YYOjUK5tinVaKt4NQKTGKkDH34HBm0RN6LqMFzmyBzJg== X-Received: by 2002:a17:90a:8994:: with SMTP id v20mr1794615pjn.76.1588035245832; Mon, 27 Apr 2020 17:54:05 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id j32sm11588541pgb.55.2020.04.27.17.54.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Apr 2020 17:54:05 -0700 (PDT) Subject: [PATCH v23 QEMU 4/5] virtio-balloon: Implement support for page poison reporting feature From: Alexander Duyck To: david@redhat.com, mst@redhat.com Date: Mon, 27 Apr 2020 17:54:04 -0700 Message-ID: <20200428005404.6158.95415.stgit@localhost.localdomain> In-Reply-To: <20200428005134.6158.88521.stgit@localhost.localdomain> References: <20200428005134.6158.88521.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+incoming=patchwork.ozlabs.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. Acked-by: David Hildenbrand Signed-off-by: Alexander Duyck --- 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 a209706b4d8d..1666132a24c1 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 Tue Apr 28 00:54:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 1278111 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=ott5Zfcf; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 49B3DJ0nscz9sSK for ; Tue, 28 Apr 2020 10:58:24 +1000 (AEST) Received: from localhost ([::1]:37816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTEZq-0005W9-1E for incoming@patchwork.ozlabs.org; Mon, 27 Apr 2020 20:58:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58984) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTEVq-0007w1-Hx for qemu-devel@nongnu.org; Mon, 27 Apr 2020 20:54:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTEVp-0007t2-Sg for qemu-devel@nongnu.org; Mon, 27 Apr 2020 20:54:14 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:45390) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jTEVp-0007ra-FJ for qemu-devel@nongnu.org; Mon, 27 Apr 2020 20:54:13 -0400 Received: by mail-pl1-x641.google.com with SMTP id t4so7641404plq.12 for ; Mon, 27 Apr 2020 17:54:13 -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=f60PjaQ32uAPz31QIwCr3FQCyG63xWUpLWuGVvAuWxg=; b=ott5ZfcfjsX8twq3aMk83UeYAo9pX8WJJxHY6YdkeYFfBJGRxsxYZZA7v7EDhpGhKb o3PLPkMKlrJ6VZU4rIylsZLL9yoQh9tgeKUDkJYZNG3WjaZsm80DpmNNHaTU1pRd8+eX QT6oHgoIbz4xgVY48EkqikxACeJrdSGKoAJomSzwLDsqiARh5HIw/OP0UFmjY+GeScpH oXSN0ToZeTGGutXg7YzIJT1EP9HSBWZfh+vJ9jTblhq2+UX5qihpSOrFq5XN2ocDc2IP FEDCRdQWSmiIqI5/wpjAvGgNkzcuJpFjGWhIwjhjgwk98zDa6ZOmgawH9FTffN/W9xEP 8sBQ== 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=f60PjaQ32uAPz31QIwCr3FQCyG63xWUpLWuGVvAuWxg=; b=Xn5UDkX/uINv8z1Uo5cnGUI1p7GRAbGAlILKH0WE4t47FcBGGcUQyNA2nn1tSbIo/y Z+n+XXJgOF8B8fx/A1zX9iJPok1nfeOFIRGHRqDmbhs+mRdVZGqOrzqytOsH0tvzBx28 Y8cYVz/9e1NV4/lWco1/4Z+oMViTmbXiqRS73js/T0vdKuDcsyDe2isP5CcDMo/mOGVw YsBJe61PqRXRDruukc8PGIkIbG0o8d9NzpdFtQg1iS+FJ+TrQzkdPbjiVlYltvNLSe1B smnV5h36hbPEGXzHg0unhAAgC4R0kDqd6Uzv5Ye2Fna/XXiLXvHtnR524W9cP08duaLp U8MQ== X-Gm-Message-State: AGi0PuZXlDe0TBFQvUIKM2RvXV7/LGX2MBFf6FRaMLwFj3XD5YXHDk1b aeedaJSAlXj+W8w9Cj6IKcE= X-Google-Smtp-Source: APiQypKM/UeoJ04DIuB1fMPrOKtfTjcu0VeAbgnUH8nfuNpNf3i8qI3e9mdrAZsIXqT5X4CvWWS+DA== X-Received: by 2002:a17:90a:25cb:: with SMTP id k69mr1665193pje.93.1588035252024; Mon, 27 Apr 2020 17:54:12 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id 67sm3945151pfx.108.2020.04.27.17.54.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Apr 2020 17:54:11 -0700 (PDT) Subject: [PATCH v23 QEMU 5/5] virtio-balloon: Provide an interface for free page reporting From: Alexander Duyck To: david@redhat.com, mst@redhat.com Date: Mon, 27 Apr 2020 17:54:10 -0700 Message-ID: <20200428005410.6158.56128.stgit@localhost.localdomain> In-Reply-To: <20200428005134.6158.88521.stgit@localhost.localdomain> References: <20200428005134.6158.88521.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::641; envelope-from=alexander.duyck@gmail.com; helo=mail-pl1-x641.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::641 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+incoming=patchwork.ozlabs.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. Acked-by: David Hildenbrand Signed-off-by: Alexander Duyck --- hw/virtio/virtio-balloon.c | 69 ++++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio-balloon.h | 2 + 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 1666132a24c1..53abba290274 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); @@ -841,6 +902,12 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp) virtio_error(vdev, "iothread is missing"); } } + + if (virtio_has_feature(s->host_features, VIRTIO_BALLOON_F_REPORTING)) { + s->reporting_vq = virtio_add_queue(vdev, 32, + virtio_balloon_handle_report); + } + reset_stats(s); } @@ -945,6 +1012,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..28fd2b396087 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, *reporting_vq; uint32_t free_page_hint_status; uint32_t num_pages; uint32_t actual;