libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libunwind-devel] [patch] Eliminate some unnecessary msync() calls.


From: Paul Pluzhnikov
Subject: [Libunwind-devel] [patch] Eliminate some unnecessary msync() calls.
Date: Tue, 1 Dec 2009 13:34:32 -0800 (PST)

Greetings,

This is rather on the obvious side.

While doing strace on an executable using libunwind, I noticed a
lot of:

  msync(0, 1, MS_SYNC) = -1 ENOMEM (Cannot allocate memory)

Since we know that the first page isn't mapped (or at least doesn't
contain the data we are looking for), we can eliminate all such
msync calls.

Tested on Linux/x86_64 with no regressions.

Thanks,
--
Paul Pluzhnikov

diff --git a/src/x86/Ginit.c b/src/x86/Ginit.c
index e1b1dcf..2df94f0 100644
--- a/src/x86/Ginit.c
+++ b/src/x86/Ginit.c
@@ -117,6 +117,9 @@ validate_mem (unw_word_t addr)
 
   addr = PAGE_START(addr);
 
+  if (addr == 0)
+    return -1;
+
   for (i = 0; i < NLGA; i++)
     {
       if (last_good_addr[i] && (addr == last_good_addr[i]))
diff --git a/src/x86_64/Ginit.c b/src/x86_64/Ginit.c
index 031deaa..51d77c2 100644
--- a/src/x86_64/Ginit.c
+++ b/src/x86_64/Ginit.c
@@ -120,6 +120,9 @@ validate_mem (unw_word_t addr)
 
   addr = PAGE_START(addr);
 
+  if (addr == 0)
+    return -1;
+
   for (i = 0; i < NLGA; i++)
     {
       if (last_good_addr[i] && (addr == last_good_addr[i]))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]