Changeset 37400 in vbox for trunk/src/VBox
- Timestamp:
- Jun 9, 2011 8:38:21 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/log/tracebuf.cpp
r37398 r37400 25 25 /** Alignment used to place the trace buffer members, this should be a multiple 26 26 * of the cache line size if possible. (We should dynamically determine it.) */ 27 #define RTTRACEBUF_ALIGNMENT 6427 #define RTTRACEBUF_ALIGNMENT 64 28 28 AssertCompile(RTTRACEBUF_ALIGNMENT >= sizeof(uint64_t) * 2); 29 29 30 /** The maximum number of entries. */ 31 #define RTTRACEBUF_MAX_ENTRIES _64K 32 /** The minimum number of entries. */ 33 #define RTTRACEBUF_MIN_ENTRIES 4 34 /** The default number of entries. */ 35 #define RTTRACEBUF_DEF_ENTRIES 256 36 37 /** The maximum entry size. */ 38 #define RTTRACEBUF_MAX_ENTRY_SIZE _1M 39 /** The minimum entry size. */ 40 #define RTTRACEBUF_MIN_ENTRY_SIZE RTTRACEBUF_ALIGNMENT 41 /** The default entry size. */ 42 #define RTTRACEBUF_DEF_ENTRY_SIZE 256 43 AssertCompile(!(RTTRACEBUF_DEF_ENTRY_SIZE & (RTTRACEBUF_DEF_ENTRY_SIZE - 1))); 30 44 31 45 /** … … 240 254 AssertPtrReturn(phTraceBuf, VERR_INVALID_POINTER); 241 255 AssertReturn(!fFlags, VERR_INVALID_PARAMETER); 242 AssertMsgReturn(cbEntry <= _64K, ("%#x\n", cbEntry),VERR_OUT_OF_RANGE);243 AssertMsgReturn(cEntries <= _1M, ("%#x\n", cEntries), VERR_OUT_OF_RANGE);256 AssertMsgReturn(cbEntry <= RTTRACEBUF_MAX_ENTRIES, ("%#x\n", cbEntry), VERR_OUT_OF_RANGE); 257 AssertMsgReturn(cEntries <= RTTRACEBUF_MAX_ENTRY_SIZE, ("%#x\n", cEntries), VERR_OUT_OF_RANGE); 244 258 245 259 /* … … 247 261 */ 248 262 if (!cbEntry) 249 cbEntry = RT _ALIGN_Z(256, RTTRACEBUF_ALIGNMENT);263 cbEntry = RTTRACEBUF_DEF_ENTRY_SIZE; 250 264 else 251 cbEntry = RT_ALIGN_ Z(cbEntry, RTTRACEBUF_ALIGNMENT);265 cbEntry = RT_ALIGN_32(cbEntry, RTTRACEBUF_ALIGNMENT); 252 266 253 267 if (!cEntries) 254 cEntries = 64;255 else if (cEntries < 4)256 cEntries = 4;268 cEntries = RTTRACEBUF_DEF_ENTRIES; 269 else if (cEntries < RTTRACEBUF_MIN_ENTRIES) 270 cEntries = RTTRACEBUF_MIN_ENTRIES; 257 271 258 272 /* … … 288 302 AssertPtrReturn(phTraceBuf, VERR_INVALID_POINTER); 289 303 AssertReturn(!(fFlags & ~RTTRACEBUF_FLAGS_MASK), VERR_INVALID_PARAMETER); 290 AssertMsgReturn(cbEntry <= _64K, ("%#x\n", cbEntry),VERR_OUT_OF_RANGE);291 AssertMsgReturn(cEntries <= _1M, ("%#x\n", cEntries), VERR_OUT_OF_RANGE);304 AssertMsgReturn(cbEntry <= RTTRACEBUF_MAX_ENTRIES, ("%#x\n", cbEntry), VERR_OUT_OF_RANGE); 305 AssertMsgReturn(cEntries <= RTTRACEBUF_MAX_ENTRY_SIZE, ("%#x\n", cEntries), VERR_OUT_OF_RANGE); 292 306 AssertPtrReturn(pvBlock, VERR_INVALID_POINTER); 293 307 AssertPtrReturn(pcbBlock, VERR_INVALID_POINTER); … … 302 316 size_t const cbEntryBuf = cbBlock > cbHdr ? cbBlock - cbHdr : 0; 303 317 if (cbEntry) 304 cbEntry = RT_ALIGN_ Z(cbEntry, RTTRACEBUF_ALIGNMENT);318 cbEntry = RT_ALIGN_32(cbEntry, RTTRACEBUF_ALIGNMENT); 305 319 else 306 320 { 307 321 if (!cbEntryBuf) 308 cbEntry = RT_ALIGN_Z(256, RTTRACEBUF_ALIGNMENT); 322 { 323 cbEntry = RTTRACEBUF_DEF_ENTRY_SIZE; 324 cEntries = RTTRACEBUF_DEF_ENTRIES; 325 } 309 326 else if (cEntries) 310 327 { 311 cbEntry = cbBlock / cEntries; 312 cbEntry &= ~(RTTRACEBUF_ALIGNMENT - 1); 313 if (cbEntry > _64K) 314 cbEntry = _64K; 328 size_t cbEntryZ = cbBlock / cEntries; 329 cbEntryZ &= ~(RTTRACEBUF_ALIGNMENT - 1); 330 if (cbEntryZ > RTTRACEBUF_MAX_ENTRIES) 331 cbEntryZ = RTTRACEBUF_MAX_ENTRIES; 332 cbEntry = (uint32_t)cbEntryZ; 315 333 } 316 else if (cbBlock >= RT_ALIGN_ Z(512, RTTRACEBUF_ALIGNMENT) * 256)317 cbEntry = RT_ALIGN_ Z(512, RTTRACEBUF_ALIGNMENT);318 else if (cbBlock >= RT_ALIGN_ Z(256, RTTRACEBUF_ALIGNMENT) * 64)319 cbEntry = RT_ALIGN_ Z(256, RTTRACEBUF_ALIGNMENT);320 else if (cbBlock >= RT_ALIGN_ Z(128, RTTRACEBUF_ALIGNMENT) * 32)321 cbEntry = RT_ALIGN_ Z(128, RTTRACEBUF_ALIGNMENT);334 else if (cbBlock >= RT_ALIGN_32(512, RTTRACEBUF_ALIGNMENT) * 256) 335 cbEntry = RT_ALIGN_32(512, RTTRACEBUF_ALIGNMENT); 336 else if (cbBlock >= RT_ALIGN_32(256, RTTRACEBUF_ALIGNMENT) * 64) 337 cbEntry = RT_ALIGN_32(256, RTTRACEBUF_ALIGNMENT); 338 else if (cbBlock >= RT_ALIGN_32(128, RTTRACEBUF_ALIGNMENT) * 32) 339 cbEntry = RT_ALIGN_32(128, RTTRACEBUF_ALIGNMENT); 322 340 else 323 341 cbEntry = sizeof(RTTRACEBUFENTRY); 324 342 } 325 Assert(RT_ALIGN_ Z(cbEntry, RTTRACEBUF_ALIGNMENT) == cbEntry);343 Assert(RT_ALIGN_32(cbEntry, RTTRACEBUF_ALIGNMENT) == cbEntry); 326 344 327 345 if (!cEntries) 328 cEntries = cbEntry / cbEntryBuf; 329 if (cEntries < 4) 330 cEntries = 4; 346 { 347 size_t cEntriesZ = cbEntryBuf / cbEntry; 348 if (cEntriesZ > RTTRACEBUF_MAX_ENTRIES) 349 cEntriesZ = RTTRACEBUF_MAX_ENTRIES; 350 cEntries = (uint32_t)cEntriesZ; 351 } 352 if (cEntries < RTTRACEBUF_MIN_ENTRIES) 353 cEntries = RTTRACEBUF_MIN_ENTRIES; 331 354 332 355 uint32_t offVolatile = RTTRACEBUF_ALIGNMENT - ((uintptr_t)pvBlock & (RTTRACEBUF_ALIGNMENT - 1)); … … 376 399 AssertReturnVoid(ASMAtomicCmpXchgU32(&pThis->u32Magic, RTTRACEBUF_MAGIC_DEAD, RTTRACEBUF_MAGIC)); 377 400 if (pThis->fFlags & RTTRACEBUF_FLAGS_FREE_ME) 401 { 378 402 #ifdef IN_RC 379 403 AssertReleaseFailed(); … … 381 405 RTMemFree(pThis); 382 406 #endif 407 } 383 408 } 384 409
Note:
See TracChangeset
for help on using the changeset viewer.