[PATCH] Enhance time sampling of async IO VFS functions

Ralph Boehme rb at sernet.de
Fri Feb 26 20:56:58 UTC 2016


On Fri, Feb 26, 2016 at 10:45:31AM -0800, Jeremy Allison wrote:
> On Fri, Feb 26, 2016 at 06:39:36PM +0100, Ralph Boehme wrote:
> > I though about adding struct tevent_req.async.(uint64_t)duration and
> > getter/setter functions
> > tevent_req_set_duration()/tevent_req_get_duration().
> > 
> > This could then be used by the implementation of an async request to
> > set the duration and the caller can read it, further passing up the
> > stack and processing as needed.
> 
> If we want to make this a generic feature of tevent, then
> the above is the way to go - but I think that needs a bigger
> discussion than just you and I.
> 
> Metze, Volker - what do you think about adding duration
> as a feature to tevent_req.async ?

something like this.

-Ralph

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de,mailto:kontakt@sernet.de
-------------- next part --------------
From c669366fc8b8c6e1267e1d481f23dcad4609e7e1 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Fri, 26 Feb 2016 21:49:11 +0100
Subject: [PATCH] tevent: add optional duration to tevent_req

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 lib/tevent/tevent.h          | 28 ++++++++++++++++++++++++++++
 lib/tevent/tevent_internal.h |  9 +++++++++
 lib/tevent/tevent_req.c      | 10 ++++++++++
 3 files changed, 47 insertions(+)

diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h
index cb95507..2b25f73 100644
--- a/lib/tevent/tevent.h
+++ b/lib/tevent/tevent.h
@@ -1299,6 +1299,34 @@ bool tevent_req_is_error(struct tevent_req *req,
 			 uint64_t *error);
 
 /**
+ * @brief Use this in the implementation of an async request that wants
+ * to pass information about the completion time of the request to the
+ * caller of the async request.
+ *
+ * @param[in]  req      The tevent request to get the error from.
+ *
+ * @param[in]  duration Set the duration of a request
+ *
+ * @see tevent_ret_get_duration()
+ */
+void tevent_ret_set_duration(struct tevent_req *req, uint64_t duration);
+
+/**
+ * @brief Used by the caller of any async request to retrieve duration
+ * info.
+ *
+ * @note It's up to the implementation of an async request to store
+ * duration information.
+ *
+ * @param[in]  req      The tevent request to get the error from.
+ *
+ * @param[in]  duration Set the duration of a request
+ *
+ * @see tevent_ret_get_duration()
+ */
+uint64_t tevent_ret_get_duration(struct tevent_req *req);
+
+/**
  * @brief Use as the last action of a _recv() function.
  *
  * This function destroys the attached private data.
diff --git a/lib/tevent/tevent_internal.h b/lib/tevent/tevent_internal.h
index 10cc4a4..369abc9 100644
--- a/lib/tevent/tevent_internal.h
+++ b/lib/tevent/tevent_internal.h
@@ -164,6 +164,15 @@ struct tevent_req {
 		 *
 		 */
 		struct tevent_timer *timer;
+
+		/**
+		 * @brief Can be used by the implementation of an
+		 *        async request to store the duration of the
+		 *        request via tevent_ret_set_duration(). The
+		 *        caller can read the value via
+		 *        tevent_ret_get_duration().
+		 */
+		uint64_t duration;
 	} internal;
 };
 
diff --git a/lib/tevent/tevent_req.c b/lib/tevent/tevent_req.c
index c86fb68..9fcd652 100644
--- a/lib/tevent/tevent_req.c
+++ b/lib/tevent/tevent_req.c
@@ -345,3 +345,13 @@ void tevent_req_set_cleanup_fn(struct tevent_req *req, tevent_req_cleanup_fn fn)
 	req->private_cleanup.state = req->internal.state;
 	req->private_cleanup.fn = fn;
 }
+
+void tevent_ret_set_duration(struct tevent_req *req, uint64_t duration)
+{
+	req->internal.duration = duration;
+}
+
+uint64_t tevent_ret_get_duration(struct tevent_req *req)
+{
+	return req->internal.duration;
+}
-- 
2.5.0



More information about the samba-technical mailing list