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=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 B2D20C4360C for ; Wed, 9 Oct 2019 03:15:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8D00D20B7C for ; Wed, 9 Oct 2019 03:15:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730305AbfJIDPT (ORCPT ); Tue, 8 Oct 2019 23:15:19 -0400 Received: from mga03.intel.com ([134.134.136.65]:42057 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726490AbfJIDPT (ORCPT ); Tue, 8 Oct 2019 23:15:19 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Oct 2019 20:15:18 -0700 X-IronPort-AV: E=Sophos;i="5.67,273,1566889200"; d="scan'208";a="197891410" Received: from likexu-mobl1.ccr.corp.intel.com (HELO [10.239.196.204]) ([10.239.196.204]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/AES256-SHA; 08 Oct 2019 20:15:15 -0700 Subject: Re: [PATCH 3/3] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC To: Peter Zijlstra Cc: Paolo Bonzini , 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: Like Xu Organization: Intel OTC Message-ID: Date: Wed, 9 Oct 2019 11:14:56 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191008121140.GN2294@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8; format=flowed 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 2019/10/8 20:11, Peter Zijlstra wrote: > On Tue, Oct 01, 2019 at 08:33:45PM +0800, Like Xu wrote: >> Hi Peter, >> >> On 2019/10/1 16:23, Peter Zijlstra wrote: >>> On Mon, Sep 30, 2019 at 03:22:57PM +0800, Like Xu wrote: >>>> + union { >>>> + u8 event_count :7; /* the total number of created perf_events */ >>>> + bool enable_cleanup :1; >>> >>> That's atrocious, don't ever create a bitfield with base _Bool. >> >> I saw this kind of usages in the tree such as "struct >> arm_smmu_master/tipc_mon_state/regmap_irq_chip". > > Because other people do tasteless things doesn't make it right. > >> 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. > > Now, I suppose it 'works', but there is no actual benefit over just > using a single bit of any other base type. > >> My design point is to save a little bit space without introducing >> two variables such as "int event_count & bool enable_cleanup". > > Your design is questionable, the structure is _huge_, and your union has > event_count:0 and enable_cleanup:0 as the same bit, which I don't think > was intentional. > > Did you perhaps want to write: > > struct { > u8 event_count : 7; > u8 event_cleanup : 1; > }; > > which has a total size of 1 byte and uses the low 7 bits as count and the > msb as cleanup. Yes, my union here is wrong and let me fix it in the next version. > > Also, the structure has plenty holes to stick proper variables in > without further growing it. Yes, we could benefit from it. > >> By the way, is the lazy release mechanism looks reasonable to you? > > I've no idea how it works.. I don't know much about virt. >