From patchwork Wed Mar 10 00:30:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Zhang X-Patchwork-Id: 12126741 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9B18C4332D for ; Wed, 10 Mar 2021 00:31:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A477D64FF7 for ; Wed, 10 Mar 2021 00:31:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231341AbhCJAbP (ORCPT ); Tue, 9 Mar 2021 19:31:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231335AbhCJAam (ORCPT ); Tue, 9 Mar 2021 19:30:42 -0500 Received: from mail-io1-xd49.google.com (mail-io1-xd49.google.com [IPv6:2607:f8b0:4864:20::d49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B311CC061762 for ; Tue, 9 Mar 2021 16:30:42 -0800 (PST) Received: by mail-io1-xd49.google.com with SMTP id x26so11677654ior.7 for ; Tue, 09 Mar 2021 16:30:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=1BcHrgVIevscHGOPbP9Sxwife20LoA3ZZqd9CRbz5Bw=; b=DKv71NfHgZl9K+3WTTgnMIMFhTJhw0KdiZ+0DsSSoWMbruSU8JYpotmsteHcMpFnKP p3oJl9d7poG/uNqx9QVjZxRsDg84eU0xeqR/z3zNbVYX8v/8Pqaq2D2o6XtuLtoQIAWn XZIko6RjucQT9l8eCAbgMb2o84jv4v0MYqAUW+gbWQ/6DAdn7cgT09hkIvc7uvV40U3/ OXNI1psrB1fZwZO3xGQK35hCSkEnWUaO1l3/peXbxmeOQdZwn1Qj3XsVRuxh8uptWwNf ZpoGFHSOUGyGujS8e+ldyI4tL/z2BcdRYhlTSsMqOPaw7n36OXxIcUJIiplu0hMkQaNX IFPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=1BcHrgVIevscHGOPbP9Sxwife20LoA3ZZqd9CRbz5Bw=; b=OzL4j5+3NWUcMoxiVkt+3Yt5PkC1RwrwcLkZeLO80de7jMYeyBrGIBh5BJ4SlZIsgG Imj1lNW804Mb0Qn/dQbOcB2Z72zG4vef2fjgunG62f+QSFL81bdoVnoGMwh2KPkg+99Z 0DsnWQvleMBaVqWRNryvfOpB1el7Aejg/bSNMIb7+L0329dglBJpPO+Y7D9kYPLRYqZY zKAH1hvVqoahehGIZKX3YoQYlNALB7/h4UFARkPRaT3IgsKxaJ6ZOqi1iaT6eJS6iw2a leEvcZnLq8Vn4EkTnu4NormGhHSvUgf4GmjmILkzT+GNcHhZo1klvV1ztrORonrZCtIF zFtg== X-Gm-Message-State: AOAM5338U71GYQjPUYhNT1fvXr0VdrNnAxNdDdC6KJaMf4d/4zvRHulz l9zif+8mPtIDiz20WPs8JJYHWlYcEUeY0h+2X0CZ8RaA1nsbehL/v1FGovasKut0bP/V1WL7G0B DOXCKlGAFIeUwuP8wvRQKDOFnzoIPBHYGPKPJt+9LYdFxnDDeRstIhq/FRfFLW5Vr7jPa9/c= X-Google-Smtp-Source: ABdhPJzu6oYBav/oVxbZg4DkYFlYy8mfxqu7QjB5WE/gplPDgic3NrLr6r8qLWmnqz7/bt/7iNP/OuQ+NB4k0O9fnQ== X-Received: from jingzhangos.c.googlers.com ([fda3:e722:ac3:10:2b:ff92:c0a8:513]) (user=jingzhangos job=sendgmr) by 2002:a92:b00d:: with SMTP id x13mr708430ilh.128.1615336242003; Tue, 09 Mar 2021 16:30:42 -0800 (PST) Date: Wed, 10 Mar 2021 00:30:20 +0000 Message-Id: <20210310003024.2026253-1-jingzhangos@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [RFC PATCH 0/4] KVM: stats: Retrieve statistics data in binary format From: Jing Zhang To: KVM , KVM ARM , Linux MIPS , KVM PPC , Linux S390 , Linux kselftest , Paolo Bonzini , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Will Deacon , Huacai Chen , Aleksandar Markovic , Thomas Bogendoerfer , Paul Mackerras , Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Peter Shier , Oliver Upton , David Rientjes , Emanuele Giuseppe Esposito Cc: Jing Zhang Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This patchset extends IOCTL interface to retrieve KVM statistics data in aggregated binary format. It is meant to provide a lightweight, flexible, scalable and efficient lock-free solution for userspace telemetry applications to pull the statistics data periodically for large scale systems. The capability is indicated by KVM_CAP_STATS_BINARY_FORM. Ioctl KVM_STATS_GET_INFO is used to get the information about VM or vCPU statistics data (The number of supported statistics data which is used for buffer allocation). Ioctl KVM_STATS_GET_NAMES is used to get the list of name strings of all supported statistics data. Ioctl KVM_STATS_GET_DATA is used to get the aggregated statistics data per VM or vCPU in the same order as the list of name strings. This is the ioctl which would be called periodically to retrieve statistics data per VM or vCPU. Jing Zhang (4): KVM: stats: Separate statistics name strings from debugfs code KVM: stats: Define APIs for aggregated stats retrieval in binary format KVM: stats: Add ioctl commands to pull statistics in binary format KVM: selftests: Add selftest for KVM binary form statistics interface Documentation/virt/kvm/api.rst | 79 +++++ arch/arm64/kvm/guest.c | 47 ++- arch/mips/kvm/mips.c | 114 +++++-- arch/powerpc/kvm/book3s.c | 107 ++++-- arch/powerpc/kvm/booke.c | 84 +++-- arch/s390/kvm/kvm-s390.c | 320 ++++++++++++------ arch/x86/kvm/x86.c | 127 ++++--- include/linux/kvm_host.h | 30 +- include/uapi/linux/kvm.h | 60 ++++ tools/testing/selftests/kvm/.gitignore | 1 + tools/testing/selftests/kvm/Makefile | 3 + .../selftests/kvm/kvm_bin_form_stats.c | 89 +++++ virt/kvm/kvm_main.c | 115 +++++++ 13 files changed, 935 insertions(+), 241 deletions(-) create mode 100644 tools/testing/selftests/kvm/kvm_bin_form_stats.c base-commit: 357ad203d45c0f9d76a8feadbd5a1c5d460c638b