From mboxrd@z Thu Jan 1 00:00:00 1970 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=-7.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 E3377C433E9 for ; Tue, 16 Mar 2021 17:55:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD40B65104 for ; Tue, 16 Mar 2021 17:55:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239375AbhCPRzX (ORCPT ); Tue, 16 Mar 2021 13:55:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:54881 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239414AbhCPRy5 (ORCPT ); Tue, 16 Mar 2021 13:54:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615917296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q+nIYLcJsbNrOQJXNJzvpf/dZa2SR4YCfI1fCwdaCUY=; b=WsvcAM/DVZVN+35RQG4SU18F0p3n/dpdLxLxWAAmKFjaqnh3e65gERW6qfIO7IqkCxJQ8q qGH3g4UIkk5SlcSS6KQOmSYkXOMz25ctOFCeD3iIaRz7PMkb+aczhGLtHdL3gNhmH9DLcY LB0dVH2+spXH+ePpC9hSAz8ozFvlNls= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-288-QuVom0HdM9WbPXAT00tysw-1; Tue, 16 Mar 2021 13:54:54 -0400 X-MC-Unique: QuVom0HdM9WbPXAT00tysw-1 Received: by mail-wr1-f69.google.com with SMTP id h21so16895705wrc.19 for ; Tue, 16 Mar 2021 10:54:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=q+nIYLcJsbNrOQJXNJzvpf/dZa2SR4YCfI1fCwdaCUY=; b=SOr2CijFl/7Eh6bNFL4NogSmP/7jyS48IP1EF0YRnN71Z/HQcFaV1pAjE31cRZwYw3 vuV1KHxY1rVojwD6mlGnd0Be5HwYKXTIdJ+RpnoUx1DDevTWKTJLoDEN2ou+9N8ty+K9 vsYAU2L2wqhb+WcLRZ7yOrKEy81m2APwf/oy0WCJT38qxt657Britdbn12CSI4uZRzfw kfjDh0mAQpwupOEo0+5PtJywqSZ3pFjbbKDBCyeJS9u/Wk1YWDY9r0jl0zz/pkXHzzrh TuXGWocGe6yXx8Yy+YvpQVqTZHxurEHwxlb+T4+gUf7M6797pbwPYq1pjIPkc0gpE/Ia dMzg== X-Gm-Message-State: AOAM533dcw3JXPCpoQrRWUJ7UEueWvRfuHkhwYpgilvuBUaQ8Br7NyrL +z+2mNkX8HHVPb61HE+YfMNgdHCe+xPx8GCBgRIxtvh0LWCYXKn8v6U44PbbLr4ePiZcEsovZvF BNJ+BMDDdJ3AFUGRgInXNJw== X-Received: by 2002:a7b:c2f7:: with SMTP id e23mr100846wmk.30.1615917293666; Tue, 16 Mar 2021 10:54:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhx2jdBpeYlHU1yJBLoi471Tl00503kY5ZdmFFXsMHSMA2gpxqqBKYhTriICrO+/ourTLAQg== X-Received: by 2002:a7b:c2f7:: with SMTP id e23mr100818wmk.30.1615917293485; Tue, 16 Mar 2021 10:54:53 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id s83sm7994wms.16.2021.03.16.10.54.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Mar 2021 10:54:52 -0700 (PDT) To: Jing Zhang Cc: KVM , KVM ARM , Linux MIPS , KVM PPC , Linux S390 , Linux kselftest , 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 References: <20210310003024.2026253-1-jingzhangos@google.com> <20210310003024.2026253-4-jingzhangos@google.com> From: Paolo Bonzini Subject: Re: [RFC PATCH 3/4] KVM: stats: Add ioctl commands to pull statistics in binary format Message-ID: <26035a80-3cce-9872-ab1d-b25b5817d512@redhat.com> Date: Tue, 16 Mar 2021 18:54:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org On 15/03/21 23:31, Jing Zhang wrote: > We are considering about how to create the file descriptor. It might be risky > to create an extra fd for every vCPU. It will easily hit the fd limit for the > process or the system for machines running a ton of small VMs. You already have a file descriptor for every vCPU, but I agree that having twice as many is not very good. > Looks like creating an extra file descriptor for every VM is a better option. > And then we can check per vCPU stats through Ioctl of this VM fd by > passing the vCPU index. The file descriptor idea is not really infeasible I think (not just because the # of file descriptors is "only" doubled, but also because most of the time I think you'd only care of per-VM stats). If you really believe it's not usable for you, you can use two ioctls to fill the description and the data respectively (i.e. ioctl(fd, KVM_GET_STATS_{DESCRIPTION,VALUES}, pdata) using the same layout as below. If called with NULL argument, the ioctl returns how much data they will fill in. The (always zero) global flags can be replaced by the value returned by KVM_CHECK_EXTENSION. The number of statistics can be obtained by ioctl(fd, KVM_GET_STATS_VALUES, NULL), just divide the returned value by 8. Paolo >> 4 bytes flags (always zero) >> 4 bytes number of statistics >> 4 bytes offset of the first stat description >> 4 bytes offset of the first stat value >> stat descriptions: >> - 4 bytes for the type (for now always zero: uint64_t) >> - 4 bytes for the flags (for now always zero) >> - length of name >> - name >> statistics in 64-bit format