Received: by 10.223.185.116 with SMTP id b49csp530600wrg; Wed, 21 Feb 2018 02:35:07 -0800 (PST) X-Google-Smtp-Source: AH8x225XTmI5n7aubka+DclU2G5hGKmCkt5UT+ZuPDnsUvyW2vECNHI85vt5/GM10sjohbPQ4eCa X-Received: by 10.101.97.139 with SMTP id c11mr2306420pgv.449.1519209307535; Wed, 21 Feb 2018 02:35:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519209307; cv=none; d=google.com; s=arc-20160816; b=xr0lM0mFME8ZMtuyEzxZPYvLnhRD+9MNpw0T5d2zDe4xH6avKuYsFLhjsAfD+QABfg ouDB5+2D2So9QUQChzFALXDXwIDsL97I5SEv8O75hGZVb1Ng+Bb+NvhFEskLM9OrYijw Kwby/H1UfnGyjfhX7s+3JVn/80Cs0yYCWlC1f5q4l85WT0H9SLMvHzolzzfXOsmq18gF o2zG6u6snclZmkekRRsUPBi7ZfAnMoi5vISZ3PyKvLwLWx98hNwBPZszK99T/dTphm4g ZPg1ux9Xwq2ICP6+VW+imSt83E+I0RjtNvusNblxL+mRIXjmow32sbgOBfDAHjhIpdki gwJg== 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:arc-authentication-results; bh=vfHnnLopMgnGAXeZHUf98mhCSzEO/wwDJ38kWXKq8sw=; b=ekAwFa8imF0WqUpKD/ZkS3rwx5S/Bk1mB7RT1l0ULXHUE6z0b7qchLbS137sTOCoFq NrLJvagnx0dCdQTg4RKGMYg7Aszp58fSW4WPm8aHhmsQS8zfbghj44J9anrN4irRqmYt YmW59qxnXyfDECLSe/J09/7KsAH5482PZbNw5qukJrBYMRZ9iL8LZd15/3fhGqFCboN+ klHhF3v352/2m29rZVZAPyd6UZSnNBdbgKp0uA/3qmlS/Yq0WRcSEMSDhaB8vssfgVEl 7cabLfagMBt5coceqnoKIXbXhpACxWWwX/2mVvd3VdX/ZEozci4LIWRUMsq/tIvnyKr8 mqhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=PJsdTTh5; 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 c3-v6si929999plo.708.2018.02.21.02.34.53; Wed, 21 Feb 2018 02:35:07 -0800 (PST) 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=PJsdTTh5; 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 S933257AbeBUKc4 (ORCPT + 99 others); Wed, 21 Feb 2018 05:32:56 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:51802 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932751AbeBUKcx (ORCPT ); Wed, 21 Feb 2018 05:32:53 -0500 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=vfHnnLopMgnGAXeZHUf98mhCSzEO/wwDJ38kWXKq8sw=; b=PJsdTTh5l1vrqhtHcRg+ra4g8 ensjGs8ZoM5NBYfV1zVM9GF0CXownBPEbuU2LtliDlN6FOpI35rXFxuwcsYzB6QP0GyVPB1rBXPvN +od9jEu5IK+jFWXd3Y0XXYNilqrN2cV2YoWaOvYkK3ze6IItR9x9SwA5Ea0p8DwtLvzpsGhB5pTZU Ss7AQR+v0evvLMzWmGU/RbL+ro8DKmP5OV9vbCXXef6qFtrio7wgrdgUFf5EvJ0kNLS5pqEyHRdvM IsNF1GXdjX0LeHP90oPBQG7c4wJXxOtVPH7blfs4+V57Sl5N4tD/FzeRpOxoI56nyn9hBHI+1I1xX UnTvICtdg==; 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.89 #1 (Red Hat Linux)) id 1eoRhi-0006E7-AC; Wed, 21 Feb 2018 10:32:50 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id C8C30201FB4F5; Wed, 21 Feb 2018 11:32:47 +0100 (CET) Date: Wed, 21 Feb 2018 11:32:47 +0100 From: Peter Zijlstra To: kan.liang@linux.intel.com Cc: mingo@redhat.com, linux-kernel@vger.kernel.org, acme@kernel.org, tglx@linutronix.de, jolsa@redhat.com, eranian@google.com, ak@linux.intel.com Subject: Re: [PATCH V4 1/5] perf/x86/intel: Fix event update for auto-reload Message-ID: <20180221103247.GL25181@hirez.programming.kicks-ass.net> References: <1518474035-21006-1-git-send-email-kan.liang@linux.intel.com> <1518474035-21006-2-git-send-email-kan.liang@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1518474035-21006-2-git-send-email-kan.liang@linux.intel.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 12, 2018 at 02:20:31PM -0800, kan.liang@linux.intel.com wrote: > @@ -1389,8 +1456,22 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs) > > ds->pebs_index = ds->pebs_buffer_base; > > - if (unlikely(base >= top)) > + if (unlikely(base >= top)) { > + /* > + * The drain_pebs() could be called twice in a short period > + * for auto-reload event in pmu::read(). There are no > + * overflows have happened in between. > + * It needs to call intel_pmu_save_and_restart_reload() to > + * update the event->count for this case. > + */ > + for_each_set_bit(bit, (unsigned long *)&cpuc->pebs_enabled, > + x86_pmu.max_pebs_events) { > + event = cpuc->events[bit]; > + if (event->hw.flags & PERF_X86_EVENT_AUTO_RELOAD) > + intel_pmu_save_and_restart_reload(event, 0); > + } > return; > + } > > for (at = base; at < top; at += x86_pmu.pebs_record_size) { > struct pebs_record_nhm *p = at; Is there a reason you didn't do intel_pmu_drain_pebs_core() ? --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -1435,8 +1435,11 @@ static void intel_pmu_drain_pebs_core(st return; n = top - at; - if (n <= 0) + if (n <= 0) { + if (event->hw.flags & PERF_X86_EVENT_AUTO_RELOAD) + intel_pmu_save_and_restart_reload(event, 0); return; + } __intel_pmu_pebs_event(event, iregs, at, top, 0, n); }