Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5574399ybp; Tue, 8 Oct 2019 05:12:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwc+r5sa01OOBei/8CoLx44157fVgDc22CIjkV5SYnKGHyMCuLySHYJmr6l95eyrruQy2fD X-Received: by 2002:aa7:cd5a:: with SMTP id v26mr32980658edw.256.1570536777443; Tue, 08 Oct 2019 05:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570536777; cv=none; d=google.com; s=arc-20160816; b=iYOzbUGlwUNx7LgXIO0YY92ipZ74HIueCCZ2QDtF+ubRtdM/b2GdWVze9ZWTKOuBrT kuoH3f68STJM7WIDSTxgDnucdT7rWxWRj2+Wxh4X6ncbQBPp+EuDGB+jj9JSNL4PDcYu CAvzuBBjIzmTb4nm3wrA5QgJIRIeVHmdw1Tco+cmgnAWVKj5uadZ0hT5ZPZMFco0HMQb PuurTgsOJUU/8hVJBvMcaiktkdTv+2mkZOz+z5ZXZWF9iNLzDjQPqXwZKSSrmintIDXk NKf4XBVmlgqbu5oCl3smokEP+te93BjQIpjgM8qZ1I1kLicynHqYT4/Ea4whkLCOIEIC 5P1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=el0DYGZ+UtD3Q7bf+tloYS3IVTjk0rUS+bONbgMT2Rg=; b=clQTWI+ftXpD66nII8vIhp99+9Dc22zRtabmjztafJ8cNOh4opR3LyiiAgCfk4oBaT F6Ilr8LxAEeyF5TxfN5HYD9c91kY0AeMoDGVYPDDrBEFEXPdBGhGpL+WqJpzNzD8miyj N6Bj21u1QzFrbjPgH5QCPao6p0hO5OALTUXR1czQHV6OE3eOyj0ZNBBTcOLqS9oMCjTD NlEnVTg8chymCjnmkaRrRRhNngaDICDQhgwdNAborSEsoI2VsU21zpf+C3MAoDrt0+1Z XughyxdARyMlOo+tAdAIudVu58F/3C9JmIb8mFQwfcQds8dCN5Zrjf/+izleL5g8nHj7 pV1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=O74tYwgU; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l2si8640883ejh.389.2019.10.08.05.12.33; Tue, 08 Oct 2019 05:12:57 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=O74tYwgU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731261AbfJHMLx (ORCPT + 99 others); Tue, 8 Oct 2019 08:11:53 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35068 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731226AbfJHMLw (ORCPT ); Tue, 8 Oct 2019 08:11:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=el0DYGZ+UtD3Q7bf+tloYS3IVTjk0rUS+bONbgMT2Rg=; b=O74tYwgUjbjFkwHNi6ZU+HaR6 LBkK8REqe9k40pVT68Vf1bZ875QNzej49ZWHpedsMDiJGCyVXElI/WYMpzBequQwZQVxzCvGsqycR 1Eo3sHvlUSL/B1zyyKLRGDs0KZFQ00BLfbPtTEoQPZFPo2j2OY6DHN/ia/ea4oX4QPXsw5Q2sqE66 FA2i/hjj6056Mr6HBGA/HW7QvtuWNTBvA8Y9v3TTDYwe8ImhMa7IiT3bARuiUKS7RHE9oYafG+HMr q3yB4iMkdE0a6FKcVTvl/5KaggJ8OxdgMRG+Y23uk7kjteTIGJ11T0ySqwJJEPPEdHpYy4PDVnJqr 0kSH4reeg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.2 #3 (Red Hat Linux)) id 1iHoL9-0007Qk-R3; Tue, 08 Oct 2019 12:11:44 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id A8440306C53; Tue, 8 Oct 2019 14:10:49 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0714D202A1952; Tue, 8 Oct 2019 14:11:41 +0200 (CEST) Date: Tue, 8 Oct 2019 14:11:40 +0200 From: Peter Zijlstra To: Like Xu 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 Subject: Re: [PATCH 3/3] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC Message-ID: <20191008121140.GN2294@hirez.programming.kicks-ass.net> References: <20190930072257.43352-1-like.xu@linux.intel.com> <20190930072257.43352-4-like.xu@linux.intel.com> <20191001082321.GL4519@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. Also, the structure has plenty holes to stick proper variables in without further growing 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.