Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | /******************************************************************************* * * Module Name: dbstats - Generation and display of ACPI table statistics * $Revision: 47 $ * ******************************************************************************/ /* * Copyright (C) 2000, 2001 R. Byron Moore * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <acpi.h> #include <acdebug.h> #include <amlcode.h> #include <acparser.h> #include <acnamesp.h> #ifdef ENABLE_DEBUGGER #define _COMPONENT ACPI_DEBUGGER MODULE_NAME ("dbstats") /* * Statistics subcommands */ ARGUMENT_INFO acpi_db_stat_types [] = { {"ALLOCATIONS"}, {"OBJECTS"}, {"MEMORY"}, {"MISC"}, {"TABLES"}, {"SIZES"}, {"STACK"}, {NULL} /* Must be null terminated */ }; #define CMD_ALLOCATIONS 0 #define CMD_OBJECTS 1 #define CMD_MEMORY 2 #define CMD_MISC 3 #define CMD_TABLES 4 #define CMD_SIZES 5 #define CMD_STACK 6 /******************************************************************************* * * FUNCTION: Acpi_db_enumerate_object * * PARAMETERS: Obj_desc - Object to be counted * * RETURN: None * * DESCRIPTION: Add this object to the global counts, by object type. * Recursively handles subobjects and packages. * * [TBD] Restructure - remove recursion. * ******************************************************************************/ void acpi_db_enumerate_object ( acpi_operand_object *obj_desc) { u32 type; u32 i; if (!obj_desc) { return; } /* Enumerate this object first */ acpi_gbl_num_objects++; type = obj_desc->common.type; if (type > INTERNAL_TYPE_NODE_MAX) { acpi_gbl_obj_type_count_misc++; } else { acpi_gbl_obj_type_count [type]++; } /* Count the sub-objects */ switch (type) { case ACPI_TYPE_PACKAGE: for (i = 0; i< obj_desc->package.count; i++) { acpi_db_enumerate_object (obj_desc->package.elements[i]); } break; case ACPI_TYPE_DEVICE: acpi_db_enumerate_object (obj_desc->device.sys_handler); acpi_db_enumerate_object (obj_desc->device.drv_handler); acpi_db_enumerate_object (obj_desc->device.addr_handler); break; case ACPI_TYPE_REGION: acpi_db_enumerate_object (obj_desc->region.addr_handler); break; case ACPI_TYPE_POWER: acpi_db_enumerate_object (obj_desc->power_resource.sys_handler); acpi_db_enumerate_object (obj_desc->power_resource.drv_handler); break; case ACPI_TYPE_PROCESSOR: acpi_db_enumerate_object (obj_desc->processor.sys_handler); acpi_db_enumerate_object (obj_desc->processor.drv_handler); acpi_db_enumerate_object (obj_desc->processor.addr_handler); break; case ACPI_TYPE_THERMAL: acpi_db_enumerate_object (obj_desc->thermal_zone.sys_handler); acpi_db_enumerate_object (obj_desc->thermal_zone.drv_handler); acpi_db_enumerate_object (obj_desc->thermal_zone.addr_handler); break; } } #ifndef PARSER_ONLY /******************************************************************************* * * FUNCTION: Acpi_db_classify_one_object * * PARAMETERS: Callback for Walk_namespace * * RETURN: Status * * DESCRIPTION: Enumerate both the object descriptor (including subobjects) and * the parent namespace node. * ******************************************************************************/ acpi_status acpi_db_classify_one_object ( acpi_handle obj_handle, u32 nesting_level, void *context, void **return_value) { acpi_namespace_node *node; acpi_operand_object *obj_desc; u32 type; acpi_gbl_num_nodes++; node = (acpi_namespace_node *) obj_handle; obj_desc = ((acpi_namespace_node *) obj_handle)->object; acpi_db_enumerate_object (obj_desc); type = node->type; if (type > INTERNAL_TYPE_NODE_MAX) { acpi_gbl_node_type_count_misc++; } else { acpi_gbl_node_type_count [type]++; } return AE_OK; /* TBD: These need to be counted during the initial parsing phase */ /* if (Acpi_ps_is_named_op (Op->Opcode)) { Num_nodes++; } if (Is_method) { Num_method_elements++; } Num_grammar_elements++; Op = Acpi_ps_get_depth_next (Root, Op); Size_of_parse_tree = (Num_grammar_elements - Num_method_elements) * (u32) sizeof (acpi_parse_object); Size_of_method_trees = Num_method_elements * (u32) sizeof (acpi_parse_object); Size_of_node_entries = Num_nodes * (u32) sizeof (acpi_namespace_node); Size_of_acpi_objects = Num_nodes * (u32) sizeof (acpi_operand_object); */ } /******************************************************************************* * * FUNCTION: Acpi_db_count_namespace_objects * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Count and classify the entire namespace, including all * namespace nodes and attached objects. * ******************************************************************************/ acpi_status acpi_db_count_namespace_objects ( void) { u32 i; acpi_gbl_num_nodes = 0; acpi_gbl_num_objects = 0; acpi_gbl_obj_type_count_misc = 0; for (i = 0; i < (INTERNAL_TYPE_NODE_MAX -1); i++) { acpi_gbl_obj_type_count [i] = 0; acpi_gbl_node_type_count [i] = 0; } acpi_ns_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, FALSE, acpi_db_classify_one_object, NULL, NULL); return (AE_OK); } #endif /******************************************************************************* * * FUNCTION: Acpi_db_display_statistics * * PARAMETERS: Type_arg - Subcommand * * RETURN: Status * * DESCRIPTION: Display various statistics * ******************************************************************************/ acpi_status acpi_db_display_statistics ( NATIVE_CHAR *type_arg) { u32 i; u32 type; u32 outstanding; u32 size; if (!acpi_gbl_DSDT) { acpi_os_printf ("*** Warning: There is no DSDT loaded\n"); } if (!type_arg) { acpi_os_printf ("The following subcommands are available:\n ALLOCATIONS, OBJECTS, MEMORY, MISC, SIZES, TABLES\n"); return (AE_OK); } STRUPR (type_arg); type = acpi_db_match_argument (type_arg, acpi_db_stat_types); if (type == (u32) -1) { acpi_os_printf ("Invalid or unsupported argument\n"); return (AE_OK); } switch (type) { #ifndef PARSER_ONLY case CMD_ALLOCATIONS: #ifdef ACPI_DBG_TRACK_ALLOCATIONS acpi_ut_dump_allocation_info (); #endif break; #endif case CMD_TABLES: acpi_os_printf ("ACPI Table Information:\n\n"); if (acpi_gbl_DSDT) { acpi_os_printf ("DSDT Length:................% 7ld (%X)\n", acpi_gbl_DSDT->length, acpi_gbl_DSDT->length); } break; case CMD_OBJECTS: #ifndef PARSER_ONLY acpi_db_count_namespace_objects (); acpi_os_printf ("\n_objects defined in the current namespace:\n\n"); acpi_os_printf ("%16.16s % 10.10s % 10.10s\n", "ACPI_TYPE", "NODES", "OBJECTS"); for (i = 0; i < INTERNAL_TYPE_NODE_MAX; i++) { acpi_os_printf ("%16.16s % 10ld% 10ld\n", acpi_ut_get_type_name (i), acpi_gbl_node_type_count [i], acpi_gbl_obj_type_count [i]); } acpi_os_printf ("%16.16s % 10ld% 10ld\n", "Misc/Unknown", acpi_gbl_node_type_count_misc, acpi_gbl_obj_type_count_misc); acpi_os_printf ("%16.16s % 10ld% 10ld\n", "TOTALS:", acpi_gbl_num_nodes, acpi_gbl_num_objects); #endif break; case CMD_MEMORY: #ifdef ACPI_DBG_TRACK_ALLOCATIONS acpi_os_printf ("\n----Object and Cache Statistics---------------------------------------------\n"); for (i = 0; i < ACPI_NUM_MEM_LISTS; i++) { acpi_os_printf ("\n%s\n", acpi_gbl_memory_lists[i].list_name); if (acpi_gbl_memory_lists[i].max_cache_depth > 0) { acpi_os_printf (" Cache: [Depth Max Avail Size] % 7d % 7d % 7d % 7d B\n", acpi_gbl_memory_lists[i].cache_depth, acpi_gbl_memory_lists[i].max_cache_depth, acpi_gbl_memory_lists[i].max_cache_depth - acpi_gbl_memory_lists[i].cache_depth, (acpi_gbl_memory_lists[i].cache_depth * acpi_gbl_memory_lists[i].object_size)); acpi_os_printf (" Cache: [Requests Hits Misses Obj_size] % 7d % 7d % 7d % 7d B\n", acpi_gbl_memory_lists[i].cache_requests, acpi_gbl_memory_lists[i].cache_hits, acpi_gbl_memory_lists[i].cache_requests - acpi_gbl_memory_lists[i].cache_hits, acpi_gbl_memory_lists[i].object_size); } outstanding = acpi_gbl_memory_lists[i].total_allocated - acpi_gbl_memory_lists[i].total_freed - acpi_gbl_memory_lists[i].cache_depth; if (acpi_gbl_memory_lists[i].object_size) { size = ROUND_UP_TO_1_k (outstanding * acpi_gbl_memory_lists[i].object_size); } else { size = ROUND_UP_TO_1_k (acpi_gbl_memory_lists[i].current_total_size); } acpi_os_printf (" Mem: [Alloc Free Outstanding Size] % 7d % 7d % 7d % 7d Kb\n", acpi_gbl_memory_lists[i].total_allocated, acpi_gbl_memory_lists[i].total_freed, outstanding, size); } #endif break; case CMD_MISC: acpi_os_printf ("\n_miscellaneous Statistics:\n\n"); acpi_os_printf ("Calls to Acpi_ps_find:.. ........% 7ld\n", acpi_gbl_ps_find_count); acpi_os_printf ("Calls to Acpi_ns_lookup:..........% 7ld\n", acpi_gbl_ns_lookup_count); acpi_os_printf ("\n"); acpi_os_printf ("Mutex usage:\n\n"); for (i = 0; i < NUM_MTX; i++) { acpi_os_printf ("%-28s: % 7ld\n", acpi_ut_get_mutex_name (i), acpi_gbl_acpi_mutex_info[i].use_count); } break; case CMD_SIZES: acpi_os_printf ("\n_internal object sizes:\n\n"); acpi_os_printf ("Common %3d\n", sizeof (ACPI_OBJECT_COMMON)); acpi_os_printf ("Number %3d\n", sizeof (ACPI_OBJECT_INTEGER)); acpi_os_printf ("String %3d\n", sizeof (ACPI_OBJECT_STRING)); acpi_os_printf ("Buffer %3d\n", sizeof (ACPI_OBJECT_BUFFER)); acpi_os_printf ("Package %3d\n", sizeof (ACPI_OBJECT_PACKAGE)); acpi_os_printf ("Buffer_field %3d\n", sizeof (ACPI_OBJECT_BUFFER_FIELD)); acpi_os_printf ("Device %3d\n", sizeof (ACPI_OBJECT_DEVICE)); acpi_os_printf ("Event %3d\n", sizeof (ACPI_OBJECT_EVENT)); acpi_os_printf ("Method %3d\n", sizeof (ACPI_OBJECT_METHOD)); acpi_os_printf ("Mutex %3d\n", sizeof (ACPI_OBJECT_MUTEX)); acpi_os_printf ("Region %3d\n", sizeof (ACPI_OBJECT_REGION)); acpi_os_printf ("Power_resource %3d\n", sizeof (ACPI_OBJECT_POWER_RESOURCE)); acpi_os_printf ("Processor %3d\n", sizeof (ACPI_OBJECT_PROCESSOR)); acpi_os_printf ("Thermal_zone %3d\n", sizeof (ACPI_OBJECT_THERMAL_ZONE)); acpi_os_printf ("Region_field %3d\n", sizeof (ACPI_OBJECT_REGION_FIELD)); acpi_os_printf ("Bank_field %3d\n", sizeof (ACPI_OBJECT_BANK_FIELD)); acpi_os_printf ("Index_field %3d\n", sizeof (ACPI_OBJECT_INDEX_FIELD)); acpi_os_printf ("Reference %3d\n", sizeof (ACPI_OBJECT_REFERENCE)); acpi_os_printf ("Notify_handler %3d\n", sizeof (ACPI_OBJECT_NOTIFY_HANDLER)); acpi_os_printf ("Addr_handler %3d\n", sizeof (ACPI_OBJECT_ADDR_HANDLER)); acpi_os_printf ("Extra %3d\n", sizeof (ACPI_OBJECT_EXTRA)); acpi_os_printf ("\n"); acpi_os_printf ("Parse_object %3d\n", sizeof (acpi_parse_object)); acpi_os_printf ("Parse2_object %3d\n", sizeof (acpi_parse2_object)); acpi_os_printf ("Operand_object %3d\n", sizeof (acpi_operand_object)); acpi_os_printf ("Namespace_node %3d\n", sizeof (acpi_namespace_node)); break; case CMD_STACK: size = acpi_gbl_entry_stack_pointer - acpi_gbl_lowest_stack_pointer; acpi_os_printf ("\n_subsystem Stack Usage:\n\n"); acpi_os_printf ("Entry Stack Pointer %X\n", acpi_gbl_entry_stack_pointer); acpi_os_printf ("Lowest Stack Pointer %X\n", acpi_gbl_lowest_stack_pointer); acpi_os_printf ("Stack Use %X (%d)\n", size, size); acpi_os_printf ("Deepest Procedure Nesting %d\n", acpi_gbl_deepest_nesting); break; } acpi_os_printf ("\n"); return (AE_OK); } #endif /* ENABLE_DEBUGGER */ |