From patchwork Fri Aug 4 08:15:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruidong Tian X-Patchwork-Id: 13341449 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 77972C04A94 for ; Fri, 4 Aug 2023 08:15:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wZUwoNdvXBCWtYHVW/1iAxWGzPXqVMLgXJoTQ4oaMJg=; b=awwf9Iz+Z0wxLu AnAWczBmNz82sueQCZJbMQp5RiTVCoI2aFL3DZqAC7XZWZb0Rw8HPolhh+1xa4aeclZ7Kkg9C2ufk IN6ahRKzE1c2B6ml9APUp3f8EYCik1Swg8h8zAoPDaeFJX0LyolYahLydv+uSfW88o5dqu/RMRkwZ WSf7QHJmAe92Bq2l5PneCKci0e4M8ml4hdNe/oC5mBJQNO8f/U+8ll4M7yvrF6x3QnApi2HsqCRQ+ oXmsUbHpmn+1G5smkZiRPJcMEpFeEkUatLWSAlC6veIFDuv9xt7FrM7yKW9RMKs0Xy7FauKYsJXcX WZyo/W2T9NIlhja/8qbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRpy7-00BrNQ-1B; Fri, 04 Aug 2023 08:15:31 +0000 Received: from out30-119.freemail.mail.aliyun.com ([115.124.30.119]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qRpy4-00BrMF-15 for linux-arm-kernel@lists.infradead.org; Fri, 04 Aug 2023 08:15:30 +0000 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R791e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=tianruidong@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0Vp.kW45_1691136918; Received: from localhost(mailfrom:tianruidong@linux.alibaba.com fp:SMTPD_---0Vp.kW45_1691136918) by smtp.aliyun-inc.com; Fri, 04 Aug 2023 16:15:20 +0800 From: Ruidong Tian To: linux-kernel@vger.kernel.org Cc: tianruidong@linux.alibaba.com, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org, suzuki.poulose@arm.com, james.clark@arm.com Subject: [PATCH v3 0/1] coresight: tmc: Explicit type conversions to Date: Fri, 4 Aug 2023 16:15:13 +0800 Message-Id: <20230804081514.120171-1-tianruidong@linux.alibaba.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20230714084349.31567-1-tianruidong@linux.alibaba.com> References: <20230714084349.31567-1-tianruidong@linux.alibaba.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230804_011528_580380_7FE9DDCB X-CRM114-Status: UNSURE ( 7.66 ) X-CRM114-Notice: Please train this message. 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Perf cs_etm session executed unexpectedly when AUX buffer > 1G. perf record -C 0 -m ,2G -e cs_etm// -- [ perf record: Captured and wrote 2.615 MB perf.data ] Perf only collect about 2M perf data rather than 2G. This is becasuse the operation, "nr_pages << PAGE_SHIFT", in coresight tmc driver, will overflow when nr_pages >= 0x80000(correspond to 1G AUX buffer). The overflow cause buffer allocation to fail, and TMC driver will alloc minimal buffer size(1M). You can just get about 2M perf data(1M AUX buffer + perf data header) at least. Explicit convert nr_pages to 64 bit in tmc driver to avoid overflow. Changes in V2: Suzuki K Poulose: Add another 2 places where needed to fix. Changes in V1: James Clark: Use a more accurate commit message. Ruidong Tian (1): coresight: tmc: Explicit type conversions to prevent integer overflow drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +- drivers/hwtracing/coresight/coresight-tmc-etr.c | 5 +++-- drivers/hwtracing/coresight/coresight-tmc.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)