OSDN Git Service

soc: qcom: hab: add time profiling function
authorYong Ding <yongding@codeaurora.org>
Wed, 29 Nov 2017 05:46:07 +0000 (13:46 +0800)
committerYong Ding <yongding@codeaurora.org>
Thu, 30 Nov 2017 03:20:12 +0000 (11:20 +0800)
With this profiling function, hab communication overhead can be
measured for performance debug.

Change-Id: I26dd487cfd1bbb811de69d8b35a7c095a21361ac
Signed-off-by: Yong Ding <yongding@codeaurora.org>
drivers/soc/qcom/hab/hab.c
drivers/soc/qcom/hab/hab_msg.c
drivers/soc/qcom/hab/qvm_comm.c
include/uapi/linux/habmm.h

index 019f93b..eb228a0 100644 (file)
@@ -311,7 +311,11 @@ long hab_vchan_send(struct uhab_context *ctx,
                return -ENODEV;
 
        HAB_HEADER_SET_SIZE(header, sizebytes);
-       HAB_HEADER_SET_TYPE(header, HAB_PAYLOAD_TYPE_MSG);
+       if (flags & HABMM_SOCKET_SEND_FLAGS_XING_VM_STAT)
+               HAB_HEADER_SET_TYPE(header, HAB_PAYLOAD_TYPE_PROFILE);
+       else
+               HAB_HEADER_SET_TYPE(header, HAB_PAYLOAD_TYPE_MSG);
+
        HAB_HEADER_SET_ID(header, vchan->otherend_id);
 
        while (1) {
index f08cc83..88aa868 100644 (file)
@@ -139,6 +139,7 @@ void hab_msg_recv(struct physical_channel *pchan,
        uint32_t vchan_id = HAB_HEADER_GET_ID(*header);
        struct virtual_channel *vchan = NULL;
        struct export_desc *exp_desc;
+       struct timeval tv;
 
        /* get the local virtual channel if it isn't an open message */
        if (payload_type != HAB_PAYLOAD_TYPE_INIT &&
@@ -200,6 +201,21 @@ void hab_msg_recv(struct physical_channel *pchan,
                hab_vchan_stop(vchan);
                break;
 
+       case HAB_PAYLOAD_TYPE_PROFILE:
+               do_gettimeofday(&tv);
+
+               /* pull down the incoming data */
+               message = hab_msg_alloc(pchan, sizebytes);
+               if (!message) {
+                       pr_err("msg alloc failed\n");
+                       break;
+               }
+
+               ((uint64_t *)message->data)[2] = tv.tv_sec;
+               ((uint64_t *)message->data)[3] = tv.tv_usec;
+               hab_msg_queue(vchan, message);
+               break;
+
        default:
                break;
        }
index 20a631e..d839977 100644 (file)
@@ -40,6 +40,7 @@ int physical_channel_send(struct physical_channel *pchan,
        int sizebytes = HAB_HEADER_GET_SIZE(*header);
        struct qvm_channel *dev  = (struct qvm_channel *)pchan->hyp_data;
        int total_size = sizeof(*header) + sizebytes;
+       struct timeval tv;
 
        if (total_size > dev->pipe_ep->tx_info.sh_buf->size)
                return -EINVAL; /* too much data for ring */
@@ -60,6 +61,12 @@ int physical_channel_send(struct physical_channel *pchan,
                return -EIO;
        }
 
+       if (HAB_HEADER_GET_TYPE(*header) == HAB_PAYLOAD_TYPE_PROFILE) {
+               do_gettimeofday(&tv);
+               ((uint64_t *)payload)[0] = tv.tv_sec;
+               ((uint64_t *)payload)[1] = tv.tv_usec;
+       }
+
        if (sizebytes) {
                if (hab_pipe_write(dev->pipe_ep,
                        (unsigned char *)payload,
index c051465..59b603a 100644 (file)
@@ -117,6 +117,14 @@ struct hab_unimport {
 
 #define HABMM_SOCKET_SEND_FLAGS_NON_BLOCKING 0x00000001
 
+/*
+ * Collect cross-VM stats: client provides stat-buffer large enough to allow 2
+ * ets of a 2-uint64_t pair to collect seconds and nano-seconds at the
+ * beginning of the stat-buffer. Stats are collected when the stat-buffer leaves
+ * VM1, then enters VM2
+ */
+#define HABMM_SOCKET_SEND_FLAGS_XING_VM_STAT 0x00000002
+
 #define HABMM_SOCKET_RECV_FLAGS_NON_BLOCKING 0x00000001
 
 #define HABMM_EXP_MEM_TYPE_DMA 0x00000001