Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp634570ybz; Wed, 15 Apr 2020 15:36:11 -0700 (PDT) X-Google-Smtp-Source: APiQypKphURpBQV1jLR8mTAU8NTy+rTi0rplxszGMt/Z3FYKVMd/4cWRoy/pZ6caMi/djGlaJWg0 X-Received: by 2002:aa7:d78b:: with SMTP id s11mr28092066edq.226.1586990171605; Wed, 15 Apr 2020 15:36:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586990171; cv=none; d=google.com; s=arc-20160816; b=1KP4/CeBHqAq3ndusg0Wj2U3Z2sId5WhXmeVoiQpEFcvChTxw6omJzYwMZSC4+eSA+ lt2xl0SXG7h/u7ujoHwDMjGV5UG9KhwQc+rqYSgktCa6Cs/grAYeYFJtsle+HmVCTKYO w9b4td12P5Q/TbY6Jc75k1VTr4IRVgjSnPnq34XkzduaGG84HI+hHn7n51O/xDIkT89r nz1ZFeBiZy2XsK57ROwc+oJTTnS/4yB2+PSv/9jjg6OQV1GcqVKyJwAbqAyyjvkc1lBT Lj+nI6yyHnKiuwvgtITZob898vi4m1/IhSDcaew3FYRc4wnvOzt52zDEwv8svxeXsTRd VHkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=bLmrOkcXJQ/8f3TsPjBB59Qp6PFUF6WHach7rOTidPU=; b=HstSgzQkQWPnSmGvRcQYpZzslzeBe9HZq6SlNEc/EXM13bCeP2kw1fg9aZZ75p9t0Y rTVvb72WeA4B8TALHk89z5GE7hgfTKGhRyHL4pO5IdEzYWcnD362ClgRtpQIEsQ+G4GG TQjTuFiB8guRyjHcHR4VJnx/1xEwSm0dAvKht509yKr8DvYTJrOpuLWo6bx2oecwdWHf 9mzcFCITx9gXVKT2rjtoQC+YekVlB2EwnNOrog0nv+glBA8wnjLj9F6KYHVaKGmcfFPj re1yff4wWQmpMZWj57EPdS5N37GPZZZd+0nCfCg2OutvD11KAeH869nIC3Ds1xft3kHY 0gww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Yb7p1K7s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k17si3303812ejg.470.2020.04.15.15.35.48; Wed, 15 Apr 2020 15:36:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Yb7p1K7s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408067AbgDOIa0 (ORCPT + 99 others); Wed, 15 Apr 2020 04:30:26 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:33062 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2408046AbgDOIaQ (ORCPT ); Wed, 15 Apr 2020 04:30:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586939414; 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=bLmrOkcXJQ/8f3TsPjBB59Qp6PFUF6WHach7rOTidPU=; b=Yb7p1K7sVA3olaCuHiBBjK9yqILcoVdKBSzQpmJF0kxrIzL6C2Mt/pQE1wdX4bML6D9hNY G3y5HkTMxQs3vdnCBV6/wkBL2Z63GMx+P1UdlLMy9rrM7ejSgqNg9i8cr4HtgFYl/j3P/6 i3SeRFqf+ifkLFnwcXaQBl2OzzMFbzc= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-259-t2O1iRReO8yDzyEE8oEDug-1; Wed, 15 Apr 2020 04:30:10 -0400 X-MC-Unique: t2O1iRReO8yDzyEE8oEDug-1 Received: by mail-wr1-f70.google.com with SMTP id s11so5338132wru.6 for ; Wed, 15 Apr 2020 01:30: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:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=bLmrOkcXJQ/8f3TsPjBB59Qp6PFUF6WHach7rOTidPU=; b=CYE6Dx/BI891NtrLAfvtdi6gbEz7vzmtU3lO3nM8A3Va3ZEt9/RQc1HuUNnh61tjjo yq6fYbWO2oPBlLCGoYyfPFg0TI9/LF4/yrjb8sP8Xxr0zBkmqThGAxTCp1r75izaF5A1 PAVkllbD3Xgxz1kvuqmUl6H9mpmFvsvVxqOT/oZNHwO2GLiu+NdnxV3S1rM+HBAfcaoN mVAIvMTt5wGsYXx7KQLrjrZprAy5hSsgJktwjUK6vtaoaNFAHdy4mgf3W390EKGxwnG0 Bv15HVImmckmsITnrS7qiB2DBZBoXSH8q++BFZfIFnr18C52jtr988G6ny6oymwLv4Sp qd7g== X-Gm-Message-State: AGi0PuY8Wj2YeMJrFlm86zdggJjuVDJmfsuLHMOgg2bByoMwq/9IYGEn OZJ4hMLZ2w/IqCv3TaZAwSZdfDLhK3Sy/LooG+hEvRxnzwrZCFeJxTYwkk4GDgfvWYS323GMc0r zOiUiOY3Qqbu1PRGggEA72e6x X-Received: by 2002:a1c:b445:: with SMTP id d66mr4126790wmf.187.1586939409338; Wed, 15 Apr 2020 01:30:09 -0700 (PDT) X-Received: by 2002:a1c:b445:: with SMTP id d66mr4126760wmf.187.1586939409106; Wed, 15 Apr 2020 01:30:09 -0700 (PDT) Received: from localhost.localdomain ([194.230.155.238]) by smtp.gmail.com with ESMTPSA id g25sm8724053wmh.24.2020.04.15.01.30.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Apr 2020 01:30:08 -0700 (PDT) Subject: Re: [PATCH v2] kvm_host: unify VM_STAT and VCPU_STAT definitions in a single place To: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , kvm@vger.kernel.org Cc: Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Paul Mackerras , Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, kvm-ppc@vger.kernel.org, linux-s390@vger.kernel.org References: <20200414155625.20559-1-eesposit@redhat.com> From: Emanuele Giuseppe Esposito Message-ID: <992ede27-3eae-f2da-ad38-1d3498853ad2@redhat.com> Date: Wed, 15 Apr 2020 10:30:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/15/20 8:36 AM, Philippe Mathieu-Daudé wrote: > On 4/14/20 5:56 PM, Emanuele Giuseppe Esposito wrote: >> The macros VM_STAT and VCPU_STAT are redundantly implemented in multiple >> files, each used by a different architecure to initialize the debugfs >> entries for statistics. Since they all have the same purpose, they can be >> unified in a single common definition in include/linux/kvm_host.h >> >> Signed-off-by: Emanuele Giuseppe Esposito >> --- >> arch/arm64/kvm/guest.c | 23 ++--- >> arch/mips/kvm/mips.c | 61 ++++++------ >> arch/powerpc/kvm/book3s.c | 61 ++++++------ >> arch/powerpc/kvm/booke.c | 41 ++++---- >> arch/s390/kvm/kvm-s390.c | 203 +++++++++++++++++++------------------- >> arch/x86/kvm/x86.c | 80 +++++++-------- >> include/linux/kvm_host.h | 5 + >> 7 files changed, 231 insertions(+), 243 deletions(-) >> >> diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c >> index 23ebe51410f0..8417b200bec9 100644 >> --- a/arch/arm64/kvm/guest.c >> +++ b/arch/arm64/kvm/guest.c >> @@ -29,20 +29,17 @@ >> >> #include "trace.h" >> >> -#define VM_STAT(x) { #x, offsetof(struct kvm, stat.x), KVM_STAT_VM } >> -#define VCPU_STAT(x) { #x, offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU } >> - >> struct kvm_stats_debugfs_item debugfs_entries[] = { >> - VCPU_STAT(halt_successful_poll), >> - VCPU_STAT(halt_attempted_poll), >> - VCPU_STAT(halt_poll_invalid), >> - VCPU_STAT(halt_wakeup), >> - VCPU_STAT(hvc_exit_stat), >> - VCPU_STAT(wfe_exit_stat), >> - VCPU_STAT(wfi_exit_stat), >> - VCPU_STAT(mmio_exit_user), >> - VCPU_STAT(mmio_exit_kernel), >> - VCPU_STAT(exits), >> + VCPU_STAT("halt_successful_poll", halt_successful_poll), >> + VCPU_STAT("halt_attempted_poll", halt_attempted_poll), >> + VCPU_STAT("halt_poll_invalid", halt_poll_invalid), >> + VCPU_STAT("halt_wakeup", halt_wakeup), >> + VCPU_STAT("hvc_exit_stat", hvc_exit_stat), >> + VCPU_STAT("wfe_exit_stat", wfe_exit_stat), >> + VCPU_STAT("wfi_exit_stat", wfi_exit_stat), >> + VCPU_STAT("mmio_exit_user", mmio_exit_user), >> + VCPU_STAT("mmio_exit_kernel", mmio_exit_kernel), >> + VCPU_STAT("exits", exits), >> { NULL } >> }; > > Patch easily reviewed with --word-diff. > > [...] >> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h >> index 6d58beb65454..2e6ead872957 100644 >> --- a/include/linux/kvm_host.h >> +++ b/include/linux/kvm_host.h >> @@ -1130,6 +1130,11 @@ struct kvm_stats_debugfs_item { >> #define KVM_DBGFS_GET_MODE(dbgfs_item) \ >> ((dbgfs_item)->mode ? (dbgfs_item)->mode : 0644) >> >> +#define VM_STAT(n, x, ...) \ >> + { n, offsetof(struct kvm, stat.x), KVM_STAT_VM, ## __VA_ARGS__ } >> +#define VCPU_STAT(n, x, ...) \ > > Not sure while you use so many whitespaces here... (maybe Paolo can > strip some when applying?). I honestly am not sure why it added few more spaces than I wanted, but the idea was to follow the KVM_DBGFS_GET_MODE macro above and put the backslash at the end of the line (80th char). > > Otherwise it looks nicer that v1, thanks. > > Reviewed-by: Philippe Mathieu-Daudé > >> + { n, offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU, ## __VA_ARGS__ } >> + >> extern struct kvm_stats_debugfs_item debugfs_entries[]; >> extern struct dentry *kvm_debugfs_dir; >> >> >