Print this page
update to acpica-unix2-20140114
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 - 2014, 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++;
↓ open down ↓ |
60 lines elided |
↑ open up ↑ |
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 - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation));
310 + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed (block %p)\n",
311 + Allocation, DebugBlock));
289 312 return_VOID;
290 313 }
291 314
292 315
293 316 /*******************************************************************************
294 317 *
295 318 * FUNCTION: AcpiUtFindAllocation
296 319 *
297 320 * PARAMETERS: Allocation - Address of allocated memory
298 321 *
299 - * RETURN: A list element if found; NULL otherwise.
322 + * RETURN: Three cases:
323 + * 1) List is empty, NULL is returned.
324 + * 2) Element was found. Returns Allocation parameter.
325 + * 3) Element was not found. Returns position where it should be
326 + * inserted into the list.
300 327 *
301 328 * DESCRIPTION: Searches for an element in the global allocation tracking list.
329 + * If the element is not found, returns the location within the
330 + * list where the element should be inserted.
302 331 *
332 + * Note: The list is ordered by larger-to-smaller addresses.
333 + *
334 + * This global list is used to detect memory leaks in ACPICA as
335 + * well as other issues such as an attempt to release the same
336 + * internal object more than once. Although expensive as far
337 + * as cpu time, this list is much more helpful for finding these
338 + * types of issues than using memory leak detectors outside of
339 + * the ACPICA code.
340 + *
303 341 ******************************************************************************/
304 342
305 343 static ACPI_DEBUG_MEM_BLOCK *
306 344 AcpiUtFindAllocation (
307 - void *Allocation)
345 + ACPI_DEBUG_MEM_BLOCK *Allocation)
308 346 {
309 347 ACPI_DEBUG_MEM_BLOCK *Element;
310 348
311 349
312 - ACPI_FUNCTION_ENTRY ();
313 -
314 -
315 350 Element = AcpiGbl_GlobalList->ListHead;
351 + if (!Element)
352 + {
353 + return (NULL);
354 + }
316 355
317 - /* Search for the address. */
318 -
319 - while (Element)
356 + /*
357 + * Search for the address.
358 + *
359 + * Note: List is ordered by larger-to-smaller addresses, on the
360 + * assumption that a new allocation usually has a larger address
361 + * than previous allocations.
362 + */
363 + while (Element > Allocation)
320 364 {
321 - if (Element == Allocation)
365 + /* Check for end-of-list */
366 +
367 + if (!Element->Next)
322 368 {
323 369 return (Element);
324 370 }
325 371
326 372 Element = Element->Next;
327 373 }
328 374
329 - return (NULL);
375 + if (Element == Allocation)
376 + {
377 + return (Element);
378 + }
379 +
380 + return (Element->Previous);
330 381 }
331 382
332 383
333 384 /*******************************************************************************
334 385 *
335 386 * FUNCTION: AcpiUtTrackAllocation
336 387 *
337 388 * PARAMETERS: Allocation - Address of allocated memory
338 389 * Size - Size of the allocation
339 390 * AllocType - MEM_MALLOC or MEM_CALLOC
340 391 * Component - Component type of caller
341 392 * Module - Source file name of caller
342 393 * Line - Line number of caller
343 394 *
344 - * RETURN: None.
395 + * RETURN: Status
345 396 *
346 397 * DESCRIPTION: Inserts an element into the global allocation tracking list.
347 398 *
348 399 ******************************************************************************/
349 400
350 401 static ACPI_STATUS
351 402 AcpiUtTrackAllocation (
352 403 ACPI_DEBUG_MEM_BLOCK *Allocation,
353 404 ACPI_SIZE Size,
354 405 UINT8 AllocType,
355 406 UINT32 Component,
356 407 const char *Module,
357 408 UINT32 Line)
358 409 {
359 410 ACPI_MEMORY_LIST *MemList;
360 411 ACPI_DEBUG_MEM_BLOCK *Element;
361 412 ACPI_STATUS Status = AE_OK;
362 413
363 414
364 415 ACPI_FUNCTION_TRACE_PTR (UtTrackAllocation, Allocation);
365 416
366 417
367 418 if (AcpiGbl_DisableMemTracking)
368 419 {
369 420 return_ACPI_STATUS (AE_OK);
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
370 421 }
371 422
372 423 MemList = AcpiGbl_GlobalList;
373 424 Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
374 425 if (ACPI_FAILURE (Status))
375 426 {
376 427 return_ACPI_STATUS (Status);
377 428 }
378 429
379 430 /*
380 - * Search list for this address to make sure it is not already on the list.
381 - * This will catch several kinds of problems.
431 + * Search the global list for this address to make sure it is not
432 + * already present. This will catch several kinds of problems.
382 433 */
383 434 Element = AcpiUtFindAllocation (Allocation);
384 - if (Element)
435 + if (Element == Allocation)
385 436 {
386 437 ACPI_ERROR ((AE_INFO,
387 - "UtTrackAllocation: Allocation already present in list! (%p)",
438 + "UtTrackAllocation: Allocation (%p) already present in global list!",
388 439 Allocation));
389 -
390 - ACPI_ERROR ((AE_INFO, "Element %p Address %p",
391 - Element, Allocation));
392 -
393 440 goto UnlockAndExit;
394 441 }
395 442
396 - /* Fill in the instance data. */
443 + /* Fill in the instance data */
397 444
398 445 Allocation->Size = (UINT32) Size;
399 446 Allocation->AllocType = AllocType;
400 447 Allocation->Component = Component;
401 448 Allocation->Line = Line;
402 449
403 450 ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME);
404 451 Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0;
405 452
406 - /* Insert at list head */
407 -
408 - if (MemList->ListHead)
453 + if (!Element)
409 454 {
410 - ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation;
455 + /* Insert at list head */
456 +
457 + if (MemList->ListHead)
458 + {
459 + ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation;
460 + }
461 +
462 + Allocation->Next = MemList->ListHead;
463 + Allocation->Previous = NULL;
464 +
465 + MemList->ListHead = Allocation;
411 466 }
467 + else
468 + {
469 + /* Insert after element */
412 470
413 - Allocation->Next = MemList->ListHead;
414 - Allocation->Previous = NULL;
471 + Allocation->Next = Element->Next;
472 + Allocation->Previous = Element;
415 473
416 - MemList->ListHead = Allocation;
474 + if (Element->Next)
475 + {
476 + (Element->Next)->Previous = Allocation;
477 + }
417 478
479 + Element->Next = Allocation;
480 + }
418 481
482 +
419 483 UnlockAndExit:
420 484 Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
421 485 return_ACPI_STATUS (Status);
422 486 }
423 487
424 488
425 489 /*******************************************************************************
426 490 *
427 491 * FUNCTION: AcpiUtRemoveAllocation
428 492 *
429 493 * PARAMETERS: Allocation - Address of allocated memory
430 494 * Component - Component type of caller
431 495 * Module - Source file name of caller
432 496 * Line - Line number of caller
433 497 *
434 - * RETURN:
498 + * RETURN: Status
435 499 *
436 500 * DESCRIPTION: Deletes an element from the global allocation tracking list.
437 501 *
438 502 ******************************************************************************/
439 503
440 504 static ACPI_STATUS
441 505 AcpiUtRemoveAllocation (
442 506 ACPI_DEBUG_MEM_BLOCK *Allocation,
443 507 UINT32 Component,
444 508 const char *Module,
445 509 UINT32 Line)
446 510 {
447 511 ACPI_MEMORY_LIST *MemList;
448 512 ACPI_STATUS Status;
449 513
450 514
451 - ACPI_FUNCTION_TRACE (UtRemoveAllocation);
515 + ACPI_FUNCTION_NAME (UtRemoveAllocation);
452 516
453 517
454 518 if (AcpiGbl_DisableMemTracking)
455 519 {
456 - return_ACPI_STATUS (AE_OK);
520 + return (AE_OK);
457 521 }
458 522
459 523 MemList = AcpiGbl_GlobalList;
460 524 if (NULL == MemList->ListHead)
461 525 {
462 526 /* No allocations! */
463 527
464 528 ACPI_ERROR ((Module, Line,
465 529 "Empty allocation list, nothing to free!"));
466 530
467 - return_ACPI_STATUS (AE_OK);
531 + return (AE_OK);
468 532 }
469 533
470 534 Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
471 535 if (ACPI_FAILURE (Status))
472 536 {
473 - return_ACPI_STATUS (Status);
537 + return (Status);
474 538 }
475 539
476 540 /* Unlink */
477 541
478 542 if (Allocation->Previous)
479 543 {
480 544 (Allocation->Previous)->Next = Allocation->Next;
481 545 }
482 546 else
483 547 {
484 548 MemList->ListHead = Allocation->Next;
485 549 }
486 550
487 551 if (Allocation->Next)
488 552 {
489 553 (Allocation->Next)->Previous = Allocation->Previous;
490 554 }
491 555
556 + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing %p, size 0%X\n",
557 + &Allocation->UserSpace, Allocation->Size));
558 +
492 559 /* Mark the segment as deleted */
493 560
494 561 ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size);
495 562
496 - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n",
497 - Allocation->Size));
498 -
499 563 Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
500 - return_ACPI_STATUS (Status);
564 + return (Status);
501 565 }
502 566
503 567
504 568 /*******************************************************************************
505 569 *
506 570 * FUNCTION: AcpiUtDumpAllocationInfo
507 571 *
508 - * PARAMETERS:
572 + * PARAMETERS: None
509 573 *
510 574 * RETURN: None
511 575 *
512 576 * DESCRIPTION: Print some info about the outstanding allocations.
513 577 *
514 578 ******************************************************************************/
515 579
516 580 void
517 581 AcpiUtDumpAllocationInfo (
518 582 void)
519 583 {
520 584 /*
521 585 ACPI_MEMORY_LIST *MemList;
522 586 */
523 587
524 588 ACPI_FUNCTION_TRACE (UtDumpAllocationInfo);
525 589
526 590 /*
527 591 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
528 592 ("%30s: %4d (%3d Kb)\n", "Current allocations",
529 593 MemList->CurrentCount,
530 594 ROUND_UP_TO_1K (MemList->CurrentSize)));
531 595
532 596 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
533 597 ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",
534 598 MemList->MaxConcurrentCount,
535 599 ROUND_UP_TO_1K (MemList->MaxConcurrentSize)));
536 600
537 601
538 602 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
539 603 ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
540 604 RunningObjectCount,
541 605 ROUND_UP_TO_1K (RunningObjectSize)));
542 606
543 607 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
544 608 ("%30s: %4d (%3d Kb)\n", "Total (all) allocations",
545 609 RunningAllocCount,
546 610 ROUND_UP_TO_1K (RunningAllocSize)));
547 611
548 612
549 613 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
550 614 ("%30s: %4d (%3d Kb)\n", "Current Nodes",
551 615 AcpiGbl_CurrentNodeCount,
552 616 ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize)));
553 617
554 618 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
555 619 ("%30s: %4d (%3d Kb)\n", "Max Nodes",
556 620 AcpiGbl_MaxConcurrentNodeCount,
557 621 ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount *
558 622 sizeof (ACPI_NAMESPACE_NODE)))));
↓ open down ↓ |
40 lines elided |
↑ open up ↑ |
559 623 */
560 624 return_VOID;
561 625 }
562 626
563 627
564 628 /*******************************************************************************
565 629 *
566 630 * FUNCTION: AcpiUtDumpAllocations
567 631 *
568 632 * PARAMETERS: Component - Component(s) to dump info for.
569 - * Module - Module to dump info for. NULL means all.
633 + * Module - Module to dump info for. NULL means all.
570 634 *
571 635 * RETURN: None
572 636 *
573 637 * DESCRIPTION: Print a list of all outstanding allocations.
574 638 *
575 639 ******************************************************************************/
576 640
577 641 void
578 642 AcpiUtDumpAllocations (
579 643 UINT32 Component,
580 644 const char *Module)
581 645 {
582 646 ACPI_DEBUG_MEM_BLOCK *Element;
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
583 647 ACPI_DESCRIPTOR *Descriptor;
584 648 UINT32 NumOutstanding = 0;
585 649 UINT8 DescriptorType;
586 650
587 651
588 652 ACPI_FUNCTION_TRACE (UtDumpAllocations);
589 653
590 654
591 655 if (AcpiGbl_DisableMemTracking)
592 656 {
593 - return;
657 + return_VOID;
594 658 }
595 659
596 660 /*
597 661 * Walk the allocation list.
598 662 */
599 663 if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY)))
600 664 {
601 - return;
665 + return_VOID;
602 666 }
603 667
604 668 Element = AcpiGbl_GlobalList->ListHead;
605 669 while (Element)
606 670 {
607 671 if ((Element->Component & Component) &&
608 672 ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module))))
609 673 {
610 674 Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace);
611 675
612 676 if (Element->Size < sizeof (ACPI_COMMON_DESCRIPTOR))
613 677 {
614 678 AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u "
615 679 "[Not a Descriptor - too small]\n",
616 680 Descriptor, Element->Size, Element->Module,
617 681 Element->Line);
618 682 }
619 683 else
620 684 {
621 685 /* Ignore allocated objects that are in a cache */
622 686
623 687 if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED)
624 688 {
625 689 AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u [%s] ",
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
626 690 Descriptor, Element->Size, Element->Module,
627 691 Element->Line, AcpiUtGetDescriptorName (Descriptor));
628 692
629 693 /* Validate the descriptor type using Type field and length */
630 694
631 695 DescriptorType = 0; /* Not a valid descriptor type */
632 696
633 697 switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor))
634 698 {
635 699 case ACPI_DESC_TYPE_OPERAND:
636 - if (Element->Size == sizeof (ACPI_DESC_TYPE_OPERAND))
700 +
701 + if (Element->Size == sizeof (ACPI_OPERAND_OBJECT))
637 702 {
638 703 DescriptorType = ACPI_DESC_TYPE_OPERAND;
639 704 }
640 705 break;
641 706
642 707 case ACPI_DESC_TYPE_PARSER:
643 - if (Element->Size == sizeof (ACPI_DESC_TYPE_PARSER))
708 +
709 + if (Element->Size == sizeof (ACPI_PARSE_OBJECT))
644 710 {
645 711 DescriptorType = ACPI_DESC_TYPE_PARSER;
646 712 }
647 713 break;
648 714
649 715 case ACPI_DESC_TYPE_NAMED:
650 - if (Element->Size == sizeof (ACPI_DESC_TYPE_NAMED))
716 +
717 + if (Element->Size == sizeof (ACPI_NAMESPACE_NODE))
651 718 {
652 719 DescriptorType = ACPI_DESC_TYPE_NAMED;
653 720 }
654 721 break;
655 722
656 723 default:
724 +
657 725 break;
658 726 }
659 727
660 728 /* Display additional info for the major descriptor types */
661 729
662 730 switch (DescriptorType)
663 731 {
664 732 case ACPI_DESC_TYPE_OPERAND:
733 +
665 734 AcpiOsPrintf ("%12.12s RefCount 0x%04X\n",
666 735 AcpiUtGetTypeName (Descriptor->Object.Common.Type),
667 736 Descriptor->Object.Common.ReferenceCount);
668 737 break;
669 738
670 739 case ACPI_DESC_TYPE_PARSER:
740 +
671 741 AcpiOsPrintf ("AmlOpcode 0x%04hX\n",
672 742 Descriptor->Op.Asl.AmlOpcode);
673 743 break;
674 744
675 745 case ACPI_DESC_TYPE_NAMED:
746 +
676 747 AcpiOsPrintf ("%4.4s\n",
677 748 AcpiUtGetNodeName (&Descriptor->Node));
678 749 break;
679 750
680 751 default:
752 +
681 753 AcpiOsPrintf ( "\n");
682 754 break;
683 755 }
684 756 }
685 757 }
686 758
687 759 NumOutstanding++;
688 760 }
689 761
690 762 Element = Element->Next;
691 763 }
692 764
693 765 (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
694 766
695 767 /* Print summary */
696 768
697 769 if (!NumOutstanding)
698 770 {
699 771 ACPI_INFO ((AE_INFO, "No outstanding allocations"));
700 772 }
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
701 773 else
702 774 {
703 775 ACPI_ERROR ((AE_INFO, "%u(0x%X) Outstanding allocations",
704 776 NumOutstanding, NumOutstanding));
705 777 }
706 778
707 779 return_VOID;
708 780 }
709 781
710 782 #endif /* ACPI_DBG_TRACK_ALLOCATIONS */
711 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX