Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp570461ybp; Wed, 9 Oct 2019 00:18:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWEI4zLxbiVVYBdE54lDeMC4FVmRpPMEZuu4Tj32SrLSnGpZ8ue1P9UuAT0NHiqwgQFwlm X-Received: by 2002:a17:906:5407:: with SMTP id q7mr1487213ejo.24.1570605506318; Wed, 09 Oct 2019 00:18:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570605506; cv=none; d=google.com; s=arc-20160816; b=NEfTPTONgWoyYh+2dVryQWIAcOp0tmGpDPT2jJfTl1JD6e3LCgaMjQkf8WR4rCy5fV 2LkWioQ60upK+cqhyH2e3bGgH7LHA6gFxJrk45Ebx3qb4DMrz9vo02jdm7IqqiLeq/PS 9Jpiz8x6WvRUGyrXSBvL6nBqpmB36NjWTP1+PytbtznlEK5ASYOt5fNEQrE9Rq/QioG3 3IiZtjoM0DfhkmuKfd+e1kUfzlmxf/FkvR+o+kGVFoa0AqBKL1DFHH7xTP2bdMocVW39 nE2Sac+HkM91Wn5LNcr72vv+YRWVXxfw2LFhViHlZbCXR3LeixUU/jgvJeNsfqkUVmEm 3/aQ== 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:openpgp:from:references:cc:to:subject; bh=beb9HIPPbmhFYNfmtVdjyRkfC7WTvuQw9rrgx9e5c6M=; b=hN8Sq5n/9ulU2yG6YtTrVLwf5/6kTsICPAwFrmq8vyhGcl5RNrdcbxerRL0KBF9zr5 u70fgOxFiI8pN55uj/HpGPgkqsNVAyIpkmaWYT5/l6Fw4G/ouBCW51R98cb4Gzy5j0Ws yZp/91L1Q4EoV1bpZR9Et1h0XX1ItK8fq7Uj6UggG65FFnKRFpau9553gYAM1jB7risf HtyX1QNAkIUgPmmY6fC6acbIJfvmUAjn+M1NSYLjgY4g2p0gPsKZGI/q/dHOYazKdXtV KbxnHj3kgNzy2BNFGdhkmcOY1gY+mmupNKF/draOwmWrkLJsBt7/U/tgrSnaKpZCH1He 5pzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4si625535ejd.328.2019.10.09.00.18.02; Wed, 09 Oct 2019 00:18:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728567AbfJIHPI (ORCPT + 99 others); Wed, 9 Oct 2019 03:15:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58446 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbfJIHPI (ORCPT ); Wed, 9 Oct 2019 03:15:08 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 36F632A09AA for ; Wed, 9 Oct 2019 07:15:08 +0000 (UTC) Received: by mail-wr1-f72.google.com with SMTP id n18so668185wro.11 for ; Wed, 09 Oct 2019 00:15:08 -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:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=beb9HIPPbmhFYNfmtVdjyRkfC7WTvuQw9rrgx9e5c6M=; b=uAvIleTZN6NqrH3rE4tqhvJ//quiXSqlBi3Gb8ziTYcHmMRldn3TXB0PhVzlRIwfEH NMWQL2An07Tf/x3R61T4JH+FqhyosvE9t2xyLfJOHgDr7GeZW5A/fE3Qtp+adXMdwKA+ 83x/lmDUKsEsf/1Vnoei1SVvYMnYIpbJa6A6yo8RJyvYsNFFyhQWV4kJYwZLAuKUaVG4 iB0ezdKP8ZJwUAiFG3JwYCQdCJp/JT5iY49wtcLtG6rei84jQ4By34Jv/ZPij3qUiA7a zYT+du5Y9a1jtUld7vYvFMd07GZmIn8QxKWFGCn2ikdDLRyJJqobQI8olYzzHBeHCmDC 2TaQ== X-Gm-Message-State: APjAAAXhGeBpH+XdsqB0R13QZGVABoUobl6XcNCSa6JBkFNNmJ7EFgZd M6qFr54kf+IYiAjb+stmllKfnfZaCCy3DjUgoYfcvsQbFiBdb4dmVGAGC9aeJGuonwS7Lh8oIhj ss83d4cw2nbe8IW/jPzr4Kedh X-Received: by 2002:a5d:6b52:: with SMTP id x18mr1575143wrw.66.1570605306444; Wed, 09 Oct 2019 00:15:06 -0700 (PDT) X-Received: by 2002:a5d:6b52:: with SMTP id x18mr1575084wrw.66.1570605305611; Wed, 09 Oct 2019 00:15:05 -0700 (PDT) Received: from [192.168.10.150] ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id h14sm1686671wro.44.2019.10.09.00.15.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Oct 2019 00:15:05 -0700 (PDT) Subject: Re: [PATCH 3/3] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC To: Like Xu , Peter Zijlstra Cc: kvm@vger.kernel.org, rkrcmar@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, Jim Mattson , Ingo Molnar , Arnaldo Carvalho de Melo , ak@linux.intel.com, wei.w.wang@intel.com, kan.liang@intel.com, like.xu@intel.com, ehankland@google.com, arbel.moshe@oracle.com, linux-kernel@vger.kernel.org References: <20190930072257.43352-1-like.xu@linux.intel.com> <20190930072257.43352-4-like.xu@linux.intel.com> <20191001082321.GL4519@hirez.programming.kicks-ass.net> <20191008121140.GN2294@hirez.programming.kicks-ass.net> From: Paolo Bonzini Openpgp: preference=signencrypt Message-ID: Date: Wed, 9 Oct 2019 09:15:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/10/19 05:14, Like Xu wrote: >> >> >>> I'm not sure is this your personal preference or is there a technical >>> reason such as this usage is not incompatible with union syntax? >> >> Apparently it 'works', so there is no hard technical reason, but >> consider that _Bool is specified as an integer type large enough to >> store the values 0 and 1, then consider it as a base type for a >> bitfield. That's just disguisting. > > It's reasonable. Thanks. /me chimes in since this is KVM code after all... For stuff like hardware registers, bitfields are probably a bad idea anyway, so let's only consider the case of space optimization. bool:2 would definitely cause an eyebrow raise, but I don't see why bool:1 bitfields are a problem. An integer type large enough to store the values 0 and 1 can be of any size bigger than one bit. bool bitfields preserve the magic behavior where something like this: foo->x = y; (x is a bool bitfield) would be compiled as foo->x = (y != 0); which can be a plus or a minus depending on the point of view. :) Either way, bool bitfields are useful if you are using bitfields for space optimization, especially if you have existing code using bool and it might rely on the idiom above. However, in this patch bitfields are unnecessary and they result in worse code from the compiler. There is plenty of padding in struct kvm_pmu, with or without bitfields, so I'd go with "u8 event_count; bool enable_cleanup;" (or better "need_cleanup"). Thanks, Paolo