malloc: remove assumptions about MINALLOCSIZE

Remove assumptions about the minimum MINALLOCSIZE, in order to allow
testing of smaller MINALLOCSIZE.  A following patch will lower the
MINALLOCSIZE, but not so much that the present patch is required for
correctness at these sites.

Reviewed by:	jeff, markj
Sponsored by:	Dell EMC Isilon
This commit is contained in:
rlibby 2020-01-14 02:14:02 +00:00
parent d3d56117a6
commit c334136053
2 changed files with 3 additions and 2 deletions

View File

@ -2054,7 +2054,7 @@ crextend(struct ucred *cr, int n)
*/
if ( n < PAGE_SIZE / sizeof(gid_t) ) {
if (cr->cr_agroups == 0)
cnt = MINALLOCSIZE / sizeof(gid_t);
cnt = MAX(1, MINALLOCSIZE / sizeof(gid_t));
else
cnt = cr->cr_agroups * 2;

View File

@ -1686,7 +1686,8 @@ devclass_alloc_unit(devclass_t dc, device_t dev, int *unitp)
int newsize;
oldlist = dc->devices;
newsize = roundup((unit + 1), MINALLOCSIZE / sizeof(device_t));
newsize = roundup((unit + 1),
MAX(1, MINALLOCSIZE / sizeof(device_t)));
newlist = malloc(sizeof(device_t) * newsize, M_BUS, M_NOWAIT);
if (!newlist)
return (ENOMEM);