diff mbox

[ovs-dev,12/12] timeval: Reorder elements in clock structure.

Message ID 1475857062-55311-13-git-send-email-bhanuprakash.bodireddy@intel.com
State Changes Requested
Delegated to: Daniele Di Proietto
Headers show

Commit Message

Bodireddy, Bhanuprakash Oct. 7, 2016, 4:17 p.m. UTC
By reordering the elements in clock structure, pad bytes can be reduced
and also a cache line is saved.

Before: structure size:136, holes:3, sum padbytes:18, cachelines:3
After: structure size:120, holes:1, sum padbytes:2, cachelines:2

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
---
 lib/timeval.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jarno Rajahalme Oct. 7, 2016, 9:13 p.m. UTC | #1
I would leave the ‘stopped’ member below the comment.

Also, the 2nd cacheline is only ever accessed during unit tests, so this should not have real performance impact.

Acked-by: Jarno Rajahalme <jarno@ovn.org>

> On Oct 7, 2016, at 9:17 AM, Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com> wrote:
> 
> By reordering the elements in clock structure, pad bytes can be reduced
> and also a cache line is saved.
> 
> Before: structure size:136, holes:3, sum padbytes:18, cachelines:3
> After: structure size:120, holes:1, sum padbytes:2, cachelines:2
> 
> Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
> Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
> ---
> lib/timeval.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/timeval.c b/lib/timeval.c
> index 0e8709a..ee755db 100644
> --- a/lib/timeval.c
> +++ b/lib/timeval.c
> @@ -69,12 +69,12 @@ struct large_warp {
> 
> struct clock {
>     clockid_t id;               /* CLOCK_MONOTONIC or CLOCK_REALTIME. */
> +    atomic_bool slow_path;             /* True if warped or stopped. */
> +    bool stopped OVS_GUARDED;          /* Disable real-time updates if true. */
> 
>     /* Features for use by unit tests.  Protected by 'mutex'. */
>     struct ovs_mutex mutex;
> -    atomic_bool slow_path;             /* True if warped or stopped. */
>     struct timespec warp OVS_GUARDED;  /* Offset added for unit tests. */
> -    bool stopped OVS_GUARDED;          /* Disable real-time updates if true. */
>     struct timespec cache OVS_GUARDED; /* Last time read from kernel. */
>     struct large_warp large_warp OVS_GUARDED; /* Connection information waiting
>                                                  for warp response. */
> -- 
> 2.4.11
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
diff mbox

Patch

diff --git a/lib/timeval.c b/lib/timeval.c
index 0e8709a..ee755db 100644
--- a/lib/timeval.c
+++ b/lib/timeval.c
@@ -69,12 +69,12 @@  struct large_warp {
 
 struct clock {
     clockid_t id;               /* CLOCK_MONOTONIC or CLOCK_REALTIME. */
+    atomic_bool slow_path;             /* True if warped or stopped. */
+    bool stopped OVS_GUARDED;          /* Disable real-time updates if true. */
 
     /* Features for use by unit tests.  Protected by 'mutex'. */
     struct ovs_mutex mutex;
-    atomic_bool slow_path;             /* True if warped or stopped. */
     struct timespec warp OVS_GUARDED;  /* Offset added for unit tests. */
-    bool stopped OVS_GUARDED;          /* Disable real-time updates if true. */
     struct timespec cache OVS_GUARDED; /* Last time read from kernel. */
     struct large_warp large_warp OVS_GUARDED; /* Connection information waiting
                                                  for warp response. */