Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2374319rdb; Tue, 10 Oct 2023 01:51:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTdIuvMCLouUouXZXCEQFcj10cmxEOSEmGKcjcXvCNBJCUt1likXZssLS3hSM9ucAdoska X-Received: by 2002:a05:6358:9d82:b0:164:a045:e459 with SMTP id d2-20020a0563589d8200b00164a045e459mr4388178rwo.16.1696927862284; Tue, 10 Oct 2023 01:51:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696927862; cv=none; d=google.com; s=arc-20160816; b=dh0DtFfNv/mLVm0wsW4RJO8jcdbc2teHJCeGCX/gVBYWal8RwKB2h1izYCx4/02jTG atyfzD9QqYyXENG0RAJa9YG69N6WTcpyemQLFbAmQGUy48DN/8NjOPvJLIg0XCqdLW7A 92pEuFb2JcnM7h8loBG9upwBKj6LXkaoooyAND0jvWjGeKaTZqHwahz8vFUn3czcuQ99 WMmpElNkHdofQWbyCWHw3/v0eXoamo46+KqE/cauQflgN53z+6uNvBH+yB58pw1eSaSr WeBUOU+Cqsf7Zh9E39FM4m2T+e1gchK/zpDHSXQB1c8ozDU8reFPD7j58hT0QzSidLUU mqbA== 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=UhF132UR7CjX0tu3a7TrhbkBkhaP2ML4LJ1M75Ezkoc=; fh=ko8w2iEBByNlWLnAg6bNI5pex73wZFG+4jwxERcD8TA=; b=oKu3++MB8+yA9P2T6toozTLLa9eCo7gL2/jd5tVGok50+dvU7N2lVaW2vfrbcdH6Ug tHIoxUPx2ebzi6YvQpTZg5FlnEkQFgIAhJtu78TCKMjKSdnjMyoEqHTuztY7WNtb6uR0 YJh5Q5AXQoddknQkmcwWF1VXhcokpULJdQ/2krVlesnMF2/K+2sSFueamV04pMxhW5/x Ncas/7arPrBbYOJEEl8hVsfivgaPpSzaXDVgFLidpFu6ypPc8DpCdxffxsWCWrdteZtm AFLGBRLDyH4xWYkUlEMBdW39+/gDduJiap4Le5pdWxm9jAg84+Z2r+MQLpO4tY3oWI0l qJNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id q15-20020a17090a178f00b0027ce344c18asi1389229pja.38.2023.10.10.01.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 01:51:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 2934A826E333; Tue, 10 Oct 2023 01:50:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230054AbjJJIum (ORCPT + 99 others); Tue, 10 Oct 2023 04:50:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229729AbjJJIu2 (ORCPT ); Tue, 10 Oct 2023 04:50:28 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEFA3A7; Tue, 10 Oct 2023 01:50:22 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4S4TzJ5w91zVlDB; Tue, 10 Oct 2023 16:46:52 +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.31; Tue, 10 Oct 2023 16:50:20 +0800 From: Yicong Yang To: , , , CC: , , , , , , Subject: [PATCH v3 3/5] hwtracing: hisi_ptt: Optimize the trace data committing Date: Tue, 10 Oct 2023 16:47:29 +0800 Message-ID: <20231010084731.30450-4-yangyicong@huawei.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20231010084731.30450-1-yangyicong@huawei.com> References: <20231010084731.30450-1-yangyicong@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 10 Oct 2023 01:50:58 -0700 (PDT) X-Spam-Level: ** From: Yicong Yang In the current implementation, there're 4*4MiB trace buffer and hardware will fill the buffer one by one. The driver will get notified if one buffer is full and then copy data to the AUX buffer. If there's no enough room for the next trace buffer, we'll commit the AUX buffer to the perf core and try to apply a new one. In a typical configuration the AUX buffer will be 16MiB, so we'll commit the data after the whole AUX buffer is occupied. Then the driver cannot apply a new AUX buffer immediately until the committed data is consumed by userspace and then there's room in the AUX buffer again. This patch tries to optimize this by commit the data after one single trace buffer is filled. Since there's still room in the AUX buffer, driver can apply a new one without failure and don't need to wait for the userspace to consume the data. Signed-off-by: Yicong Yang Acked-by: Jonathan Cameron --- 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 3041238a6e54..4f355df8da23 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; -- 2.24.0