Print this page
update to acpica-unix2-20130927
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/utilities/uttrack.c
+++ new/usr/src/common/acpica/components/utilities/uttrack.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: uttrack - Memory allocation tracking routines (debug only)
4 4 *
5 5 *****************************************************************************/
6 6
7 7 /*
8 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2013, Intel Corp.
9 9 * All rights reserved.
10 10 *
11 11 * Redistribution and use in source and binary forms, with or without
12 12 * modification, are permitted provided that the following conditions
13 13 * are met:
14 14 * 1. Redistributions of source code must retain the above copyright
15 15 * notice, this list of conditions, and the following disclaimer,
16 16 * without modification.
17 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 18 * substantially similar to the "NO WARRANTY" disclaimer below
19 19 * ("Disclaimer") and any redistribution must be conditioned upon
20 20 * including a substantially similar Disclaimer requirement for further
21 21 * binary redistribution.
22 22 * 3. Neither the names of the above-listed copyright holders nor the names
23 23 * of any contributors may be used to endorse or promote products derived
24 24 * from this software without specific prior written permission.
25 25 *
26 26 * Alternatively, this software may be distributed under the terms of the
27 27 * GNU General Public License ("GPL") version 2 as published by the Free
28 28 * Software Foundation.
29 29 *
30 30 * NO WARRANTY
31 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
38 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 41 * POSSIBILITY OF SUCH DAMAGES.
42 42 */
43 43
44 44 /*
45 45 * These procedures are used for tracking memory leaks in the subsystem, and
46 46 * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set.
47 47 *
48 - * Each memory allocation is tracked via a doubly linked list. Each
48 + * Each memory allocation is tracked via a doubly linked list. Each
49 49 * element contains the caller's component, module name, function name, and
50 - * line number. AcpiUtAllocate and AcpiUtAllocateZeroed call
50 + * line number. AcpiUtAllocate and AcpiUtAllocateZeroed call
51 51 * AcpiUtTrackAllocation to add an element to the list; deletion
52 52 * occurs in the body of AcpiUtFree.
53 53 */
54 54
55 55 #define __UTTRACK_C__
56 56
57 57 #include "acpi.h"
58 58 #include "accommon.h"
59 59
60 60 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
61 61
62 62 #define _COMPONENT ACPI_UTILITIES
63 63 ACPI_MODULE_NAME ("uttrack")
64 64
65 +
65 66 /* Local prototypes */
66 67
67 68 static ACPI_DEBUG_MEM_BLOCK *
68 69 AcpiUtFindAllocation (
69 - void *Allocation);
70 + ACPI_DEBUG_MEM_BLOCK *Allocation);
70 71
71 72 static ACPI_STATUS
72 73 AcpiUtTrackAllocation (
73 74 ACPI_DEBUG_MEM_BLOCK *Address,
74 75 ACPI_SIZE Size,
75 76 UINT8 AllocType,
76 77 UINT32 Component,
77 78 const char *Module,
78 79 UINT32 Line);
79 80
80 81 static ACPI_STATUS
81 82 AcpiUtRemoveAllocation (
82 83 ACPI_DEBUG_MEM_BLOCK *Address,
83 84 UINT32 Component,
84 85 const char *Module,
85 86 UINT32 Line);
86 87
87 88
88 89 /*******************************************************************************
89 90 *
90 91 * FUNCTION: AcpiUtCreateList
91 92 *
92 93 * PARAMETERS: CacheName - Ascii name for the cache
93 94 * ObjectSize - Size of each cached object
94 95 * ReturnCache - Where the new cache object is returned
95 96 *
96 97 * RETURN: Status
97 98 *
98 99 * DESCRIPTION: Create a local memory list for tracking purposed
99 100 *
100 101 ******************************************************************************/
101 102
102 103 ACPI_STATUS
103 104 AcpiUtCreateList (
104 105 char *ListName,
105 106 UINT16 ObjectSize,
106 107 ACPI_MEMORY_LIST **ReturnCache)
107 108 {
108 109 ACPI_MEMORY_LIST *Cache;
109 110
110 111
111 112 Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST));
112 113 if (!Cache)
113 114 {
114 115 return (AE_NO_MEMORY);
115 116 }
116 117
117 118 ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST));
118 119
119 120 Cache->ListName = ListName;
120 121 Cache->ObjectSize = ObjectSize;
121 122
122 123 *ReturnCache = Cache;
123 124 return (AE_OK);
124 125 }
125 126
126 127
127 128 /*******************************************************************************
128 129 *
129 130 * FUNCTION: AcpiUtAllocateAndTrack
130 131 *
131 132 * PARAMETERS: Size - Size of the allocation
132 133 * Component - Component type of caller
133 134 * Module - Source file name of caller
134 135 * Line - Line number of caller
135 136 *
136 137 * RETURN: Address of the allocated memory on success, NULL on failure.
137 138 *
138 139 * DESCRIPTION: The subsystem's equivalent of malloc.
139 140 *
140 141 ******************************************************************************/
141 142
142 143 void *
↓ open down ↓ |
63 lines elided |
↑ open up ↑ |
143 144 AcpiUtAllocateAndTrack (
144 145 ACPI_SIZE Size,
145 146 UINT32 Component,
146 147 const char *Module,
147 148 UINT32 Line)
148 149 {
149 150 ACPI_DEBUG_MEM_BLOCK *Allocation;
150 151 ACPI_STATUS Status;
151 152
152 153
153 - Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER),
154 - Component, Module, Line);
154 + /* Check for an inadvertent size of zero bytes */
155 +
156 + if (!Size)
157 + {
158 + ACPI_WARNING ((Module, Line,
159 + "Attempt to allocate zero bytes, allocating 1 byte"));
160 + Size = 1;
161 + }
162 +
163 + Allocation = AcpiOsAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER));
155 164 if (!Allocation)
156 165 {
166 + /* Report allocation error */
167 +
168 + ACPI_WARNING ((Module, Line,
169 + "Could not allocate size %u", (UINT32) Size));
170 +
157 171 return (NULL);
158 172 }
159 173
160 174 Status = AcpiUtTrackAllocation (Allocation, Size,
161 175 ACPI_MEM_MALLOC, Component, Module, Line);
162 176 if (ACPI_FAILURE (Status))
163 177 {
164 178 AcpiOsFree (Allocation);
165 179 return (NULL);
166 180 }
167 181
168 182 AcpiGbl_GlobalList->TotalAllocated++;
169 183 AcpiGbl_GlobalList->TotalSize += (UINT32) Size;
170 184 AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size;
171 185 if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied)
172 186 {
173 187 AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize;
174 188 }
175 189
176 190 return ((void *) &Allocation->UserSpace);
177 191 }
178 192
179 193
180 194 /*******************************************************************************
181 195 *
182 196 * FUNCTION: AcpiUtAllocateZeroedAndTrack
183 197 *
184 198 * PARAMETERS: Size - Size of the allocation
185 199 * Component - Component type of caller
186 200 * Module - Source file name of caller
187 201 * Line - Line number of caller
188 202 *
189 203 * RETURN: Address of the allocated memory on success, NULL on failure.
190 204 *
191 205 * DESCRIPTION: Subsystem equivalent of calloc.
192 206 *
193 207 ******************************************************************************/
194 208
195 209 void *
↓ open down ↓ |
29 lines elided |
↑ open up ↑ |
196 210 AcpiUtAllocateZeroedAndTrack (
197 211 ACPI_SIZE Size,
198 212 UINT32 Component,
199 213 const char *Module,
200 214 UINT32 Line)
201 215 {
202 216 ACPI_DEBUG_MEM_BLOCK *Allocation;
203 217 ACPI_STATUS Status;
204 218
205 219
206 - Allocation = AcpiUtAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER),
207 - Component, Module, Line);
220 + /* Check for an inadvertent size of zero bytes */
221 +
222 + if (!Size)
223 + {
224 + ACPI_WARNING ((Module, Line,
225 + "Attempt to allocate zero bytes, allocating 1 byte"));
226 + Size = 1;
227 + }
228 +
229 + Allocation = AcpiOsAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER));
208 230 if (!Allocation)
209 231 {
210 232 /* Report allocation error */
211 233
212 234 ACPI_ERROR ((Module, Line,
213 235 "Could not allocate size %u", (UINT32) Size));
214 236 return (NULL);
215 237 }
216 238
217 239 Status = AcpiUtTrackAllocation (Allocation, Size,
218 240 ACPI_MEM_CALLOC, Component, Module, Line);
219 241 if (ACPI_FAILURE (Status))
220 242 {
221 243 AcpiOsFree (Allocation);
222 244 return (NULL);
223 245 }
224 246
225 247 AcpiGbl_GlobalList->TotalAllocated++;
226 248 AcpiGbl_GlobalList->TotalSize += (UINT32) Size;
227 249 AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size;
228 250 if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied)
229 251 {
230 252 AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize;
231 253 }
232 254
233 255 return ((void *) &Allocation->UserSpace);
234 256 }
235 257
236 258
237 259 /*******************************************************************************
238 260 *
239 261 * FUNCTION: AcpiUtFreeAndTrack
240 262 *
241 263 * PARAMETERS: Allocation - Address of the memory to deallocate
242 264 * Component - Component type of caller
243 265 * Module - Source file name of caller
244 266 * Line - Line number of caller
245 267 *
246 268 * RETURN: None
247 269 *
248 270 * DESCRIPTION: Frees the memory at Allocation
249 271 *
250 272 ******************************************************************************/
251 273
252 274 void
253 275 AcpiUtFreeAndTrack (
254 276 void *Allocation,
255 277 UINT32 Component,
256 278 const char *Module,
257 279 UINT32 Line)
258 280 {
259 281 ACPI_DEBUG_MEM_BLOCK *DebugBlock;
260 282 ACPI_STATUS Status;
261 283
262 284
263 285 ACPI_FUNCTION_TRACE_PTR (UtFree, Allocation);
264 286
265 287
266 288 if (NULL == Allocation)
267 289 {
268 290 ACPI_ERROR ((Module, Line,
269 291 "Attempt to delete a NULL address"));
270 292
271 293 return_VOID;
272 294 }
273 295
274 296 DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK,
275 297 (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER)));
276 298
277 299 AcpiGbl_GlobalList->TotalFreed++;
278 300 AcpiGbl_GlobalList->CurrentTotalSize -= DebugBlock->Size;
279 301
280 302 Status = AcpiUtRemoveAllocation (DebugBlock,
281 303 Component, Module, Line);
282 304 if (ACPI_FAILURE (Status))
283 305 {
284 306 ACPI_EXCEPTION ((AE_INFO, Status, "Could not free memory"));
285 307 }
286 308
287 309 AcpiOsFree (DebugBlock);
288 310 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation));
↓ open down ↓ |
71 lines elided |
↑ open up ↑ |
289 311 return_VOID;
290 312 }
291 313
292 314
293 315 /*******************************************************************************
294 316 *
295 317 * FUNCTION: AcpiUtFindAllocation
296 318 *
297 319 * PARAMETERS: Allocation - Address of allocated memory
298 320 *
299 - * RETURN: A list element if found; NULL otherwise.
321 + * RETURN: Three cases:
322 + * 1) List is empty, NULL is returned.
323 + * 2) Element was found. Returns Allocation parameter.
324 + * 3) Element was not found. Returns position where it should be
325 + * inserted into the list.
300 326 *
301 327 * DESCRIPTION: Searches for an element in the global allocation tracking list.
328 + * If the element is not found, returns the location within the
329 + * list where the element should be inserted.
302 330 *
331 + * Note: The list is ordered by larger-to-smaller addresses.
332 + *
333 + * This global list is used to detect memory leaks in ACPICA as
334 + * well as other issues such as an attempt to release the same
335 + * internal object more than once. Although expensive as far
336 + * as cpu time, this list is much more helpful for finding these
337 + * types of issues than using memory leak detectors outside of
338 + * the ACPICA code.
339 + *
303 340 ******************************************************************************/
304 341
305 342 static ACPI_DEBUG_MEM_BLOCK *
306 343 AcpiUtFindAllocation (
307 - void *Allocation)
344 + ACPI_DEBUG_MEM_BLOCK *Allocation)
308 345 {
309 346 ACPI_DEBUG_MEM_BLOCK *Element;
310 347
311 348
312 - ACPI_FUNCTION_ENTRY ();
313 -
314 -
315 349 Element = AcpiGbl_GlobalList->ListHead;
350 + if (!Element)
351 + {
352 + return (NULL);
353 + }
316 354
317 - /* Search for the address. */
318 -
319 - while (Element)
355 + /*
356 + * Search for the address.
357 + *
358 + * Note: List is ordered by larger-to-smaller addresses, on the
359 + * assumption that a new allocation usually has a larger address
360 + * than previous allocations.
361 + */
362 + while (Element > Allocation)
320 363 {
321 - if (Element == Allocation)
364 + /* Check for end-of-list */
365 +
366 + if (!Element->Next)
322 367 {
323 368 return (Element);
324 369 }
325 370
326 371 Element = Element->Next;
327 372 }
328 373
329 - return (NULL);
374 + if (Element == Allocation)
375 + {
376 + return (Element);
377 + }
378 +
379 + return (Element->Previous);
330 380 }
331 381
332 382
333 383 /*******************************************************************************
334 384 *
335 385 * FUNCTION: AcpiUtTrackAllocation
336 386 *
337 387 * PARAMETERS: Allocation - Address of allocated memory
338 388 * Size - Size of the allocation
339 389 * AllocType - MEM_MALLOC or MEM_CALLOC
340 390 * Component - Component type of caller
341 391 * Module - Source file name of caller
342 392 * Line - Line number of caller
343 393 *
344 - * RETURN: None.
394 + * RETURN: Status
345 395 *
346 396 * DESCRIPTION: Inserts an element into the global allocation tracking list.
347 397 *
348 398 ******************************************************************************/
349 399
350 400 static ACPI_STATUS
351 401 AcpiUtTrackAllocation (
352 402 ACPI_DEBUG_MEM_BLOCK *Allocation,
353 403 ACPI_SIZE Size,
354 404 UINT8 AllocType,
355 405 UINT32 Component,
356 406 const char *Module,
357 407 UINT32 Line)
358 408 {
359 409 ACPI_MEMORY_LIST *MemList;
360 410 ACPI_DEBUG_MEM_BLOCK *Element;
361 411 ACPI_STATUS Status = AE_OK;
362 412
363 413
364 414 ACPI_FUNCTION_TRACE_PTR (UtTrackAllocation, Allocation);
365 415
366 416
367 417 if (AcpiGbl_DisableMemTracking)
368 418 {
369 419 return_ACPI_STATUS (AE_OK);
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
370 420 }
371 421
372 422 MemList = AcpiGbl_GlobalList;
373 423 Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
374 424 if (ACPI_FAILURE (Status))
375 425 {
376 426 return_ACPI_STATUS (Status);
377 427 }
378 428
379 429 /*
380 - * Search list for this address to make sure it is not already on the list.
381 - * This will catch several kinds of problems.
430 + * Search the global list for this address to make sure it is not
431 + * already present. This will catch several kinds of problems.
382 432 */
383 433 Element = AcpiUtFindAllocation (Allocation);
384 - if (Element)
434 + if (Element == Allocation)
385 435 {
386 436 ACPI_ERROR ((AE_INFO,
387 - "UtTrackAllocation: Allocation already present in list! (%p)",
437 + "UtTrackAllocation: Allocation (%p) already present in global list!",
388 438 Allocation));
389 -
390 - ACPI_ERROR ((AE_INFO, "Element %p Address %p",
391 - Element, Allocation));
392 -
393 439 goto UnlockAndExit;
394 440 }
395 441
396 - /* Fill in the instance data. */
442 + /* Fill in the instance data */
397 443
398 444 Allocation->Size = (UINT32) Size;
399 445 Allocation->AllocType = AllocType;
400 446 Allocation->Component = Component;
401 447 Allocation->Line = Line;
402 448
403 449 ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME);
404 450 Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0;
405 451
406 - /* Insert at list head */
407 -
408 - if (MemList->ListHead)
452 + if (!Element)
409 453 {
410 - ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation;
454 + /* Insert at list head */
455 +
456 + if (MemList->ListHead)
457 + {
458 + ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation;
459 + }
460 +
461 + Allocation->Next = MemList->ListHead;
462 + Allocation->Previous = NULL;
463 +
464 + MemList->ListHead = Allocation;
411 465 }
466 + else
467 + {
468 + /* Insert after element */
412 469
413 - Allocation->Next = MemList->ListHead;
414 - Allocation->Previous = NULL;
470 + Allocation->Next = Element->Next;
471 + Allocation->Previous = Element;
415 472
416 - MemList->ListHead = Allocation;
473 + if (Element->Next)
474 + {
475 + (Element->Next)->Previous = Allocation;
476 + }
417 477
478 + Element->Next = Allocation;
479 + }
418 480
481 +
419 482 UnlockAndExit:
420 483 Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
421 484 return_ACPI_STATUS (Status);
422 485 }
423 486
424 487
425 488 /*******************************************************************************
426 489 *
427 490 * FUNCTION: AcpiUtRemoveAllocation
428 491 *
429 492 * PARAMETERS: Allocation - Address of allocated memory
430 493 * Component - Component type of caller
431 494 * Module - Source file name of caller
432 495 * Line - Line number of caller
433 496 *
434 - * RETURN:
497 + * RETURN: Status
435 498 *
436 499 * DESCRIPTION: Deletes an element from the global allocation tracking list.
437 500 *
438 501 ******************************************************************************/
439 502
440 503 static ACPI_STATUS
441 504 AcpiUtRemoveAllocation (
442 505 ACPI_DEBUG_MEM_BLOCK *Allocation,
443 506 UINT32 Component,
444 507 const char *Module,
445 508 UINT32 Line)
446 509 {
447 510 ACPI_MEMORY_LIST *MemList;
448 511 ACPI_STATUS Status;
449 512
450 513
451 - ACPI_FUNCTION_TRACE (UtRemoveAllocation);
514 + ACPI_FUNCTION_NAME (UtRemoveAllocation);
452 515
453 516
454 517 if (AcpiGbl_DisableMemTracking)
455 518 {
456 - return_ACPI_STATUS (AE_OK);
519 + return (AE_OK);
457 520 }
458 521
459 522 MemList = AcpiGbl_GlobalList;
460 523 if (NULL == MemList->ListHead)
461 524 {
462 525 /* No allocations! */
463 526
464 527 ACPI_ERROR ((Module, Line,
465 528 "Empty allocation list, nothing to free!"));
466 529
467 - return_ACPI_STATUS (AE_OK);
530 + return (AE_OK);
468 531 }
469 532
470 533 Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
471 534 if (ACPI_FAILURE (Status))
472 535 {
473 - return_ACPI_STATUS (Status);
536 + return (Status);
474 537 }
475 538
476 539 /* Unlink */
477 540
478 541 if (Allocation->Previous)
479 542 {
480 543 (Allocation->Previous)->Next = Allocation->Next;
481 544 }
482 545 else
483 546 {
484 547 MemList->ListHead = Allocation->Next;
485 548 }
486 549
487 550 if (Allocation->Next)
488 551 {
489 552 (Allocation->Next)->Previous = Allocation->Previous;
490 553 }
491 554
555 + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing %p, size 0%X\n",
556 + &Allocation->UserSpace, Allocation->Size));
557 +
492 558 /* Mark the segment as deleted */
493 559
494 560 ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size);
495 561
496 - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n",
497 - Allocation->Size));
498 -
499 562 Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
500 - return_ACPI_STATUS (Status);
563 + return (Status);
501 564 }
502 565
503 566
504 567 /*******************************************************************************
505 568 *
506 569 * FUNCTION: AcpiUtDumpAllocationInfo
507 570 *
508 - * PARAMETERS:
571 + * PARAMETERS: None
509 572 *
510 573 * RETURN: None
511 574 *
512 575 * DESCRIPTION: Print some info about the outstanding allocations.
513 576 *
514 577 ******************************************************************************/
515 578
516 579 void
517 580 AcpiUtDumpAllocationInfo (
518 581 void)
519 582 {
520 583 /*
521 584 ACPI_MEMORY_LIST *MemList;
522 585 */
523 586
524 587 ACPI_FUNCTION_TRACE (UtDumpAllocationInfo);
525 588
526 589 /*
527 590 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
528 591 ("%30s: %4d (%3d Kb)\n", "Current allocations",
529 592 MemList->CurrentCount,
530 593 ROUND_UP_TO_1K (MemList->CurrentSize)));
531 594
532 595 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
533 596 ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",
534 597 MemList->MaxConcurrentCount,
535 598 ROUND_UP_TO_1K (MemList->MaxConcurrentSize)));
536 599
537 600
538 601 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
539 602 ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
540 603 RunningObjectCount,
541 604 ROUND_UP_TO_1K (RunningObjectSize)));
542 605
543 606 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
544 607 ("%30s: %4d (%3d Kb)\n", "Total (all) allocations",
545 608 RunningAllocCount,
546 609 ROUND_UP_TO_1K (RunningAllocSize)));
547 610
548 611
549 612 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
550 613 ("%30s: %4d (%3d Kb)\n", "Current Nodes",
551 614 AcpiGbl_CurrentNodeCount,
552 615 ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize)));
553 616
554 617 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
555 618 ("%30s: %4d (%3d Kb)\n", "Max Nodes",
556 619 AcpiGbl_MaxConcurrentNodeCount,
557 620 ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount *
558 621 sizeof (ACPI_NAMESPACE_NODE)))));
↓ open down ↓ |
40 lines elided |
↑ open up ↑ |
559 622 */
560 623 return_VOID;
561 624 }
562 625
563 626
564 627 /*******************************************************************************
565 628 *
566 629 * FUNCTION: AcpiUtDumpAllocations
567 630 *
568 631 * PARAMETERS: Component - Component(s) to dump info for.
569 - * Module - Module to dump info for. NULL means all.
632 + * Module - Module to dump info for. NULL means all.
570 633 *
571 634 * RETURN: None
572 635 *
573 636 * DESCRIPTION: Print a list of all outstanding allocations.
574 637 *
575 638 ******************************************************************************/
576 639
577 640 void
578 641 AcpiUtDumpAllocations (
579 642 UINT32 Component,
580 643 const char *Module)
581 644 {
582 645 ACPI_DEBUG_MEM_BLOCK *Element;
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
583 646 ACPI_DESCRIPTOR *Descriptor;
584 647 UINT32 NumOutstanding = 0;
585 648 UINT8 DescriptorType;
586 649
587 650
588 651 ACPI_FUNCTION_TRACE (UtDumpAllocations);
589 652
590 653
591 654 if (AcpiGbl_DisableMemTracking)
592 655 {
593 - return;
656 + return_VOID;
594 657 }
595 658
596 659 /*
597 660 * Walk the allocation list.
598 661 */
599 662 if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY)))
600 663 {
601 - return;
664 + return_VOID;
602 665 }
603 666
604 667 Element = AcpiGbl_GlobalList->ListHead;
605 668 while (Element)
606 669 {
607 670 if ((Element->Component & Component) &&
608 671 ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module))))
609 672 {
610 673 Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace);
611 674
612 675 if (Element->Size < sizeof (ACPI_COMMON_DESCRIPTOR))
613 676 {
614 677 AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u "
615 678 "[Not a Descriptor - too small]\n",
616 679 Descriptor, Element->Size, Element->Module,
617 680 Element->Line);
618 681 }
619 682 else
620 683 {
621 684 /* Ignore allocated objects that are in a cache */
622 685
623 686 if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED)
624 687 {
625 688 AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u [%s] ",
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
626 689 Descriptor, Element->Size, Element->Module,
627 690 Element->Line, AcpiUtGetDescriptorName (Descriptor));
628 691
629 692 /* Validate the descriptor type using Type field and length */
630 693
631 694 DescriptorType = 0; /* Not a valid descriptor type */
632 695
633 696 switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor))
634 697 {
635 698 case ACPI_DESC_TYPE_OPERAND:
636 - if (Element->Size == sizeof (ACPI_DESC_TYPE_OPERAND))
699 +
700 + if (Element->Size == sizeof (ACPI_OPERAND_OBJECT))
637 701 {
638 702 DescriptorType = ACPI_DESC_TYPE_OPERAND;
639 703 }
640 704 break;
641 705
642 706 case ACPI_DESC_TYPE_PARSER:
643 - if (Element->Size == sizeof (ACPI_DESC_TYPE_PARSER))
707 +
708 + if (Element->Size == sizeof (ACPI_PARSE_OBJECT))
644 709 {
645 710 DescriptorType = ACPI_DESC_TYPE_PARSER;
646 711 }
647 712 break;
648 713
649 714 case ACPI_DESC_TYPE_NAMED:
650 - if (Element->Size == sizeof (ACPI_DESC_TYPE_NAMED))
715 +
716 + if (Element->Size == sizeof (ACPI_NAMESPACE_NODE))
651 717 {
652 718 DescriptorType = ACPI_DESC_TYPE_NAMED;
653 719 }
654 720 break;
655 721
656 722 default:
723 +
657 724 break;
658 725 }
659 726
660 727 /* Display additional info for the major descriptor types */
661 728
662 729 switch (DescriptorType)
663 730 {
664 731 case ACPI_DESC_TYPE_OPERAND:
732 +
665 733 AcpiOsPrintf ("%12.12s RefCount 0x%04X\n",
666 734 AcpiUtGetTypeName (Descriptor->Object.Common.Type),
667 735 Descriptor->Object.Common.ReferenceCount);
668 736 break;
669 737
670 738 case ACPI_DESC_TYPE_PARSER:
739 +
671 740 AcpiOsPrintf ("AmlOpcode 0x%04hX\n",
672 741 Descriptor->Op.Asl.AmlOpcode);
673 742 break;
674 743
675 744 case ACPI_DESC_TYPE_NAMED:
745 +
676 746 AcpiOsPrintf ("%4.4s\n",
677 747 AcpiUtGetNodeName (&Descriptor->Node));
678 748 break;
679 749
680 750 default:
751 +
681 752 AcpiOsPrintf ( "\n");
682 753 break;
683 754 }
684 755 }
685 756 }
686 757
687 758 NumOutstanding++;
688 759 }
689 760
690 761 Element = Element->Next;
691 762 }
692 763
693 764 (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
694 765
695 766 /* Print summary */
696 767
697 768 if (!NumOutstanding)
698 769 {
699 770 ACPI_INFO ((AE_INFO, "No outstanding allocations"));
700 771 }
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
701 772 else
702 773 {
703 774 ACPI_ERROR ((AE_INFO, "%u(0x%X) Outstanding allocations",
704 775 NumOutstanding, NumOutstanding));
705 776 }
706 777
707 778 return_VOID;
708 779 }
709 780
710 781 #endif /* ACPI_DBG_TRACK_ALLOCATIONS */
711 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX