Received: by 10.223.164.202 with SMTP id h10csp3833797wrb; Mon, 20 Nov 2017 05:51:30 -0800 (PST) X-Google-Smtp-Source: AGs4zMYVQWaKyZSPNXyoFWD7h8w3VtqnCEufEo2ol865tGP8ULgit5Yt6VrU6+1x2I+vHnKh9DPn X-Received: by 10.159.244.12 with SMTP id x12mr14314153plr.312.1511185890826; Mon, 20 Nov 2017 05:51:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511185890; cv=none; d=google.com; s=arc-20160816; b=b77apRG4tAdWrnN/F1lnhfkBPG8SgRZL9KLTNuNkE8tBlmE0Ewxvp3UchNBi8glJDq n1hTZgmmvoRep/26DzmqZeQn5RHeT6EqnfaC3Vq5jJs2Owoh+mYu4Q4mOn7pNE6qwSpp K0YFPhdMR9nlADk9xn1Noz/VnbgmkSCCGllHwDSzn+qn20DQU4jAL+nj9YNtP1UVSzt/ hD34TQrirfARgYLB/ZqZDE+Vhp7llCkaTK7X9um/YAjGz8mxeMepFyc1/RNgHQ1oS5b6 qoLw6e0/J9/t0EwhtjTwKq6PkZUd08Quju7oBH+pHJjrnie1qUjtKDN466/kQnnvzXqQ 3t2g== 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:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject:dkim-signature:arc-authentication-results; bh=sFvfygHpPhj2PBKgKM0Tqi7+Yv85vXFnQHrZ3ldr4Z0=; b=Gx34YI6FDfviT9ImLYJ569st10mgdRaHbTFCHYa8699ljr5FtaqpDolaM4KOXmh4uI K5qxJDqLhbA49l71bI2CoD4XZk4vpIleekRIhPXIL10WOZxXZOqyp5l5zTopv0YsWXUX YUje9cIauH+9QAwYu+tOlh5st6exISlIKNuQCAQMH42kNZdCsBpafsLR09Vwmvw8Dfvc qoepM369REyCs6UWURwqFf6DlpqEWsF/4TAs3PtF9p7MwPUGy7tZxatN8iN6nRJAxoyZ ZCi/p8ARljuvgMdBUE7ia9JPnwKRpMcVq2Squu7qRHUfboMLod8QqcC+g2PWcdHPXw4Y 3azQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NissRbaj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s1si8408048plj.341.2017.11.20.05.51.20; Mon, 20 Nov 2017 05:51:30 -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=pass header.i=@gmail.com header.s=20161025 header.b=NissRbaj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751214AbdKTNu0 (ORCPT + 66 others); Mon, 20 Nov 2017 08:50:26 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:35044 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751086AbdKTNuZ (ORCPT ); Mon, 20 Nov 2017 08:50:25 -0500 Received: by mail-pg0-f65.google.com with SMTP id l19so7432404pgo.2 for ; Mon, 20 Nov 2017 05:50:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=sFvfygHpPhj2PBKgKM0Tqi7+Yv85vXFnQHrZ3ldr4Z0=; b=NissRbajhA+yRD4QobgDPOjK9Sy296a8AuTVXVMh0tbjp1FqrbLwLx2cxVN0hbEGDH PIvYJG+1BwQsVpRRGYFygkwUBloX+TGslIs4JFi18CPNvkNXmWgNxny2fL9dWfw8uTK2 x+949UKpiAehVVMlFoEnSj7z1gkn1zNDFo1/WTGz9qZ1b/NeG7a6kk86/PHUF2aNdrMg vnqWUPDjB0j8WDDY75MW2DQng+BQIEmw4qLYPt7V8fz73jxANtsJXrsknZCJoY9/06hs NIdNNRowo/j14SC1USkpgs8I2pBEo45on2NNW43KLBDuIbGxXvmIpDNdsvZlcGjvp9nr wquA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=sFvfygHpPhj2PBKgKM0Tqi7+Yv85vXFnQHrZ3ldr4Z0=; b=SfF9KSNo/2OesXaq6MN6j/SSntm6XCDlDuetUbOiTdu7t0iXgXCe8KC/jKa8SfJfua wfsGCFE6nv4+CdnLZoYZoLeenU4mmC0KXjIpBdG07nwm341a9vKxrtL0jNG4CCkpf2fz h0Uj+yNanYPAnytmxL4tqdTCi7stQoiKEzakwbxyQCTEDYYAV0n6hPYJBuF1dvnhUKvm bgviC1z5nzIIgvwFoFfffjTRSnkG3J35qmtwiQoQR7l88aloL81N40lNSYJV6h5QCE+I DAdjt7QTrkalISNiFTXSFXk/gHBqYy/9P+uiESGrd5h4oqM1W70b4oJl+tpXJrgCgrF0 5W3Q== X-Gm-Message-State: AJaThX720CSLTqKqCPPdv5qQYDlYVjFcidjv82LRrYZuUvaVaeonhLvN fXpHON8+RRE70qqAnv3sV5c= X-Received: by 10.99.109.75 with SMTP id i72mr13753642pgc.43.1511185824650; Mon, 20 Nov 2017 05:50:24 -0800 (PST) Received: from [0.0.0.0] (67.209.179.165.16clouds.com. [67.209.179.165]) by smtp.gmail.com with ESMTPSA id g2sm11201764pfc.130.2017.11.20.05.50.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2017 05:50:23 -0800 (PST) Subject: Re: [PATCH] drivers/perf: arm_pmu: save/restore cpu cycle counter in cpu_pm_pmu_notify To: Mark Rutland Cc: Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Lorenzo Pieralisi , Jia He References: <1510813648-45090-1-git-send-email-hejianet@gmail.com> <20171120123240.ohcdgv2nnoyrc7ov@lakrids.cambridge.arm.com> From: Jia He Message-ID: Date: Mon, 20 Nov 2017 21:50:15 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171120123240.ohcdgv2nnoyrc7ov@lakrids.cambridge.arm.com> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mark Thanks for your review. On 11/20/2017 8:32 PM, Mark Rutland Wrote: > Hi, > > On Thu, Nov 16, 2017 at 06:27:28AM +0000, Jia He wrote: >> Sometimes userspace need a high resolution cycle counter by reading >> pmccntr_el0. >> >> In commit da4e4f18afe0 ("drivers/perf: arm_pmu: implement CPU_PM >> notifier"), it resets all the counters even when the pmcr_el0.E and >> pmcntenset_el0.C are both 1 . That is incorrect. > I appreciate that you may wish to make use of the cycle counter from > userspace, but this is the intended behaviour kernel-side. Direct > userspace counter acceess is not supported. Sorry for my previous description. Not only user space, but also any pmccntr_el0 reading in kernel space is 0 except perf infrastructure. > > In power states where context is lost, any perf events are > saved/restored by cpu_pm_pmu_setup(). So we certainly shouldn't be > modifying the counter registers in any other PM code. > > We *could* expose counters to userspace on homogeneous systems, so long > as users stuck to the usual perf data page interface. However, this > comes with a number of subtle problems, and no-one's done the work to > enable this. > > Even then, perf may modify counters at any point in time, and > monotonicity (and/or presence) of counters is not guaranteed. Yes, the cycle counter register pmccntr_el0 will be impacted by perf usage.But do you think pmccntr_el0 is intented for perf only? Currently, many user space/kernel space programs will use pmccntr_el0 as a timestamp( just likethe rdtsc() on X86). After commit da4e4f18afe0, all the cycle counter readingis 0 because of CPU PM enter/exit state changes in armv8pmu_reset. -- Cheers, Jia From 1584588429692122820@xxx Mon Nov 20 12:34:47 +0000 2017 X-GM-THRID: 1584209216349987268 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread