Skip to contentSkip to conversation

pktgen: clean up ktime_t helpers

RFC PATCH In review Daniel Borkmann 3 participants 3 messages Oct 26, 2012 – Oct 28, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 pktgen: clean up ktime_t helpers

Some years ago, the ktime_t helper functions ktime_now() and ktime_lt() have been introduced. Instead of defining them inside pktgen.c, they should either use ktime_t library functions or, if not available, they should be defined in ktime.h, so that also others can benefit from them. ktime_compare() is introduced with a similar notion as in timespec_compare().

---
 include/linux/ktime.h |   19 +++++++++++++++++++
 net/core/pktgen.c     |   41 +++++++++++++----------------------------
 2 files changed, 32 insertions(+), 28 deletions(-)
include/linux/ktime.h +19 -0
index 06177ba10..e83512f 100644
@@ -282,6 +282,25 @@ static inline int ktime_equal(const ktime_t cmp1, const ktime_t cmp2)
 	return cmp1.tv64 == cmp2.tv64;
 }
 
+/**
+ * ktime_compare - Compares two ktime_t variables for less, greater or equal
+ * @cmp1:	comparable1
+ * @cmp2:	comparable2
+ *
+ * Returns ...
+ *   cmp1  < cmp2: return <0
+ *   cmp1 == cmp2: return 0
+ *   cmp1  > cmp2: return >0
+ */
+static inline int ktime_compare(const ktime_t cmp1, const ktime_t cmp2)
+{
+	if (cmp1.tv64 < cmp2.tv64)
+		return -1;
+	if (cmp1.tv64 > cmp2.tv64)
+		return 1;
+	return 0;
+}
+
 static inline s64 ktime_to_us(const ktime_t kt)
 {
 	struct timeval tv = ktime_to_timeval(kt);
net/core/pktgen.c +13 -28

109 lines not on this page · raw message

#1 lore raw
Quoted 7 lines · Daniel Borkmann

Some years ago, the ktime_t helper functions ktime_now() and ktime_lt() have been introduced. Instead of defining them inside pktgen.c, they should either use ktime_t library functions or, if not available, they should be defined in ktime.h, so that also others can benefit from them. ktime_compare() is introduced with a similar notion as in timespec_compare().

Looks good. This is a cleanup patch, doesn't need to be RFC, I think.

Thanks.

#2 lore raw
Quoted 10 lines · Cong Wang
Quoted 7 lines · Daniel Borkmann

Some years ago, the ktime_t helper functions ktime_now() and ktime_lt() have been introduced. Instead of defining them inside pktgen.c, they should either use ktime_t library functions or, if not available, they should be defined in ktime.h, so that also others can benefit from them. ktime_compare() is introduced with a similar notion as in timespec_compare().

Looks good. This is a cleanup patch, doesn't need to be RFC, I think.

Thanks for the review, I'll resubmit it normally as non-RFC.