This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The NEWS file with glibc-2.10 implies that when MALLOC_ARENA_TEST is set, the test for the number of cores is only performed once the number of arenas in use reaches the value specified by MALLOC_ARENA_TEST. This is done because of the cost of testing for the number of cores. However, that is not actually what the code in arena.c implements. Within arena_get2 we have the following code: static size_t narenas_limit; a = get_free_list (); if (a == NULL) { /* Nothing immediately available, so generate a new arena. */ if (narenas_limit == 0) /* TEST 1 */ { if (mp_.arena_max != 0) /* TEST 2 */ narenas_limit = mp_.arena_max; else { int n = __get_nprocs (); if (n >= 1) narenas_limit = NARENAS_FROM_NCORES (n); else /* We have no information about the system. Assume two cores. */ narenas_limit = NARENAS_FROM_NCORES (2); } } Assume we have ARENA_MAX=0 ARENA_TEST=10. The first time through this code narenas_limit will be zero and mp_.arena_max will be zero as well. TEST 1 will be true & TEST 2 will be false, resulting in execution of the ELSE clause which calls __get_nprocs regardless of the value of ARENA_TEST. The second issue that we've spotted is that ARENA_MAX is supposed to be an upper limit on the number of arenas. But if ARENA_MAX is <= ARENA_TEST, then we will create up to ARENA_TEST arenas. The problem is we test narenas < arena_test || narenas < arena_max... This is easily resolved by clamping the value of arenas_test based on the value of arenas_max. Fixes for both problems are attached. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJPF56EAAoJEBRtltQi2kC7rekIAJMkuJfelbnup9d+m3yyoWsH Wc+685k/wOL99bBafCV5cCUCHLMLN1OQVq/bqqsqGrJ75heQq8Bi5xMV6Uy0iN/k TD/sqyqX00TdUNH5zSOMwFaybJkfjIMNkt70lny73o+4jj0iNWDJy6xSstyWDVTG 1g+pfNXCRANVBRooQW54VeMhbN8NCOAcWGpo9/nbnO9fRpmT2VwESI4IW4PkMKJ5 9WjiLfhVNJJ7+q55y/pEsv0aGcVG04pLoRCS/06X8RsLgbR0Kb0S9iV03vABZbqY 89vL2DChHuuY0S/uz7aLAHkihvbk1cXj97TKKLFY8SYVpsz+YNcW+CT2usbWZMY= =NU8s -----END PGP SIGNATURE-----
Attachment:
P
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |