]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix valgrind errors when protected_fixedsize_stack is used 39025/head
authorYuval Lifshitz <ylifshit@redhat.com>
Fri, 22 Jan 2021 14:14:00 +0000 (16:14 +0200)
committerYuval Lifshitz <ylifshit@redhat.com>
Thu, 28 Jan 2021 06:32:00 +0000 (08:32 +0200)
Fixes: https://tracker.ceph.com/issues/48963
Signed-off-by: Yuval Lifshitz <ylifshit@redhat.com>
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 5d6b1759f4f7dedfcc097e9fdf05018ca616d686..7e9c05391c4e7b4f2f5cde8c89dda1c318343d4a 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 : public DoutPrefixProvider {
   const size_t max_queue_size;
   const uint32_t queues_update_period_ms;
@@ -231,7 +237,7 @@ class Manager : public DoutPrefixProvider {
     // 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
@@ -318,7 +324,7 @@ class Manager : public DoutPrefixProvider {
               ldpp_dout(this, 20) << "INFO: processing of entry: " << 
                 entry.marker << " (" << entry_idx << "/" << total_entries << ") from: " << queue_name << " failed" << dendl;
             } 
-        });
+        }, make_stack_allocator());
         ++entry_idx;
       }
 
@@ -437,7 +443,8 @@ class Manager : public DoutPrefixProvider {
             std::lock_guard lock_guard(queue_gc_lock);
             queue_gc.push_back(queue_name);
             ldpp_dout(this, 10) << "INFO: queue: " << queue_name << " marked for removal" << dendl;
-          });
+            ldout(cct, 10) << "INFO: queue: " << queue_name << " marked for removal" << dendl;
+          }, make_stack_allocator());
         } else {
           ldpp_dout(this, 20) << "INFO: queue: " << queue_name << " ownership (lock) renewed" << dendl;
         }
@@ -482,7 +489,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";