Yoann Padioleau <p...@fb.com> once said: > in the newseg() function there is: > > [...] > > I think it should be > if(mapsize > (SEGMAPSIZE)) > mapsize = SEGMAPSIZE;
Yes, you're correct. The code allows the creation of a segment VM map with more than SEGMAPSIZE Ptes. Personally, I'd remove the check entirely along with the optimization of doubling the segment size, perhaps moving it to ibrk. I think it's more likely that the segment will grow if brk is called at least once. Anthony P.S. It looks like this is a 15 year old bug: 1998/0916/sys/src/9/port/segment.c:62,67 - 1998/0919/sys/src/9/port/segment.c:62,70 mapsize = ROUND(size, PTEPERTAB)/PTEPERTAB; if(mapsize > nelem(s->ssegmap)){ + mapsize *= 2; + if(mapsize > (SEGMAPSIZE*PTEPERTAB)) + mapsize = (SEGMAPSIZE*PTEPERTAB); s->map = smalloc(mapsize*sizeof(Pte*)); s->mapsize = mapsize; }