Received: by 10.223.176.5 with SMTP id f5csp827429wra; Fri, 9 Feb 2018 07:52:19 -0800 (PST) X-Google-Smtp-Source: AH8x226MafIaN3+PyXvk0jCYjwY0gIWFb1uY49mhTZpofgiCuF9lQQHQUUrp6aiJ/NbiD6+1RMvP X-Received: by 2002:a17:902:8:: with SMTP id 8-v6mr2933703pla.415.1518191539142; Fri, 09 Feb 2018 07:52:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518191539; cv=none; d=google.com; s=arc-20160816; b=AO2zcpcSO3jEpvJWNJFoPlZZolJgoPHzqktMl5rPR0YyGc1Z1oJ5sZFiNKVOGOVHZp MKQDfWc7dUKINnDs4Jf3R/3KCJzHWsg0GYCVCK4AW7JSwLYZj6QWLq3ilDyc67Cf2kQJ zB4BLdo6oT/avB9jCciSroVgu8MVk7cx8MJruejiM+1d9pUlwwDIufoq6kv0F2v1bg9J 70oGsR7/vz5V0GADI7ejCpCubiDxSLKnoXVsiQswdWK3gsdq3TrFg5kw8ObuC84CsAdH uLYs+P7WL+AH4zVhCqUt6XfZ9HU4LGMF8Cqr0w37niRMrCVz1I2zGbcX7oCBl4zVh3Qm pUUg== 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:from:references:cc:to:subject:arc-authentication-results; bh=qNOikVnANBu6Q4jNo/4MBtcYvRxu1xMq2FUSnq8w5Mo=; b=MibLLeBbcmqiU4vq/ntRAfwPJvWs+Sysp6yrgYhqaBBxsg5jfjl/VSwF+r9IvP/Zcw vYYjjZsxx8uWrxA6kZE1TlT8zrYRpYVeSuVYAYfmod9sQ/IJTbQbVuQSPD1FZr+NZ/mM 5+mccxD3u+Tf6gGa1svQS1FoscOeY81eSloHEk8EMyZQ8/hOr/YF8y+Ij2gxqQmP3g3j tKKOsQZ2xOp+7zyfzkttG+9imefWmZ0t/N1R/PYdUhXiajl2Bt7KKmZp0lYuYnDrsKTs Y9DeLZSyzF8Rnc3R7WTvr3H56tQauSRhffpRYFTTb8Oazh9+iFH0HYxKR0NLHS/uL3ed P51A== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g34-v6si990924pld.513.2018.02.09.07.52.05; Fri, 09 Feb 2018 07:52:19 -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; 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 S1752381AbeBIPtj (ORCPT + 99 others); Fri, 9 Feb 2018 10:49:39 -0500 Received: from mga14.intel.com ([192.55.52.115]:8548 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752335AbeBIPth (ORCPT ); Fri, 9 Feb 2018 10:49:37 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Feb 2018 07:49:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,483,1511856000"; d="scan'208";a="17259741" Received: from linux.intel.com ([10.54.29.200]) by orsmga006.jf.intel.com with ESMTP; 09 Feb 2018 07:49:36 -0800 Received: from [10.254.76.39] (kliang2-mobl1.ccr.corp.intel.com [10.254.76.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 302145802D1; Fri, 9 Feb 2018 07:49:36 -0800 (PST) Subject: Re: [PATCH V3 1/5] perf/x86/intel: fix event update for auto-reload To: Peter Zijlstra 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 References: <1517243373-355481-1-git-send-email-kan.liang@linux.intel.com> <1517243373-355481-2-git-send-email-kan.liang@linux.intel.com> <20180206150648.GK2249@hirez.programming.kicks-ass.net> <20180209140905.GG25181@hirez.programming.kicks-ass.net> From: "Liang, Kan" Message-ID: Date: Fri, 9 Feb 2018 10:49:35 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180209140905.GG25181@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 2/9/2018 9:09 AM, Peter Zijlstra wrote: > On Tue, Feb 06, 2018 at 12:58:23PM -0500, Liang, Kan wrote: >> >> >>> With the exception of handling 'empty' buffers, I ended up with the >>> below. Please try again. >>> >> >> There are two small errors. After fixing them, the patch works well. > > Well, it still doesn't do A, two read()s without PEBS record in between. > So that needs fixing. What 3/5 does, call x86_perf_event_update() after > drain_pebs() is actively wrong after this patch. > As my understanding, for case A, drain_pebs() will return immediately. It cannot reach the patch. Because there is no PEBS record ready. So the ds->pebs_index should be the same as ds->pebs_buffer_base. 3/5 is to handle case A. Thanks, Kan >>> + >>> + /* >>> + * Careful, not all hw sign-extends above the physical width >>> + * of the counter. >>> + */ >>> + delta = (new_raw_count << shift) - (prev_raw_count << shift); >>> + delta >>= shift; >> >> new_raw_count could be smaller than prev_raw_count. >> The sign bit will be set. The delta>> could be wrong. >> >> I think we can add a period here to prevent it. >> + delta = (period << shift) + (new_raw_count << shift) - >> + (prev_raw_count << shift); >> + delta >>= shift; >> ...... >> + local64_add(delta + period * (count - 1), &event->count); >> > > Right it does, but that wrecks case A again, because then we get here > with !@count. > > Maybe something like: > > > s64 new, old; > > new = ((s64)(new_raw_count << shift) >> shift); > old = ((s64)(old_raw_count << shift) >> shift); > > local64_add(new - old + count * period, &event->count); > > > And then make intel_pmu_drain_pebs_*(), call this function even when !n. >