From: Paolo Bonzini Date: Wed, 16 Jun 2021 17:12:11 +0000 Subject: Re: [PATCH v9 2/5] KVM: stats: Add fd-based API to read binary stats data Message-Id: <60b0d569-e484-f424-722b-eb7ba415e19b@redhat.com> List-Id: References: <20210614212155.1670777-1-jingzhangos@google.com> <20210614212155.1670777-3-jingzhangos@google.com> In-Reply-To: <20210614212155.1670777-3-jingzhangos@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Jing Zhang , KVM , KVMARM , LinuxMIPS , KVMPPC , LinuxS390 , Linuxkselftest , 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 , David Matlack , Ricardo Koller , Krish Sadhukhan , Fuad Tabba On 14/06/21 23:21, Jing Zhang wrote: > + /* Copy kvm stats values */ > + copylen = header->header.data_offset + size_stats - pos; > + copylen = min(copylen, remain); > + if (copylen > 0) { > + src = stats + pos - header->header.data_offset; > + if (copy_to_user(dest, src, copylen)) > + return -EFAULT; > + remain -= copylen; > + pos += copylen; > + dest += copylen; > + } Hi Jing, this code is causing usercopy warnings because the statistics are not part of the vcpu slab's usercopy region. You need to move struct kvm_vcpu_stat next to struct kvm_vcpu_arch, and adjust the call to kmem_cache_create_usercopy in kvm_init. Can you post a new version of the series, and while you are at it explain the rationale for binary stats in the commit message for this patch? This should include: - the problem statement (e.g. frequency of the accesses) - what are the benefits compared to debugfs - why the schema is included in the file descriptor as well You can probably find a lot or all of the information in my emails from the last couple days, but you might also have other breadcrumbs from Google's internal implementation of binary stats. Thanks, Paolo