Re: [PATCH v3 2/4] fio: enable cross-thread overlap checking with processes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/17/18 10:25 AM, Sébastien Boisvert wrote:
>> @@ -10,14 +11,18 @@ struct align_footer {
>>  	unsigned int offset;
>>  };
>>  
>> -void *fio_memalign(size_t alignment, size_t size)
>> +void *fio_memalign(size_t alignment, size_t size, bool shared)
>>  {
>>  	struct align_footer *f;
>>  	void *ptr, *ret = NULL;
>>  
>>  	assert(!(alignment & (alignment - 1)));
>>  
>> -	ptr = malloc(size + alignment + sizeof(*f) - 1);
>> +	if (shared)
>> +		ptr = smalloc(size + alignment + sizeof(*f) - 1);
>> +	else
>> +		ptr = malloc(size + alignment + sizeof(*f) - 1);
> 
> Hello Vincent,
> 
> In your patch serives version 2, you removed the memset() call because
> smalloc() is already zeroing memory, according to Jens.
> 
> From the hunk above, the memory pointed by ptr is not zeroed, when
> being allocated by malloc.
> 
> I don't think that malloc is guaranteed to return zeroed memory.
> 
> Sure, if the malloc from the glibc just called brk() or mmap(), then,
> maybe those pages will be zeroed by the kernel, and the glibc malloc
> arena from which the chunk is drawn may be zeroed.
> 
> But otherwise, if it's a malloc that stays in user-space (existing
> arenas can fulfill the call), then, it is not zeroed, I think.

malloc() isn't zeroed, the code was using calloc() before (which is fine.

-- 
Jens Axboe




[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux