From patchwork Wed Apr 22 18:20: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: 11504391 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 CCE76112C for ; Wed, 22 Apr 2020 18:22:32 +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 A201420882 for ; Wed, 22 Apr 2020 18:22:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rcTRMDXv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A201420882 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]:55698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRK11-0006Gt-1s for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Apr 2020 14:22:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50842) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRJzb-0004zl-RR for qemu-devel@nongnu.org; Wed, 22 Apr 2020 14:21:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jRJza-0002AY-Ka for qemu-devel@nongnu.org; Wed, 22 Apr 2020 14:21:03 -0400 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]:36345) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jRJza-00025w-6m for qemu-devel@nongnu.org; Wed, 22 Apr 2020 14:21:02 -0400 Received: by mail-qk1-x743.google.com with SMTP id l25so3486329qkk.3 for ; Wed, 22 Apr 2020 11:21:01 -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=rcTRMDXv+Yo4EYEAA4g+HOSJ0dnv6q0ciFXJ+MQ644VjZpT6QypWAuOY/+wgT97N7N Yp8dKW9oMDjS/5yBbcLLxEbti1AqK3vzZHpe1XjS/ypuh+n5o8HP3uUrUeS0j2HwDS8Y EycTrHVXfhs4DSdZmoE0E7u6K1ObKRNadh1VcrYwV3pli6h6sndfoKs3oT7HY1nyBBJ5 XBd/Fa0DXMVsSCKMp+samnM84RSglmCPW56E5Y0k63zmpjy03uK2kgomWCQldVpeEh7R zaVbAoEFIBxyHJIyrWEtPBtJ183OYCChkhq6fYBKkxFOIfPVudRgfsYVEV5ZAuP/dL4j Hi8w== 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=S2u2NwwA3CuRAegr7CnXLWLgo++WnWw9TkB+s685FQLfluhf/V2mohzN+G31aNssFA x1HZkqZwv8lfrLaFFpPknq997FrBvCACTVtDhtYVyYDSkLULNcY91PTdtWkvmaAyr6Oj MEh5pA0AWNiTR1FmLhW8xE7ZGo5SOui6QlxDM36Pg+v6wlV5XxsyWzqAYhSBXgelY7Mb MzfvHc/cAqbzDJbi+Xyvx5uzuoPM3txJ3ER96REDQkcgm2lTlLASXtWq2V2ZzYWTY62H 3yX1LPq/EAGaZCO+mOpPeXBgFVHMelMbfy0Jp1fAXbmCuNETnQ+SnJB7F+XA/PRbV5vR P0TQ== X-Gm-Message-State: AGi0PuY/eJ8c+CihHRHjJSAMbv8tMTvvZY2YnBwMXqHKKFalfOvGUXDM cf+9DZor6bBVNSw9i2TjUFo= X-Google-Smtp-Source: APiQypLqZngDSorZDDTmxZtWNAI+yVErrNWqoVWfjNQIlpiRc2olxCnd4Vf0ssdFKfdX9vkd1dX/PQ== X-Received: by 2002:a37:6393:: with SMTP id x141mr26288222qkb.179.1587579661122; Wed, 22 Apr 2020 11:21:01 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id q32sm641qta.13.2020.04.22.11.20.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2020 11:21:00 -0700 (PDT) Subject: [PATCH v21 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: Wed, 22 Apr 2020 11:20:58 -0700 Message-ID: <20200422182058.12258.52009.stgit@localhost.localdomain> In-Reply-To: <20200422181649.12258.37077.stgit@localhost.localdomain> References: <20200422181649.12258.37077.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::743; envelope-from=alexander.duyck@gmail.com; helo=mail-qk1-x743.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::743 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 Wed Apr 22 18:21:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11504397 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 57FCF15AB for ; Wed, 22 Apr 2020 18:23:57 +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 2F1882098B for ; Wed, 22 Apr 2020 18:23:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LsdWUXHe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F1882098B 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]:55724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRK2O-0000Xc-Bu for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Apr 2020 14:23:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50912) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRJzk-000515-1y for qemu-devel@nongnu.org; Wed, 22 Apr 2020 14:21:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jRJzj-0002cK-Jc for qemu-devel@nongnu.org; Wed, 22 Apr 2020 14:21:11 -0400 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]:45357) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jRJzh-0002OW-Jw for qemu-devel@nongnu.org; Wed, 22 Apr 2020 14:21:09 -0400 Received: by mail-qk1-x744.google.com with SMTP id m67so3408633qke.12 for ; Wed, 22 Apr 2020 11:21:09 -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=LsdWUXHeOCv6U+GBDHwljJ6mvIk5lxR4xVsOEtIWPNz+D4ZiQ77ZuUvPJtLbFgn2UF ReKtV7zJE8wBtNubvuRZ7dEd8O9EyGmMTfwCG3GM1fB9/lWakHoMtrSQKDndAJCo2mNK gEGU+vcUClC+4EpnBMzEL+I0P2KW/OsiCKmQGU1cl/yH5Y67vVueLycSmvogES9jm15y ic/gClC+LoC220bdCt397kSMtatBdcwfdjWvH6vfNw5+e6uFlCz5+vCSP8jq6adyb9Ni 8pAo4VjbbI+OeMrvYtgI50FaR3BUQFsohyEzxSMv07FjqwBGlRZUG95SIhdvKAL2uYMc dF8A== 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=W/yeCXGZwNca2l3v/ONhbDFReM3Yqtk3+pdiep71UuQWKNi2Wdqdwv1Y9uTBWC2j44 4e9Dj2/W3YfOpfYnQR6wGXCRsmo6DYEuxQ35PwJ4IVNWmFLAE7/w1DX53DWiEvKMAISp tWWO0dLhmO1OE05UDqqYUFODDV7ae8OI8FfsVwoPpexD7TWqXVVbpcBp6YGihcwfNCvo UFuhU6UTuP3pKe+Hrfib8zqnAfJCd/Fs6Wq7smiPw9MWYWsJh6sHAQ5XI15zWtDGopG4 TqDpU+QOeune66kq7FExeGoDRWYIL00GrywXFj/lwnsFnzAmW1UJx5SGpeOEXLU2am9g gfmw== X-Gm-Message-State: AGi0PuZBwp6FpyoWHL5J0lwWJqMuIQlodnYu/S03cebsiIOY9UzIwk4J tkWFw5fngLT2SXAa2tEcAiqaACEm1/E= X-Google-Smtp-Source: APiQypLWRMl5VLgsxPSxxQlLUOs9gHLc9Js+TPE2aDdys6oe9LdYq9QUa54y0nGVnjTffUqdakUL6w== X-Received: by 2002:a37:881:: with SMTP id 123mr28207659qki.185.1587579668130; Wed, 22 Apr 2020 11:21:08 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id 60sm4460499qtb.95.2020.04.22.11.21.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2020 11:21:07 -0700 (PDT) Subject: [PATCH v21 QEMU 2/5] linux-headers: update to contain virito-balloon free page reporting From: Alexander Duyck To: david@redhat.com, mst@redhat.com Date: Wed, 22 Apr 2020 11:21:06 -0700 Message-ID: <20200422182106.12258.53215.stgit@localhost.localdomain> In-Reply-To: <20200422181649.12258.37077.stgit@localhost.localdomain> References: <20200422181649.12258.37077.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::744; envelope-from=alexander.duyck@gmail.com; helo=mail-qk1-x744.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::744 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 Wed Apr 22 18:21:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11504393 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 355A615AB for ; Wed, 22 Apr 2020 18:22:42 +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 EE90520882 for ; Wed, 22 Apr 2020 18:22:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cLHSk9ph" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE90520882 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]:55702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRK1B-0006X0-3J for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Apr 2020 14:22:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50980) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRJzq-00058b-OA for qemu-devel@nongnu.org; Wed, 22 Apr 2020 14:21:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jRJzp-0002vf-SD for qemu-devel@nongnu.org; Wed, 22 Apr 2020 14:21:18 -0400 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]:33285) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jRJzp-0002m9-Bh for qemu-devel@nongnu.org; Wed, 22 Apr 2020 14:21:17 -0400 Received: by mail-qk1-x743.google.com with SMTP id s188so2671560qkf.0 for ; Wed, 22 Apr 2020 11:21:16 -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=YJd/5+rwmU7jV4Cc2a5A8ynsedgtcoLuxNlkQDArthc=; b=cLHSk9phlsrCc3SC/AoTmw7xWKfmYUUn5osAApzuuJjaagtSvfCCtf9tfapty+PDJ6 6pTultScRo78UmB7OyzK1NGe6BbYVkYWkJDTws2KEYVgO05Qa9hm88yxo0DLhKXqbcPo PlDJdVQ65gcQBhd3aqY/FOIF+PDpe5czayQtJO5mUPxZnz1b/JMH+wQXnQ2CaFETP8uz AADNVE83gi5MAMBQuq6jf1Z45UUS7JxI46uS5vPAvMf7D9Le3x1Iy1eahfy7Ze+asrdO nox4W8auyhDG6TqbZijFfMBepX91T90dyzRlsSxNOUEvEqaOseM7YEg0dbVYhRrZ+nT6 +qAw== 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=YJd/5+rwmU7jV4Cc2a5A8ynsedgtcoLuxNlkQDArthc=; b=I6dNH46AF0d1n/531FKq8lfnObRaIqBeOK4qSNQWnARZ8nQYmqwz8i/EmxN4dGhqSu L5t5P/O9AG3RDOTjqSqG6sGe0Pi9iud6ioU/k4lki61SOy+IEzklaOwXZobXgUP5N9+f 04Tj1NZoavFFVxIC8iFV56CvRol2OQM4P4kfA/BuJDzBrJv0Xt6OQik8ZQf6CpRYjvK/ wtM1xfubqoyIA4Dq2VN3vE5u0JNzKC0Y/fkPl7yTOXUvsQj7rnR9gX+uoGY4Z7FsEJgd 8elXPBSflhEJw5fSAIpVba3JaJc8p711mmAh1igeNOTGFizRdTgvih0aT0lu04MBK34P V0UA== X-Gm-Message-State: AGi0PuYja24MilvhpuFGwu884aqOvj69iMn1AyN9eanPWAKOn3Yo3HJG sAmKy/hhdrt1MT5RytkQhSk= X-Google-Smtp-Source: APiQypKiBty5CpIpfGztv4nVNxYPHE26i8fDnz5Ytl7Qs6ZtBCPZPKb0pA9yY8qIqcuBo0z5CjCFkQ== X-Received: by 2002:a37:a8c7:: with SMTP id r190mr28703945qke.65.1587579675085; Wed, 22 Apr 2020 11:21:15 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id i5sm4443308qtw.97.2020.04.22.11.21.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2020 11:21:14 -0700 (PDT) Subject: [PATCH v21 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: Wed, 22 Apr 2020 11:21:13 -0700 Message-ID: <20200422182113.12258.56556.stgit@localhost.localdomain> In-Reply-To: <20200422181649.12258.37077.stgit@localhost.localdomain> References: <20200422181649.12258.37077.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::743; envelope-from=alexander.duyck@gmail.com; helo=mail-qk1-x743.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::743 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. Signed-off-by: Alexander Duyck Acked-by: David Hildenbrand --- 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 Wed Apr 22 18:21:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11504395 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 C1D171667 for ; Wed, 22 Apr 2020 18:23:49 +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 988652098B for ; Wed, 22 Apr 2020 18:23:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ca2j8IaF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 988652098B 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]:55722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRK2G-0000Gl-Oh for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Apr 2020 14:23:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51050) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRJzw-0005Ij-O1 for qemu-devel@nongnu.org; Wed, 22 Apr 2020 14:21:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jRJzw-0003Fw-4n for qemu-devel@nongnu.org; Wed, 22 Apr 2020 14:21:24 -0400 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]:44625) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jRJzv-0003DD-Mc for qemu-devel@nongnu.org; Wed, 22 Apr 2020 14:21:23 -0400 Received: by mail-qt1-x843.google.com with SMTP id c23so1969123qtp.11 for ; Wed, 22 Apr 2020 11:21:22 -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=3XHy8cPDC058ii5Kpvd4Vd9LUQpAYLHDshsvadW2rYw=; b=Ca2j8IaF63I//mpvBhD/h3tEVSMmXmgLy/mXrU7Tp6Pi9R+8OtFo+d25sd16Sa4RKq yXPqCIOkFzQcvPhGQ4Hr6wAy5F7v89XuXVAmq/mmUwwL0/lHgr6tMUF9ahcPv94/hW6l ukVmUZ0m8SNE79ZsfCv4wGtGfiZbWD/fEfN/B+4GSDKVeJF3fL51YHtS/Sx46WDr1Agd lAY9bzdBalIZrDV2F2mQMRyAf0zSL38b9EPcL8HEJMRfjjFNQ+OPaGRk6OyM9WJtkwog nybF5sfEYN2sAZm3pzxqzglf/IgkwZr9zpunWP1E8a+NBaeoylJ2qeJkjq6HkG1FH13i o09g== 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=3XHy8cPDC058ii5Kpvd4Vd9LUQpAYLHDshsvadW2rYw=; b=tmP33geFfCJ10ht0sFD9eG/q+bxsodad6ttfDtPmgfMELHjZMU0vf+SCYgmBXXiWVp hA6oW+r8HZFfp9vmOpCY2TVkXfJd5Pwq1QVohvf+gDsMNxqQBcPHD6QdHGKPdQwf5Utj AYEzjeWdY3qZVlkKSEzup3rwqpJiPid6qYWMMpvJGAngkMpW04kC1SbZJGvz2/Z4DDsl FiWBZOvqUjGJAQXQRkLUjfhlDc+tdqDDATkXhQLGX2bmukVHFMOiCOst+k8wqjxoiiL9 sGJ2OIw8idjt7Mb1YL+Yda7IvnbMAhVNnb/sFs4Ix30V81DXjsNHIzjxPnVmkcJyYjqX 11pA== X-Gm-Message-State: AGi0PuZWbQugJNLY/ASez5KhPrG0fAWtpMsuI6BSuA/P9QoNA0xske1x CM8M7nznX7Ue6EB123YV9SA= X-Google-Smtp-Source: APiQypLWDF3f0qFxa+6+HGzJSoHVxo0zSUHkDxEs+y+v/RaMyA7Av1wfNmeeECPfsezr0A8LOESxQw== X-Received: by 2002:ac8:3254:: with SMTP id y20mr28002535qta.67.1587579682135; Wed, 22 Apr 2020 11:21:22 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id b126sm4422623qkc.119.2020.04.22.11.21.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2020 11:21:21 -0700 (PDT) Subject: [PATCH v21 QEMU 4/5] virtio-balloon: Implement support for page poison tracking feature From: Alexander Duyck To: david@redhat.com, mst@redhat.com Date: Wed, 22 Apr 2020 11:21:20 -0700 Message-ID: <20200422182120.12258.67417.stgit@localhost.localdomain> In-Reply-To: <20200422181649.12258.37077.stgit@localhost.localdomain> References: <20200422181649.12258.37077.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::843; envelope-from=alexander.duyck@gmail.com; helo=mail-qt1-x843.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::843 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 tracking if we want to actually get data on if the guest will be poisoning pages. Add a value for tracking the poison value being used if page poisoning is enabled. With this we can determine if we will need to skip page reporting when it is enabled in the future. Signed-off-by: Alexander Duyck --- hw/virtio/virtio-balloon.c | 7 +++++++ include/hw/virtio/virtio-balloon.h | 1 + 2 files changed, 8 insertions(+) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index a1d6fb52c876..5effc8b4653b 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 = @@ -697,6 +698,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_vdev_has_feature(vdev, VIRTIO_BALLOON_F_PAGE_POISON)) { + dev->poison_val = le32_to_cpu(config.poison_val); + } trace_virtio_balloon_set_config(dev->actual, oldactual); } @@ -854,6 +859,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) 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 Wed Apr 22 18:21:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11504399 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 A909A112C for ; Wed, 22 Apr 2020 18:24:05 +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 80A9E21473 for ; Wed, 22 Apr 2020 18:24:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="o+8GWSOH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80A9E21473 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]:55726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRK2W-0000lx-Me for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Apr 2020 14:24:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51138) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRK03-0005TQ-QT for qemu-devel@nongnu.org; Wed, 22 Apr 2020 14:21:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jRK02-0003ZD-OF for qemu-devel@nongnu.org; Wed, 22 Apr 2020 14:21:31 -0400 Received: from mail-qv1-xf32.google.com ([2607:f8b0:4864:20::f32]:35713) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jRK02-0003WI-9f for qemu-devel@nongnu.org; Wed, 22 Apr 2020 14:21:30 -0400 Received: by mail-qv1-xf32.google.com with SMTP id v10so1401231qvr.2 for ; Wed, 22 Apr 2020 11:21:29 -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=SH/65jIkrtSeeW/mAEjdDz+ENo/q+X4g5sfgY/LNkF8=; b=o+8GWSOHmbU20SpYCo6cG5qDyEn618Ub2pWbnxpl9VOimJ4keG2iNhuxuN6EOl9z0g 6sMyoEqyMPm24tfSgVqlbgSxMF/qnYdensEqTa0nYuoxVC4aMf8r3OQVI9x1UN9igIuh ln/tcmJGUKxU5AuKodXh11qCQ4uZT5h5UbA85pFbR7RVzE0B1COyaLU7+UQNQLZWeMQs G5wb946Eg1t7Z/iHZKqu6UqylcQ5kbPHImRb0UJQwdtmtmOQ1rH+C8OW9MrE57wImh3V OBvAMtcbQ5hr9qT1VVyO4r6/Rg6bFc50JN2+ipFVgZcPnVZQngyZ5AH2NDPgJZfoGgyT 1SSw== 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=SH/65jIkrtSeeW/mAEjdDz+ENo/q+X4g5sfgY/LNkF8=; b=Fo5uU21p7XXyv4yctBTWzGBZSb+UI6WTXg+hOcAnFFonljXSXOxewYgd6Qb1a9CYAr d7tMR7oLMHbur9sPty4CBtKq4rtI2PHHvCAd2v7Mn9c0N3yMY44Tr37dozZOj+XPG1Yx 4KWi+8SiMp+dOQuvuns9J/si0ys7S3Mxy/AtDVh+js4XI9tHEHHWL878xG7l/F6dJUXK 42blVAvppGVHxkg0zn6negGyTYoLDHUMuahGlKGuaa15ffYhy/px6kJmQEn11AStfOGU k1d+ABXrMD1oIE8W5e5EIFwVER3bRZYvDTVp1JmLVtKWHs/XdcZE25aGnYcEdJPotM3U ce7w== X-Gm-Message-State: AGi0Pua7rMYs4eUBHsPV3Cpgbtq20THEVR7tSP93JS+9dNFAaB53BXFS 6vouB2zi1CpZJV6PP0K/nYQIPsvBTUs= X-Google-Smtp-Source: APiQypILZzG2AF6qSMFleXJPZPIwp9FqAM9MYhXU03tP1UBo9fl5/OaSf4KPQNy9pPbXCDUI69VVgQ== X-Received: by 2002:a0c:e8c2:: with SMTP id m2mr247175qvo.24.1587579689243; Wed, 22 Apr 2020 11:21:29 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id f130sm4397937qke.22.2020.04.22.11.21.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2020 11:21:28 -0700 (PDT) Subject: [PATCH v21 QEMU 5/5] virtio-balloon: Provide an interface for free page reporting From: Alexander Duyck To: david@redhat.com, mst@redhat.com Date: Wed, 22 Apr 2020 11:21:27 -0700 Message-ID: <20200422182127.12258.26300.stgit@localhost.localdomain> In-Reply-To: <20200422181649.12258.37077.stgit@localhost.localdomain> References: <20200422181649.12258.37077.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f32; envelope-from=alexander.duyck@gmail.com; helo=mail-qv1-xf32.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::f32 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 --- hw/virtio/virtio-balloon.c | 70 ++++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio-balloon.h | 2 + 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 5effc8b4653b..b473ff7f4b88 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -321,6 +321,60 @@ 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; + + 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); @@ -782,6 +836,16 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp) VirtIOBalloon *s = VIRTIO_BALLOON(dev); int ret; + /* + * Page reporting is dependant on page poison to make sure we can + * report a page without changing the state of the internal data. + * We need to set the flag before we call virtio_init as it will + * affect the config size of the vdev. + */ + if (virtio_has_feature(s->host_features, VIRTIO_BALLOON_F_REPORTING)) { + s->host_features |= 1 << VIRTIO_BALLOON_F_PAGE_POISON; + } + virtio_init(vdev, "virtio-balloon", VIRTIO_ID_BALLOON, virtio_balloon_config_size(s)); @@ -798,6 +862,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, @@ -923,6 +991,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("free-page-reporting", VirtIOBalloon, host_features, + VIRTIO_BALLOON_F_REPORTING, 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 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;