]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix valgrind errors when protected_fixedsize_stack is used
authorYuval Lifshitz <ylifshit@redhat.com>
Fri, 22 Jan 2021 14:14:00 +0000 (16:14 +0200)
committerCasey Bodley <cbodley@redhat.com>
Fri, 12 Feb 2021 16:09:47 +0000 (11:09 -0500)
Fixes: https://tracker.ceph.com/issues/48963
Signed-off-by: Yuval Lifshitz <ylifshit@redhat.com>
(cherry picked from commit 76d4030cfeaeb4d2db39a5bd2dada09edffc8cca)

Conflicts:
src/rgw/rgw_notify.cc with DoutPrefixProvider

CMakeLists.txt
src/rgw/rgw_notify.cc

index b925881ed73423f180de41115233758f97b5bd8e..f167ef6dfaff533ebb98eb8ac218b96409ced72f 100644 (file)
@@ -350,6 +350,13 @@ else(ALLOCATOR)
   endif(gperftools_FOUND)
 endif(ALLOCATOR)
 
+if(${ALLOCATOR} STREQUAL "libc" AND WITH_SYSTEM_BOOST)
+  # valgrind can only work with libc allocator
+  # if system boost is not used, valgrind use should
+  #   be indicated via the WITH_BOOST_VALGRIND parameter
+  add_definitions(-DBOOST_USE_VALGRIND)
+endif()
+
 # Mingw generates incorrect entry points when using "-pie".
 if(WIN32 OR (HAVE_LIBTCMALLOC AND WITH_STATIC_LIBSTDCXX))
   set(EXE_LINKER_USE_PIE FALSE)
index 29b0c44093ad42718e1337aab0b40a1c053ce42f..5fa753b88830fb1e7faac7e55f8d3d2e702ad2c9 100644 (file)
@@ -6,6 +6,7 @@
 #include "cls/lock/cls_lock_client.h"
 #include <memory>
 #include <boost/algorithm/hex.hpp>
+#include <boost/context/protected_fixedsize_stack.hpp>
 #include <spawn/spawn.hpp>
 #include "rgw_pubsub.h"
 #include "rgw_pubsub_push.h"
@@ -46,6 +47,11 @@ WRITE_CLASS_ENCODER(event_entry_t)
 
 using queues_t = std::set<std::string>;
 
+// use mmap/mprotect to allocate 128k coroutine stacks
+auto make_stack_allocator() {
+  return boost::context::protected_fixedsize_stack{128*1024};
+}
+
 class Manager {
   const size_t max_queue_size;
   const uint32_t queues_update_period_ms;
@@ -227,7 +233,7 @@ class Manager {
     // start a the cleanup coroutine for the queue
     spawn::spawn(io_context, [this, queue_name](spawn::yield_context yield) {
             cleanup_queue(queue_name, yield);
-            });
+            }, make_stack_allocator());
     
     while (true) {
       // if queue was empty the last time, sleep for idle timeout
@@ -314,7 +320,7 @@ class Manager {
               ldout(cct, 20) << "INFO: processing of entry: " << 
                 entry.marker << " (" << entry_idx << "/" << total_entries << ") from: " << queue_name << " failed" << dendl;
             } 
-        });
+        }, make_stack_allocator());
         ++entry_idx;
       }
 
@@ -433,7 +439,7 @@ class Manager {
             std::lock_guard lock_guard(queue_gc_lock);
             queue_gc.push_back(queue_name);
             ldout(cct, 10) << "INFO: queue: " << queue_name << " marked for removal" << dendl;
-          });
+          }, make_stack_allocator());
         } else {
           ldout(cct, 20) << "INFO: queue: " << queue_name << " ownership (lock) renewed" << dendl;
         }
@@ -478,7 +484,7 @@ public:
     {
       spawn::spawn(io_context, [this](spawn::yield_context yield) {
             process_queues(yield);
-          });
+          }, make_stack_allocator());
 
       // start the worker threads to do the actual queue processing
       const std::string WORKER_THREAD_NAME = "notif-worker";