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 D05B9C48BE5 for ; Thu, 10 Jun 2021 16:43:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA5B6613E9 for ; Thu, 10 Jun 2021 16:43:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231857AbhFJQo4 (ORCPT ); Thu, 10 Jun 2021 12:44:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36399 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231879AbhFJQoJ (ORCPT ); Thu, 10 Jun 2021 12:44:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623343331; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FTYsk+3ZrtMDgibB9knYQRxYmGEpuIUf1VdElxSCW6k=; b=TrMQDsKp+FKHxX4nb0ERe0QpfAZo046yyVth6XhXZarsIKikOxe2S4GuwEE4mHX8KJm5Dl R0b7PJQ5LXGxbyXL+DLdbs65laG56d1Sq+pM+SZEBBBKmUnoyC72EXFFILSHrXk6rwnVxm HAsklXT37ERwhPDBTzggcxIgBGi4SWc= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-209-Q-eGBzA-Of2zDPS0hAF33w-1; Thu, 10 Jun 2021 12:42:10 -0400 X-MC-Unique: Q-eGBzA-Of2zDPS0hAF33w-1 Received: by mail-wm1-f71.google.com with SMTP id r4-20020a7bc0840000b02901b7cb5713ecso1441230wmh.1 for ; Thu, 10 Jun 2021 09:42:10 -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:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=FTYsk+3ZrtMDgibB9knYQRxYmGEpuIUf1VdElxSCW6k=; b=hc1hxRbQNlKoM36AWGbR+KmJcpFlZv7jyTSWbN61RzQfdswI9yu+i0RJ2nhYnVixOv Py+2w9dtUYb4yVpmZWC8ywPZ/4vjPJ2n2w0jTV+ZrfHwuenNURO74DOn+vFM5c5g/+TH nLMCa3690rBv0zV3tXccYrfFJ260f8UvqCk84XRy8RI9fRFaHrOlNS7gIKET4nvK43pg tu5QP14nr4cJ489/MKVjZ8vmXt7WPEymV4yqk34HDci0a5NzZ7C1ssfyTFCJwOYAMjVy Eir/XizODO9QSl6OYTcYKGXFo0vJmqEJr9cLQmKPZlyLqpM/xvM0m10A6GY6V2QJZ5XT TpZw== X-Gm-Message-State: AOAM533Ipohojz3XWiNF57QCeJ/LawjOm1+VrCdGiaDs6hBRYFpXMpDa 8IAg/uwUHaKd+14H1LGexcE1Y2rFEHIhslSRLeXyiFepmls0rsNgKSPuXsDlKDLdlBSSdmXO1dI ODv+LAhuf5aT0 X-Received: by 2002:adf:ab49:: with SMTP id r9mr6556025wrc.237.1623343329060; Thu, 10 Jun 2021 09:42:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT8GKTcc6CtIM2Omfzfm3HSpY3IDEVA0VZ0HkqF8YvTQlmVrTL+SEqxKoSDnFCTA+GbV+zog== X-Received: by 2002:adf:ab49:: with SMTP id r9mr6556002wrc.237.1623343328880; Thu, 10 Jun 2021 09:42:08 -0700 (PDT) Received: from ?IPv6:2001:b07:add:ec09:c399:bc87:7b6c:fb2a? ([2001:b07:add:ec09:c399:bc87:7b6c:fb2a]) by smtp.gmail.com with ESMTPSA id f13sm4050941wrt.86.2021.06.10.09.42.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Jun 2021 09:42:08 -0700 (PDT) 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 References: <20210603211426.790093-1-jingzhangos@google.com> <20210603211426.790093-3-jingzhangos@google.com> From: Paolo Bonzini Subject: Re: [PATCH v7 2/4] KVM: stats: Add fd-based API to read binary stats data Message-ID: <345170fd-636c-f1be-7dc3-69467e51d872@redhat.com> Date: Thu, 10 Jun 2021 18:42:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210603211426.790093-3-jingzhangos@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On 03/06/21 23:14, Jing Zhang wrote: > +struct _kvm_stats_header { > + __u32 name_size; > + __u32 count; > + __u32 desc_offset; > + __u32 data_offset; > +}; > + Keeping this struct in sync with kvm_stats_header is a bit messy. If you move the id at the end of the header, however, you can use the same trick with the zero-sized array that you used for _kvm_stats_desc. > +struct kvm_vm_stats_data { > + unsigned long value[0]; > +}; > + I posted the patch to switch the VM statistics to 64-bit; you can rebase on top of it. > +#define KVM_GET_STATS_FD _IOR(KVMIO, 0xcc, struct kvm_stats_header) This should be _IO(KVMIO, 0xcc) since it does not have an argument. > +#define STATS_DESC(stat, type, unit, scale, exp) \ > + { \ > + { \ > + .flags = type | unit | scale, \ > + .exponent = exp, \ > + .size = 1 \ > + }, \ > + .name = stat, \ Here you can use type | BUILD_BUG_ON_ZERO(type & ~KVM_STATS_TYPE_MASK) | unit | BUILD_BUG_ON_ZERO(unit & ~KVM_STATS_UNIT_MASK) | scale | BUILD_BUG_ON_ZERO(scale & ~KVM_STATS_SCALE_MASK) | to get a little bit of type checking. Paolo