Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2059457imm; Thu, 20 Sep 2018 07:12:10 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYRcZsMQlEnIumqsNDrUKx3P2pQpf6Q3g5pDTTYbcl6nX9xfdT/Qj8ii7UQDjADeHkPkSws X-Received: by 2002:a63:cf0e:: with SMTP id j14-v6mr4466342pgg.195.1537452730573; Thu, 20 Sep 2018 07:12:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537452730; cv=none; d=google.com; s=arc-20160816; b=ElLzxaD9CqF8Ff+YfdA2CV+mv8639KLndGs4RrYeZzp7w3RTre046bBCKefqv8j75O dPYsCSjrr/n5cUw9tJIVxbdAeTgOwH67cLDawuW0cBvkQdNsJIXw/bS++FffzJEam0s0 YE4vknKv0zvAmGSSRamFcmZCOM+O5KHJzkJWIRTec0eqZ2lBtWf+K4WSZgz2q6WqnjfK 49vgVlFfnHIRkNDyTc2I2hr2NSljOHhelHkACAUIaF48HNDIeJ3wxGgYdv2UQNGhavut TxBfqGCKurxdddf9rWg+1z2pvwDpHq++IEH/g9ZHw24f1dDY+I9fPfYvsHJE8j38itH1 v0MQ== 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=yiZcEUS8m98q9XGHruVnJ+8dBj+1EQDt6SRzTVYFJ88=; b=pIfGTwGwTAs23QvBFbz1oTPJkqC8h0uJOeR1p15y1MObjaRS2tvA/lwCpvzF9J7RcW pJYhmrkwbCMqXZ+o2x/ACVD6fMvfI31vrDYfFxItbW2WMKdBDw23RFMLudbIhSRqVvr9 hnk4F0cK0dz8MIeJ+b1WT2Q1efuM1W6KH9lBQQm6f/mLROwOUdkBI1BSLg3CurlIKwLB vf0A3km6Dftj6BNOmFv5i/NiTeSAqFvnHucrO7cHSYFU268KZ3Py2ba4v0DbGglxHc5y BOVy42sBRBc3KEs55JcQ4ftQr1H+B1m/6/ih38B+zc0Tb32Y0oGBlb/kuE7dBcQ54F7M Swmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=QbCIj7CL; 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 q5-v6si21730858pgv.692.2018.09.20.07.11.51; Thu, 20 Sep 2018 07:12:10 -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=QbCIj7CL; 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 S1732640AbeITTzC (ORCPT + 99 others); Thu, 20 Sep 2018 15:55:02 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:45180 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726990AbeITTzC (ORCPT ); Thu, 20 Sep 2018 15:55:02 -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=yiZcEUS8m98q9XGHruVnJ+8dBj+1EQDt6SRzTVYFJ88=; b=QbCIj7CLkDtu56j2sdo3bKpJn xNn8EiMYsTDiOJYbJ13s0o55BazqtXLDphdiXhtML92OM08RGaYIUu1cUyPZRVVdwq9VEnkQ6mJiQ wdQzXLnUMp+4y6t73ymL2OZvjRFkl/uqKnSLjecxoBssU1pxbxPetwTAmbWnHAXHKZ16dhmotc1Ti eE8DWr7ZFXepgWMRcGwC5ftydS7g2SDb1yOXRwKtXRQdCqZvhO5TBBpvMTiNEqlOOb+Xtp/NxfkpK 6qGfJi6TgwgtNovZniNxhsKchni+6pv420lmgx1DO2FZ4tP3bTLryH011ZaBk3m1hn3lYzlWSKhQy y0glIgEBA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2zfr-0001sA-8S; Thu, 20 Sep 2018 14:11:19 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A5E1C2024E448; Thu, 20 Sep 2018 16:11:15 +0200 (CEST) Date: Thu, 20 Sep 2018 16:11:15 +0200 From: Peter Zijlstra To: Reinette Chatre Cc: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com, mingo@redhat.com, acme@kernel.org, gavin.hindman@intel.com, jithu.joseph@intel.com, dave.hansen@intel.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V5 5/6] x86/intel_rdt: Use perf infrastructure for measurements Message-ID: <20180920141115.GX24124@hirez.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 19, 2018 at 10:29:10AM -0700, Reinette Chatre wrote: > +static int measure_l3_residency(void *_plr) > +{ > + counts.miss_after -= counts.miss_before; > + if (boot_cpu_data.x86_model == INTEL_FAM6_BROADWELL_X) { > + /* > + * On BDW references and misses are counted, need to adjust. > + * Sometimes the "hits" counter is a bit more than the > + * references, for example, x references but x + 1 hits. > + * To not report invalid hit values in this case we treat > + * that as misses equal to references. > + */ > + /* First compute the number of cache references measured */ > + counts.hits_after -= counts.hits_before; > + /* Next convert references to cache hits */ > + counts.hits_after -= counts.miss_after > counts.hits_after ? > + counts.hits_after : counts.miss_after; Maybe: counts.hits_after -= min(counts.hits_after, counts.miss_after);