]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
src/crush: extra logging to debug CPU burn in test_with_fork() 50406/head
authorDeepika Upadhyay <deepika@koor.tech>
Wed, 12 Oct 2022 16:43:01 +0000 (22:13 +0530)
committerRadosław Zarzyński <rzarzyns@redhat.com>
Mon, 6 Mar 2023 19:22:00 +0000 (20:22 +0100)
related: https://tracker.ceph.com/issues/57782

Signed-off-by: Deepika Upadhyay <deepika@koor.tech>
(cherry picked from commit 79e2902acdcf1c529f73e80449ac067e4bba2675)

src/crush/CrushTester.cc
src/crush/CrushTester.h
src/mon/OSDMonitor.cc
src/tools/crushtool.cc

index 372e0b9d4603901df016a489c154c4133a60f568..4f99cffaaa9ef30e9f7b147a984b0f6e54605391 100644 (file)
 #include "include/stringify.h"
 #include "CrushTester.h"
 #include "CrushTreeDumper.h"
+#include "common/ceph_context.h"
 #include "include/ceph_features.h"
+#include "common/debug.h"
 
+#define dout_subsys ceph_subsys_crush
+#undef dout_prefix
+#define dout_prefix *_dout << "CrushTester: "
 
 using std::cerr;
 using std::cout;
@@ -365,11 +370,12 @@ void CrushTester::write_integer_indexed_scalar_data_string(vector<string> &dst,
   dst.push_back( data_buffer.str() );
 }
 
-int CrushTester::test_with_fork(int timeout)
+int CrushTester::test_with_fork(CephContext* cct, int timeout)
 {
+  ldout(cct, 20) << __func__ << dendl;
   ostringstream sink;
   int r = fork_function(timeout, sink, [&]() {
-      return test();
+      return test(cct);
     });
   if (r == -ETIMEDOUT) {
     err << "timed out during smoke test (" << timeout << " seconds)";
@@ -429,8 +435,9 @@ bool CrushTester::check_name_maps(unsigned max_id) const
   return true;
 }
 
-int CrushTester::test()
+int CrushTester::test(CephContext* cct)
 {
+  ldout(cct, 20) << dendl;
   if (min_rule < 0 || max_rule < 0) {
     min_rule = 0;
     max_rule = crush.get_max_rules() - 1;
@@ -477,6 +484,8 @@ int CrushTester::test()
     crush.start_choose_profile();
   
   for (int r = min_rule; r < crush.get_max_rules() && r <= max_rule; r++) {
+    ldout(cct, 20) << "rule: " << r << dendl;
+
     if (!crush.rule_exists(r)) {
       if (output_statistics)
         err << "rule " << r << " dne" << std::endl;
@@ -490,6 +499,8 @@ int CrushTester::test()
       << std::endl;
 
     for (int nr = min_rep; nr <= max_rep; nr++) {
+      ldout(cct, 20) << "current numrep: " << nr << dendl;
+
       vector<int> per(crush.get_max_devices());
       map<int,int> sizes;
 
@@ -635,6 +646,8 @@ int CrushTester::test()
           }
         }
 
+      ldout(cct, 20) << "output statistics created" << dendl;
+
       if (output_data_file)
         for (unsigned i = 0; i < per.size(); i++) {
           vector_data_buffer_f.clear();
@@ -655,10 +668,13 @@ int CrushTester::test()
         }
       }
 
+      ldout(cct, 20) << "output data file created" << dendl;
       string rule_tag = crush.get_rule_name(r);
 
       if (output_csv)
         write_data_set_to_csv(output_data_file_name+rule_tag,tester_data);
+
+      ldout(cct, 20) << "successfully written csv" << dendl;
     }
   }
 
index aa3d904b6222fbc3735bd861840a5247a1052904..54f597651f845c34dd31de966f50565c2530c6ac 100644 (file)
@@ -5,6 +5,7 @@
 #define CEPH_CRUSH_TESTER_H
 
 #include "crush/CrushWrapper.h"
+#include "include/common_fwd.h"
 
 #include <fstream>
 
@@ -347,8 +348,8 @@ public:
    *         large, true otherwise
    */
   bool check_name_maps(unsigned max_id = 0) const;
-  int test();
-  int test_with_fork(int timeout);
+  int test(CephContext* cct);
+  int test_with_fork(CephContext* cct, int timeout);
 
   int compare(CrushWrapper& other);
 };
index abdaa983868cb294ecbb2064cf1135da780a89fa..a806c8d8085ffe69844de632f98adbc95eb90190 100644 (file)
@@ -8021,7 +8021,8 @@ int OSDMonitor::prepare_new_pool(string& name,
     tester.set_rule(crush_rule);
     tester.set_num_rep(size);
     auto start = ceph::coarse_mono_clock::now();
-    r = tester.test_with_fork(g_conf()->mon_lease);
+    r = tester.test_with_fork(cct, g_conf()->mon_lease);
+    dout(10) << __func__ << " crush test_with_fork tester created " << dendl;
     auto duration = ceph::coarse_mono_clock::now() - start;
     if (r < 0) {
       dout(10) << "tester.test_with_fork returns " << r
@@ -9999,7 +10000,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
       tester.set_max_x(50);
       tester.set_num_rep(3);  // arbitrary
       auto start = ceph::coarse_mono_clock::now();
-      int r = tester.test_with_fork(g_conf()->mon_lease);
+      int r = tester.test_with_fork(cct, g_conf()->mon_lease);
       auto duration = ceph::coarse_mono_clock::now() - start;
       if (r < 0) {
        dout(10) << " tester.test_with_fork returns " << r
index a7a63d1c45ab31bd2e57502eb7f7a1df2801fa2d..acfc9a3c6f76824eb3484319e9f19af5e4bed860 100644 (file)
@@ -1289,7 +1289,7 @@ int main(int argc, const char **argv)
        tester.get_output_utilization())
       tester.set_output_statistics(true);
 
-    int r = tester.test();
+    int r = tester.test(cct->get());
     if (r < 0)
       return EXIT_FAILURE;
   }