From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EEE9C433ED for ; Fri, 23 Apr 2021 09:22:53 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A11FF6144D for ; Fri, 23 Apr 2021 09:22:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A11FF6144D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LHIkB2e9LsW6hlBiXGs7Z6s8L2T3uOQbWfOrAyuACow=; b=W58j9Z74Tffp5mAahgnXabpPl Z5dAIhxGrVsouXYdDMTHqE+cnO0+cGpA0i9ZOn7KDkoK/lFc0lFpP4mSjL4HEBI2mG4q8wzHTsP/W a3fIADPWdJCWyg3QxsnRQGcqnTwZbTGIcWwvfMlqH2b6MwUC/6nAtWnVtl5rJq/RJvcz6hV7eCgQL iNJogSTo3jl8kss0aCdZUfs8CK/UXXX95eFo+Z8LE3QulEXzZViTDouoy9CyVcW8XxlQUzYQp7VsO XbfQVtdV/+e5NdYZFYB366m4P8XJ8+TtTMrkfvL3neW3BZloINe9cqz2eQGxeYnz2X6IeIU2QzaeK JOwhn+esQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZrzh-0019tJ-Ft; Fri, 23 Apr 2021 09:21:02 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZrzV-0019rQ-MS for linux-arm-kernel@desiato.infradead.org; Fri, 23 Apr 2021 09:20:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=A7xebbZ1l38SxyIUAFUTaNkyWQlumGw8ablUGSLLvbk=; b=3MZl1fyZuRYjtE81V8mqb2j1Xi 2vodjiFoMH/3/h/tftmDFWlC0zwNfbq9Y9Y8sIh6SUwyyWzDaA9VQEoGZqOA2MCsTOVMD0JEkQkG8 3G3pM44MF5NVfpy1aEd5p6ZHUacqBGwsF0mEiAherOaKTBzE+Q7NzyRXGhT/Nod2k99PIkIkAZMSr X789pUalKCBWMhzQY8gynKkpyC7+gsX3hruK+s3gpJqSvW+GIo25kGd7ZoS4w+ibLK6xEJ0uaDofV 7U5KDbgwUcPcvxZAyrRAx4dXOAtpdStggKjqhsfDIuxhlb9pkL7+IdZZ/DCzWR5tGC+u2Kup2zQwd N+DfrG9A==; Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZrzS-00EHbF-Mk for linux-arm-kernel@lists.infradead.org; Fri, 23 Apr 2021 09:20:48 +0000 Received: by mail-pj1-x1032.google.com with SMTP id m6-20020a17090a8586b02901507e1acf0fso931252pjn.3 for ; Fri, 23 Apr 2021 02:20:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=A7xebbZ1l38SxyIUAFUTaNkyWQlumGw8ablUGSLLvbk=; b=zoinbbQqb/il85siyXG2W/VvnTU5BBCykZzam4LFF7dM3NMg6/hveDmkh3845ycEOb wD80IcYRPF/9TwvDpTBMK0ApZZKj512xSorPTVrEs1+w8391tQz9i4m5WjIvLff9+rmD ZK/YYJYmBW8XN7pjihliPo5E1tl3GMcaD0Ozf2X0c/4WlefI/2cxmE/mEedTJz/zYdP2 3u32ZkAJ0UcEUkwaS7qQAeycLZKG5jEAi5XTreVl6TemzBvViqm14QQr6oaOVn6QgsVq LKoYMBtutGP6MnC0Za3l987lDbCzyBYGeOlQV+KI0hRsKRNKPDzCaUPxWPH2xVUbpskG k+9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=A7xebbZ1l38SxyIUAFUTaNkyWQlumGw8ablUGSLLvbk=; b=q6ICo6+2pStzIUaKKdHKnLkKiG3uyEoFKlaB7KlOMAYH5im4VGP5x0qWS7yZCWYnwd a1epVpXF1RCFzp0MqE24J/FXDSo0vgOOb3yryuW+08lJkWmM5WvChZHZWSMf2RfdBVQo H/xbQI40wI7IPtmUvfb5iSjBn81GaYg+kPIA/nTG30OQngcUIhtuAqZ2YFluokvtFeKt AAgT5vvQ9pZrZVCRNjInOL1FIhOujxKs3qAy5LOGkm6er0xiDMFb1EBdOHUskrg3OZ7i +NgeJOU2+JwTTDuQ5gI4v+sSkRbv4HH2qDlxIG8I292PVOGGh8POxEUXw1zWanZsv+8J 2McQ== X-Gm-Message-State: AOAM530di9Gl1rsi5dtwst8e98yEXVwYakC2ZVeGCnWtyi+kOgi1NVvj AFr/eA9NpW77dhHCFAK5ecLvmw== X-Google-Smtp-Source: ABdhPJx302UxmOm/xy6kpXJucrZsJ/7ikVAFOxkdBnCcNFZHh4Pbr5YZ13xtOkb3JQyC2l3I/UNV7g== X-Received: by 2002:a17:90a:8b97:: with SMTP id z23mr3448023pjn.65.1619169642949; Fri, 23 Apr 2021 02:20:42 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([116.206.101.232]) by smtp.gmail.com with ESMTPSA id r5sm6914270pjd.38.2021.04.23.02.20.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 02:20:42 -0700 (PDT) Date: Fri, 23 Apr 2021 17:20:38 +0800 From: Leo Yan To: Daniel Kiss Cc: mathieu.poirier@linaro.org, suzuki.poulose@arm.com, mike.leach@linaro.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, denik@google.com, Branislav Rankov Subject: Re: [PATCH 2/4] coresight: tmc-etr: Track perf handler. Message-ID: <20210423092038.GB377091@leoy-ThinkPad-X240s> References: <20210421120413.3110775-1-daniel.kiss@arm.com> <20210421120413.3110775-3-daniel.kiss@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210421120413.3110775-3-daniel.kiss@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210423_022046_832265_8AD0A496 X-CRM114-Status: GOOD ( 19.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Daniel, On Wed, Apr 21, 2021 at 02:04:11PM +0200, Daniel Kiss wrote: [...] > diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c > index dd19d1d1c3b38..bf9f6311d8663 100644 > --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c > +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c > @@ -1511,6 +1511,12 @@ tmc_update_etr_buffer(struct coresight_device *csdev, > goto out; > } > > + /* Serve only the tracer with the right handler */ > + if (drvdata->perf_handle != handle) { > + spin_unlock_irqrestore(&drvdata->spinlock, flags); > + goto out; > + } > + I have concern for this change, Let's use the system-wide tracing as an example. If a system have 4 CPUs, for the perf with system wide tracing, the tool maps the AUX ring buffers for four times, but the CoreSight driver only allocates pages once and maps these physical pages for four times to user space. Therefore, the perf tool in the userspace manages 4 AUX ring buffers, every AUX ring buffer is served for one CPU. The confusion between the CoreSight driver (in the kernel) and the perf tool (in the userspace) is: there actually has only one ring buffer for the enabled sink (let's say ETR), but there have four ring buffer control structures, the control structure is 'perf_event_mmap_page' which is resident in the first page for perf's general ring buffer (please note, this ring buffer is different from AUX ring buffer). IIUC, this patch only allows the first CPU which enables coresight path to update the AUX ring buffer. This can break the case: - Step 1: perf tool opens ETM event; we can use the command: # perf record -o ${perfdata} -e cs_etm/@tmc_etr0/ -a -- dd if=/dev/zero of=/dev/null - Step 2: the profiled program "dd" is firstly schedued in CPU0, so its "perf_handle" will be assigned to "drvdata->perf_handle"; - Step 3: if the program "dd" is migrated to CPU1 and it never runs on CPU0 afterwards, then this patch will prevent to update the AUX ring buffer, due to the "drvdata->perf_handle" cannot match with CPU1's handler. On the other hand, I think we should change to always stick to the same "perf_output_handle" for all CPUs, thus it can allow all CPUs to use the same structure 'perf_event_mmap_page' for AUX ring buffer management. [...] Thanks, Leo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel