From patchwork Wed Aug 9 08:18:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yicong Yang X-Patchwork-Id: 133156 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2702919vqr; Wed, 9 Aug 2023 03:38:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZyugKEBE0xmD1Z2qChOqkZ82ajZTT1znDHaB7T89JYM0lfNSUs95mLBaw2Kc/OIUslmHu X-Received: by 2002:a17:906:5dd8:b0:994:522f:3f4a with SMTP id p24-20020a1709065dd800b00994522f3f4amr1811419ejv.29.1691577492474; Wed, 09 Aug 2023 03:38:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691577492; cv=none; d=google.com; s=arc-20160816; b=GuqRRHOCWU6MUcCBV2vieKN2Rd08HXzVJvF8ee3HW12NIp4k0rkQxqqLCLCeHJH8eg 0e7jRyU2TWtADYb3/2gK7flqmxDZ6Y/t/xIwEIb9+R1dV9H5iwwLXIArhI8Ea2rvaIZF 1HTDgPADmfe7x4IFzGwy9H19s4Eh1aE0fDsclqoRiONflwhsaqTCzhUkpCVSZq62Bh6q 1RGTsT+PAo0647RSrvaVhtW0cCo6NumNZsPYF856AUgjcaJBMoi9dJYpVZXbRWmOWE5M lgcs2bwIw6ublTMaZ67B1wYbOxawLh7HDUk5e6E510oQHCnxeUqRWiNpS07dvcFpElGp B2VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=byQ4K/lZ03ybZ2H5i0kNUfquLRpDZcjopIru8yJ4Yfs=; fh=3Xa+Ca9QE4oHBLojfhmHw+QI2cJx6cXgOgG4DAxRTgs=; b=FbLHVJ2aRI9hki/lq/JMerh+LsWLH7ZR4n2GVTBG6zud2HWBN3unXtRLc4AkZ6GraI KlsgQsNWmCP3uQ6wLOcOlZsA2Ah6sDhc3Rx4IiAYANiB5uJm7GPzUwJ5V374uuWJbeCV u4G4Ykd5REOjAh+DKec3b5FJWYoN8fQVHBh/JflwmzpaaX4KiXYB4Na3aUw0dZ1cs1J4 ZyUqNNiFV3AV/HOq7Muy7Xdxc766bfOfLPOFaS4phx03UF2uhxMYwTTv0ZB2RPKsyigl KDiyzhG5NbTBLOQ+dCzknarB/Ek/wyMSF3yAFmBAz/CmlP0LoU+p+5sH1i+hp9w8dXLk 5O0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kq15-20020a170906abcf00b00977eb8d769bsi8801908ejb.289.2023.08.09.03.37.48; Wed, 09 Aug 2023 03:38:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231905AbjHIIUq (ORCPT + 99 others); Wed, 9 Aug 2023 04:20:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230006AbjHIIUm (ORCPT ); Wed, 9 Aug 2023 04:20:42 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 947BB10FF; Wed, 9 Aug 2023 01:20:41 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RLNJH6G7NzmXZF; Wed, 9 Aug 2023 16:19:27 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 9 Aug 2023 16:20:39 +0800 From: Yicong Yang To: , , , CC: , , , , , , Subject: [PATCH 3/5] hwtracing: hisi_ptt: Optimize the trace data committing Date: Wed, 9 Aug 2023 16:18:23 +0800 Message-ID: <20230809081825.11518-4-yangyicong@huawei.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20230809081825.11518-1-yangyicong@huawei.com> References: <20230809081825.11518-1-yangyicong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773747560541596174 X-GMAIL-MSGID: 1773747560541596174 From: Yicong Yang Currently during the PTT trace, we'll only commit the data to the perf core when its full, which means after 4 interrupts and totally 16MiB data while the AUX buffer is 16MiB length. Then the userspace gets notified and handle the data. The driver cannot apply a new AUX buffer immediately until the committed data are handled and there's enough room in the buffer again. This patch tries to optimize this by commit the data in every interrupts in a 4MiB granularity. Then the userspace can have enough time to consume the data and there's always enough room in the AUX buffer. Signed-off-by: Yicong Yang --- drivers/hwtracing/ptt/hisi_ptt.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/hwtracing/ptt/hisi_ptt.c b/drivers/hwtracing/ptt/hisi_ptt.c index 89638ed96cf9..3aba7bb6e548 100644 --- a/drivers/hwtracing/ptt/hisi_ptt.c +++ b/drivers/hwtracing/ptt/hisi_ptt.c @@ -274,15 +274,14 @@ static int hisi_ptt_update_aux(struct hisi_ptt *hisi_ptt, int index, bool stop) buf->pos += size; /* - * Just commit the traced data if we're going to stop. Otherwise if the - * resident AUX buffer cannot contain the data of next trace buffer, - * apply a new one. + * Always commit the data to the AUX buffer in time to make sure + * userspace got enough time to consume the data. + * + * If we're not going to stop, apply a new one and check whether + * there's enough room for the next trace. */ - if (stop) { - perf_aux_output_end(handle, buf->pos); - } else if (buf->length - buf->pos < HISI_PTT_TRACE_BUF_SIZE) { - perf_aux_output_end(handle, buf->pos); - + perf_aux_output_end(handle, size); + if (!stop) { buf = perf_aux_output_begin(handle, event); if (!buf) return -EINVAL;