diff mbox

libitm: Don't execute memtransfer/memset if size isn't larger than zero.

Message ID 1330954469.2986.5559.camel@triegel.csb
State New
Headers show

Commit Message

Torvald Riegel March 5, 2012, 1:34 p.m. UTC
This patch skips execution of memtransfer/memset if there actually isn't
anything to do.  Calls to memcpy/memmove/memset with size==0 should be
rare I'd suppose but prior code would still treat this no-op like some
store (ml_wt was particularly bad: it would to acquire _all_ locks in
such a case due to calculating a correct exclusive upper bound anymore).

OK for trunk?
4.7 too?
commit e0cd0b0a1cac087020d63e63e2d8ff67eab915d1
Author: Torvald Riegel <triegel@redhat.com>
Date:   Mon Mar 5 14:27:01 2012 +0100

    libitm: Don't execute memtransfer/memset if size isn't larger than zero.
    
    	libitm/
    	* dispatch.h (CREATE_DISPATCH_METHODS_MEM): Don't execute
    	memtransfer/memset if size isn't larger than zero.

Comments

Richard Biener March 5, 2012, 1:43 p.m. UTC | #1
On Mon, Mar 5, 2012 at 2:34 PM, Torvald Riegel <triegel@redhat.com> wrote:
> This patch skips execution of memtransfer/memset if there actually isn't
> anything to do.  Calls to memcpy/memmove/memset with size==0 should be
> rare I'd suppose but prior code would still treat this no-op like some
> store (ml_wt was particularly bad: it would to acquire _all_ locks in
> such a case due to calculating a correct exclusive upper bound anymore).
>
> OK for trunk?
> 4.7 too?

Not before 4.7.0 please.

Richard.
diff mbox

Patch

diff --git a/libitm/dispatch.h b/libitm/dispatch.h
index d059c49..6a9e62e 100644
--- a/libitm/dispatch.h
+++ b/libitm/dispatch.h
@@ -102,11 +102,13 @@ 
 virtual void memtransfer(void *dst, const void* src, size_t size,    \
     bool may_overlap, ls_modifier dst_mod, ls_modifier src_mod)       \
 {                                                                     \
-  memtransfer_static(dst, src, size, may_overlap, dst_mod, src_mod); \
+  if (size > 0)                                                       \
+    memtransfer_static(dst, src, size, may_overlap, dst_mod, src_mod); \
 }                                                                     \
 virtual void memset(void *dst, int c, size_t size, ls_modifier mod)  \
 {                                                                     \
-  memset_static(dst, c, size, mod);                                  \
+  if (size > 0)                                                       \
+    memset_static(dst, c, size, mod);                                 \
 }
 
 #define CREATE_DISPATCH_METHODS_MEM_PV()  \