Received: by 10.223.185.116 with SMTP id b49csp3814122wrg; Tue, 13 Feb 2018 08:09:29 -0800 (PST) X-Google-Smtp-Source: AH8x226SSGhx5NfZZJbCb0cCnLX3WYjTNEJjSUSN5CfpHgnGtQ0KQaEQ4lK7d0Ayyz3GCsfWk7Fa X-Received: by 10.99.117.28 with SMTP id q28mr1370807pgc.187.1518538168971; Tue, 13 Feb 2018 08:09:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518538168; cv=none; d=google.com; s=arc-20160816; b=d/l1gWA0Y3wZCNOllWO+80vImP+wMq4GmYxOgepuutNnIHE9Q64yKhrReswCGUf5/1 0CQy7N/ie7lYHHmoDRYx3RMoz7opkUbkVMVP8GJkmK5ha9h5L8m6HLN/CRCfn9DPjMHK LWnidfpOJ19muIl14qAAKMC/WpfxLpfUda5L/B2F+hAI3ZLc/0SevVCKCEF0852VyOSk MN8n5wVgXZTP/VAzw+T+VuEtcqOBfM1k05HrItF3IJtnJINlT4daEIK+UAUykJX/geFr tpm0kvV/XP2NdwWs4R1mkZIYqs/RiBJOFF4K64q01BcVSyjecUHr7Dp88oQxigHekxyt gjKQ== 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:arc-authentication-results; bh=NzKeos/JP0Uq6xckJszOppgfT7aWA/PlxMGT7vDHizw=; b=mZyf0q0Ih7iCX5KdX+h1zNzZgeKebZFa0AnRFRgJssYcfhTA5oEH4kef9k2HR5A1FN ZD4sxs+yDhhrjFJaMv4LT0wjy9DVIjTlV29iz7rMgr6owaupM1ywH3bQeRIZtvPfxQha t/BkClU2z291Bb2SB4AN74FmfQzMLDu5C2EzTJRd4vE0McO/i+a1Ugpn5qrPKT4tcOJ5 w6snYLCc0ZwwHkLfXdbBwGu+/B71d3B3oT3xj7G71k1AYLasMK3uShUboLpXArDr80Bp telpPZyF+m7q5Cq/js+GDg37KAgWHayEOP1uwr6kGT1djiR/SKfiXcIoVgPr/NGhaXBQ 6ZgA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y10si8294485pff.4.2018.02.13.08.09.14; Tue, 13 Feb 2018 08:09:28 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934491AbeBMQIb (ORCPT + 99 others); Tue, 13 Feb 2018 11:08:31 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51056 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933764AbeBMQIa (ORCPT ); Tue, 13 Feb 2018 11:08:30 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB90D8163C52; Tue, 13 Feb 2018 16:08:29 +0000 (UTC) Received: from krava (unknown [10.43.17.235]) by smtp.corp.redhat.com (Postfix) with SMTP id 7160CB07BA; Tue, 13 Feb 2018 16:08:27 +0000 (UTC) Date: Tue, 13 Feb 2018 17:08:26 +0100 From: Jiri Olsa To: Raghavendra Rao Ananta Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, psodagud@codeaurora.org, tsoni@codeaurora.org Subject: Re: [PATCH] perf: Add support for creating offline events Message-ID: <20180213160826.GA9121@krava> References: <1518217620-28458-1-git-send-email-rananta@codeaurora.org> <20180212094357.GD5821@krava> <53408020-8638-4947-90f6-87dbc4c2c4e5@codeaurora.org> <20180212210442.GA32093@krava> <20180212212101.GA15817@krava> <6aab2b36-0fe6-7a3d-2106-d4c93ec95a8a@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6aab2b36-0fe6-7a3d-2106-d4c93ec95a8a@codeaurora.org> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 13 Feb 2018 16:08:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 13 Feb 2018 16:08:29 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jolsa@redhat.com' RCPT:'' 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:22:30PM -0800, Raghavendra Rao Ananta wrote: > > > On 02/12/2018 01:21 PM, Jiri Olsa wrote: > > On Mon, Feb 12, 2018 at 10:04:42PM +0100, Jiri Olsa wrote: > > > On Mon, Feb 12, 2018 at 09:42:05AM -0800, Raghavendra Rao Ananta wrote: > > > > Hi Jiri, > > > > > > > > Thank you for the response. > > > > > > > > Does perf tool has its own check to see if the CPU was offline during the > > > > lifetime of an event? If so, it might ignore these type of events. > > > > > > nope, we don't check on that > > > > > > > > > > > Initially, I tested the same using perf tool and found similar results. > > > > Then I debugged further and found that the perf core was actually sending > > > > data to the userspace (copy_to_user()) and the corresponding count for the > > > > data. Hence, I tested this further by writing my own userspace application, > > > > and I was able to read the count through this, > > > > even when the CPU was made offline and back online. > > > > > > > > Do you think we also have to modify the perf tool accordingly? > > > > > > hum, I wonder what's wrong.. will check > > > > I think the user space needs to enable the event once the > > cpu gets online.. which we dont do and your app does..? > > > > maybe we could add perf_event_attr::enable_on_online ;-) > > > > I'll check what we can do in user space, I guess we can > > monitor the cpu state and enable event accordingly > > > > jirka > > > Yes, probably that's the reason. > > In order for an event to get scheduled-in, it expects the event to be at > least in PERF_EVENT_STATE_INACTIVE state. If you notice, in my patch, > when the cpu wakes up, we are initializing the state of the event > (perf_event__state_init()) and then trying to schedule-in. Since the event > was created with a disabled state, it seems that the same this is followed > and the state gets initialized to PERF_EVENT_STATE_OFF. Unfortunately, > events in this state could not be scheduled. > > One way for things to get working is, instead of calling > perf_event__state_init() before the event is scheduled-in (when the cpu > wakes up), we can do something like: > perf_event_set_state(event, PERF_EVENT_STATE_INACTIVE); could you add check in ioctl call that set the inactive state on the dormant event.. that would start it once the cpu is online.. as requested jirka