Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp63721ybl; Thu, 15 Aug 2019 12:43:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqRSsZBeuWHokKtOBGmwrTbv59KE6wyHQVjoHw/M5gCBYlKAGMreAmTU39h8MmC7Ce6a0K X-Received: by 2002:a65:6114:: with SMTP id z20mr4795400pgu.141.1565898213142; Thu, 15 Aug 2019 12:43:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565898213; cv=none; d=google.com; s=arc-20160816; b=arhKaRPnd3DCHdRaYQH9UeNfWdA0N7vMcFuWBA5Ya4CsED19WL8VqUClqhxKvGMxKP xYEtiIx5mCqpETB3OtoU64NyqhWcyAzLVjAzsN1v2IiG3dNxiAfPcdErEPSlUg53XpZR AftrOIvuz2SuLBEwLO8dS1ePSVUL/FHmJ8WEAJMbVgvqGepg3tBSisFjq1186yrONEbk jmnAwWiE/VoKiSVRC5MFrMFVRDoPqKHpu5ySnCEgAXJomk0O1HkXQyUa7P4feHyNgJlh /pIL8OQzLx+wT1UtAX5ObAZc7V6rBngCZtIVW8Ic5TkeZIWTJPrnbnntSyJ7dYZHRXuC R+6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=YPHDIOljV5hQaERK4FC6PgOmZFfQHVVab+DpiSEe62s=; b=EIpfs5ddef1+VidTIWcMDKqp59cLKB9wvVx2bN+J9h4DsV/xkbyOC8UvTvfzsXnf/o wabQZDFYKDI9vx6Z1dkKnTJYmGSMHU3Cd1EdHrOJysaA4+xmpZoU1uuxOweRpWlPsEdU R4pSGLQ+OZN4P3S515b15JsjQO5umiEdWR0SDJyxgojXEsmudem79xfgzzT4TZ5n4qmp 2t24H1vd5U8Zsvlxm56QJR3fIc18vSdF/F9bdFTRspCz/bCBI7zqJywl6cB2CCV5Duj6 3Kv6sC8JlzTLc78Mnl5XNU4krUHC7JF3aen8V9Ng0xc9sFXRe4ZYXmTVEqRnEqOGcPP/ ZyYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="lX/+/pbP"; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w7si2336757pgl.323.2019.08.15.12.43.16; Thu, 15 Aug 2019 12:43:33 -0700 (PDT) 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=@linaro.org header.s=google header.b="lX/+/pbP"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732275AbfHORWt (ORCPT + 99 others); Thu, 15 Aug 2019 13:22:49 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:36564 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729931AbfHORWs (ORCPT ); Thu, 15 Aug 2019 13:22:48 -0400 Received: by mail-io1-f67.google.com with SMTP id o9so656660iom.3 for ; Thu, 15 Aug 2019 10:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YPHDIOljV5hQaERK4FC6PgOmZFfQHVVab+DpiSEe62s=; b=lX/+/pbPgVYuikGECsCt+M8bkwOrFQVZRfUmqOQPaMX1z9CL2Yc1cjJHNpNYU4Sbrn bz3T9KHyos41p1xP12MdWHQX26nF9Y3GlGKfhpewxe2Rc3ijwD8hHHyukD99wq6Q2x6v PgL5MVdMZXWnZDtH/3OHfqd9z9BqsKmkGgd2jnQsyqV4EciddEOt4ubAYIPB/hUmpsTg KO3sU3cRyCNUpTzwGC0S7Hi46ohz4Vv3cJJoKy0STcxJwuDqx7wiQVo7bxAxKtLhDDnW 3APvUEGu/YYpyL2u8P1u9hln1OTcnmmvcAsICdmLl598yRShpj6b5MVHjQoVglmpk2rD 2b3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YPHDIOljV5hQaERK4FC6PgOmZFfQHVVab+DpiSEe62s=; b=SfDBStyJrnLlRzHG4JOzm52V1KqYPZN3Ffyx5gTEJTQIIXGreeiysKxFa/9ggbAHA6 Sxtu7MKjxrq2KuoNpPzDsW8Du8EdlOPpQ0m/K5S5+YbnMwr0oJe5go/mgzAn0CyNgxhq /bA6kwigeoUPN3QNK08pAgi3vmYYDOhqmJ/9WTcwAkcj2B4V1hWqqNmNx7FLQEdSwswh orTgRFO3FxAFX/0XaUeWduh8kkC+JYoJdjnBAeSdDIKLRElZANlnDO7FMWPyACRFQq68 LyS3CmQ68FDl6z14yHgco1/0uJ6NYlAMMXEV2+iR/UHReJisZ9hSapm4b4+YG67j6kY4 Kb2A== X-Gm-Message-State: APjAAAUNluyHCp5KYWeEWIGpYQyh3fq3t3jXWG2lBmceeBAnauhQqHh/ Y0cM/VuPCtLZ8FnTtAyF2hIlVc6A9Z4h3DdR5du6GZCN X-Received: by 2002:a5e:c601:: with SMTP id f1mr6364484iok.57.1565889767438; Thu, 15 Aug 2019 10:22:47 -0700 (PDT) MIME-Version: 1.0 References: <20190814235058.184204-1-yabinc@google.com> In-Reply-To: <20190814235058.184204-1-yabinc@google.com> From: Mathieu Poirier Date: Thu, 15 Aug 2019 11:22:36 -0600 Message-ID: Subject: Re: [PATCH v2] coresight: tmc-etr: Fix perf_data check. To: Yabin Cui Cc: Suzuki K Poulose , Alexander Shishkin , linux-arm-kernel , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 14 Aug 2019 at 17:51, Yabin Cui wrote: > > > Did you actually see the check fail or is this a theoretical thing? > > I'm really perplex here has I have tested this scenario many times > > without issues. > > > I have seen this warning in dmesg output, that's how I find the problem. > > > In CPU wide scenarios each perf event (one per CPU) is associated with > > an event_data during the setup process. The event_data is the > > etr_perf holding a reference to the perf ring buffer for that specific > > event along with the etr_buf, regardless of who created the latter. > > Agree. > > > From there, when the event is installed on a CPU, the csdev for that > > CPU is given a reference to the event_data of that event[1]. Before > > going further notice how there is a per CPU csdev and event handle to > > keep track of event specifics[2]. As such both (per CPU) csdev and > > event handle carry the exact same reference to the etr_perf. > > > On my test device (Pixel 3), there is an ETM device on each cpu, but only > one ETR device for the whole device. So there is only one instance of etr > csdev in the kernel. If multiple cpus are scheduling on etm perf events at > the same time, all of them are trying to set their event_data to the same > etr csdev. And different perf events have different event_data. A warning > situation is as below: > > cpu 0 > schedule on event A (set etr csdev->perf_data to event_a.etr_perf) > > cpu 1 > schedule on event B (set etr csdev->perf_data to event_b.etr_perf) > You are 100% right and looking at it again this morning it just jumped at me. I simply can't understand how it did not manifest itself during all the hammering I did on it. Please see details in my other (and upcoming) email. Thanks, Mathieu > cpu 1 > schedule off event B (update buffer, does nothing since csdev->refcnt != 1) > > cpu 0 > schedule off event A (update buffer, but etr csdev->perf_data check fail)