MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mt_thr_config.hpp
1 /*
2  Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef THRConfig_H
19 #define THRConfig_H
20 
21 struct NdbThread;
22 #include <Vector.hpp>
23 #include <SparseBitmask.hpp>
24 #include <BaseString.hpp>
25 
36 class THRConfig
37 {
38 public:
39  enum T_Type
40  {
41  T_MAIN = 0, /* DIH/QMGR/TC/SPJ etc */
42  T_LDM = 1, /* LQH/ACC/TUP/TUX etc */
43  T_RECV = 2, /* CMVMI */
44  T_REP = 3, /* SUMA */
45  T_IO = 4, /* FS, SocketServer etc */
46 
47  T_END = 5
48  };
49 
50  THRConfig();
51  ~THRConfig();
52 
53  // NOTE: needs to be called before do_parse
54  int setLockExecuteThreadToCPU(const char * val);
55  int setLockIoThreadsToCPU(unsigned val);
56 
57  int do_parse(const char * ThreadConfig);
58  int do_parse(unsigned MaxNoOfExecutionThreads,
59  unsigned __ndbmt_lqh_workers,
60  unsigned __ndbmt_classic);
61 
62  const char * getConfigString();
63 
64  const char * getErrorMessage() const;
65  const char * getInfoMessage() const;
66 
67  Uint32 getThreadCount() const; // Don't count FS/IO thread
68  Uint32 getThreadCount(T_Type) const;
69  Uint32 getMtClassic() const { return m_classic; }
70 protected:
71  struct T_Thread
72  {
73  unsigned m_type;
74  unsigned m_no; // within type
75  enum BType { B_UNBOUND, B_CPU_BOUND, B_CPUSET_BOUND } m_bind_type;
76  unsigned m_bind_no; // cpu_no/cpuset_no
77  };
78  bool m_classic;
79  SparseBitmask m_LockExecuteThreadToCPU;
80  SparseBitmask m_LockIoThreadsToCPU;
81  Vector<SparseBitmask> m_cpu_sets;
82  Vector<T_Thread> m_threads[T_END];
83 
84  BaseString m_err_msg;
85  BaseString m_info_msg;
86  BaseString m_cfg_string;
87  BaseString m_print_string;
88 
89  void add(T_Type);
90  Uint32 find_type(char *&);
91  int find_spec(char *&, T_Type);
92  int find_next(char *&);
93 
94  unsigned createCpuSet(const SparseBitmask&);
95  int do_bindings();
96  int do_validate();
97 
98  unsigned count_unbound(const Vector<T_Thread>& vec) const;
99  void bind_unbound(Vector<T_Thread> & vec, unsigned cpu);
100 
101 public:
102  struct Entries
103  {
104  const char * m_name;
105  unsigned m_type;
106  unsigned m_min_cnt;
107  unsigned m_max_cnt;
108  };
109 
110  struct Param
111  {
112  const char * name;
113  enum { S_UNSIGNED, S_BITMASK } type;
114  };
115 };
116 
122 {
123 public:
124  int create_cpusets();
125 
126  void appendInfo(BaseString&, const unsigned short list[], unsigned cnt) const;
127  int do_bind(NdbThread*, const unsigned short list[], unsigned cnt);
128  int do_bind_io(NdbThread*);
129 
130 protected:
131  const T_Thread* find_thread(const unsigned short list[], unsigned cnt) const;
132 };
133 
134 #endif // IPCConfig_H