Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp383272ybp; Tue, 8 Oct 2019 20:15:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqza7/DSZ/Vu+JKolsGsqFgmKESz1rNQPXsaF4xN9CLwTkcLSftEsZgujUcXmUDBFo9lXRjK X-Received: by 2002:a17:906:2cd2:: with SMTP id r18mr820674ejr.282.1570590953640; Tue, 08 Oct 2019 20:15:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570590953; cv=none; d=google.com; s=arc-20160816; b=oIKaddYQQblaDKxVrOzVqSsTB+fLc1jJh6dts53xYSYQX9ycvuOynQiblMpzNOt5uk M6uqPD49GnLIquvnz7keoZcNHHV+ivZw8u0u6ViyoaVt7Zqqya+Qu7fPD2YLYBYh0018 CIc99Qjs5AHL0zOJgh4Cbj9LP161/xyYe99BFEomOP6BKJA8Q+jPO0Ff9S98VpZ66FFb lR2ibJ0+boCMq1AY8ksI2Zvsn/tjyt6HwYhBK1ckDn62sGQwy73ByNOXoh6TKgwHYu3e mIEpXJJYq+aLw/8IGYX4UMHFhpMq/X4AeWf66Bgh2lNo7G9k7YjbTSadrhcOXiy6jP9f SgRg== 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:organization:from:references:cc:to:subject; bh=ed/GdcXqfsOKKsuNrSybivrPvaYaSJZ4Kzv+CzckNGQ=; b=MCUy8RDj4A49NEMx6j6KAlvRz1nrWsX8FMly0lmER4TEwDFjiQMrY/PD8i04iPQ87l +IVS9ErGY/k3WdSzbnTCzfmWKSGibNXVrVostTKhuFBLy2IlIj4nAMahBVjSl6a6tJnH /nkP1rZNIZPzU2EloJM6Y+POO02jwvg4MulQFR19g2pgaT/uH51032L3HVWX6Zda5wSL 60IXuUuCnJFyFqk0ffCJlizUIP2NXJHAMaqCL7gXobEWSsLeaspjb+7OanwWUNiq6BfB zd9iM6BPlRvdh06T3JacdcZFn9+cVHb3f/htVza0ZQYwHiPBJZ85OeHi/gPtaYgajHJy OE4A== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z33si586358edz.314.2019.10.08.20.15.29; Tue, 08 Oct 2019 20:15:53 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730274AbfJIDPT (ORCPT + 99 others); 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. >