Received: by 10.223.185.116 with SMTP id b49csp2698931wrg; Mon, 12 Feb 2018 14:24:11 -0800 (PST) X-Google-Smtp-Source: AH8x2263JwGgnTm8iJoXZElXfn6HdXmnpjAL1qNpv/BD7s2EROJNeZlmsHAxwy434qiunL62zOMy X-Received: by 2002:a17:902:624:: with SMTP id 33-v6mr3357542plg.126.1518474251082; Mon, 12 Feb 2018 14:24:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518474251; cv=none; d=google.com; s=arc-20160816; b=0DozqHg9OUvYAB6xunswLweCAYR5h+bOgEoQbIVmPUxDg/AI5C1+pQLAeHs7xt025C qYLLTYUKQG+9Txd08xwjig+XKjfiiHZ7GhtjX68cnRbVarhwVZP+FvS8p1PliZMqxAy4 QI2UH+GNUiDrvK9xUS9h/UZ9SAL+8jy7iutJt99CCFfbfeLUDGbkhDSqtLfBWqnKvEjx jQg4BXBRoGwvVrOt+Np2aqUzF2EhSRL+70THhpZ5V4axml2/+sSrbEIVHLvZ5KUfpspn q2Uoy05Xw2tsCL8NO6sheYXY9WPEHvMmLXMBpRlD0nj8PRG+12sI9Zi3Q4qfvRYjih49 z/lA== 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:references:cc:to:subject:from:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=Gb2NApJM4P/uIJroF1j+OjiHASoMgLJPAh7txzZL8wI=; b=s85O0wXF1XU0vsMnGxpy8UpjqoTZdhCjTuoVQXCmrFonsZdDlDPZl8G9XF8xGKuDfP VEkqRXpnuJua6FO3hvUvi/ZZ/6o5tnfcWBB/tsjMF1uV759CMMLy+k+yzvstSfe3vVTO +/YtXgiePx/1bFtkQrX3FWnJ3qcf9/r5znMMYuDKi+mHZDBQQ6ZtEJaT7fKf5YWQgy0E MIgAD2gxKm6q0D6W6ESyWcOZjROAlA22MX27/rWQnozVyTVhmYejM4USqDnne61npzYQ KRyf2ldD2i9tU+nwTtW1CsJPKCCmmLCsAuMAKVRzcxwy819uJniosgiQQGBH2JQWv0i3 dl9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=cqIevDJr; dkim=pass header.i=@codeaurora.org header.s=default header.b=leLnjl80; 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 m187si6891448pfb.291.2018.02.12.14.23.56; Mon, 12 Feb 2018 14:24:11 -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=@codeaurora.org header.s=default header.b=cqIevDJr; dkim=pass header.i=@codeaurora.org header.s=default header.b=leLnjl80; 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 S932930AbeBLWWn (ORCPT + 99 others); Mon, 12 Feb 2018 17:22:43 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:55442 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932628AbeBLWWk (ORCPT ); Mon, 12 Feb 2018 17:22:40 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id EF7B660F91; Mon, 12 Feb 2018 22:22:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518474160; bh=TE5oR5FI5Z0dl4ff66n+29KklnxiC91LqQZfc0aXC30=; h=From:Subject:To:Cc:References:Date:In-Reply-To:From; b=cqIevDJrgys4Yx0j3wdp380EFmOeFTHJPz+fBM0CAAjoYCbTX+7CuDH4+W+LtL0Bi Xq+DLkY16mtylK3TD6TQ1jkMPSrwGdyryBA1dGA7yVBL8pncHSmZIHl/JbkcUDP1Ng aDWJQX5+b8gFJr9yZSjOJbTgC7jCIupHJUWNx8d4= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.134.64.46] (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: rananta@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A5B2160F6C; Mon, 12 Feb 2018 22:22:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518474159; bh=TE5oR5FI5Z0dl4ff66n+29KklnxiC91LqQZfc0aXC30=; h=From:Subject:To:Cc:References:Date:In-Reply-To:From; b=leLnjl80RXE2tHIuqXUQ+WaN5ru8EGWpmmdDwt6Dt/P4VRGb0TlYohVaa+GviQO+T CiOtaki/T8cWIPLPSWibnV5ud+eX+HmXTXCGHnV1Y+XY8gELSKNuVNyeMi1Ba2OBuE TuFInU0//0DGpfJogKaCOOBqk+5k3R3g9FCPBZRw= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A5B2160F6C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=rananta@codeaurora.org From: Raghavendra Rao Ananta Subject: Re: [PATCH] perf: Add support for creating offline events To: Jiri Olsa 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 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> Message-ID: <6aab2b36-0fe6-7a3d-2106-d4c93ec95a8a@codeaurora.org> Date: Mon, 12 Feb 2018 14:22:30 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20180212212101.GA15817@krava> 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 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); I made this change and ran the same test as yours, and I see things working out for us: # ./perf stat -C 1 -e sched:sched_switch -v -I 1000 failed to read counter sched:sched_switch # time counts unit events 1.000115547 sched:sched_switch failed to read counter sched:sched_switch 2.000265492 sched:sched_switch failed to read counter sched:sched_switch 3.000379462 sched:sched_switch failed to read counter sched:sched_switch 4.000523872 sched:sched_switch failed to read counter sched:sched_switch 5.000614808 sched:sched_switch /* CPU bought ONLINE here */ sched:sched_switch: 541 284808940 284808940 6.000767761 541 sched:sched_switch sched:sched_switch: 180 1000119686 1000119686 7.000907234 180 sched:sched_switch sched:sched_switch: 248 1000129929 1000129929 8.001026518 248 sched:sched_switch sched:sched_switch: 253 1000173050 1000173050 9.001203689 253 sched:sched_switch sched:sched_switch: 620 1000113378 1000113378 10.001323334 620 sched:sched_switch sched:sched_switch: 366 1000121839 1000121839 11.001448354 366 sched:sched_switch sched:sched_switch: 327 1000147664 1000147664 12.001591432 327 sched:sched_switch ^Csched:sched_switch: 272 488810681 488810681 12.490414290 272 sched:sched_switch sched:sched_switch: 6 75893 75893 Yes, so as you mentioned adding something like perf_event_attr::enable_on_online gives us a control as to put the event in INACTIVE state. -- Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project