Re: [PATCH v2] fs: optimise kiocb_set_rw_flags()

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

 



On 1/31/2020 4:01 PM, Pavel Begunkov wrote:
> On 1/17/2020 4:32 AM, Pavel Begunkov wrote:
>> kiocb_set_rw_flags() generates a poor code with several memory writes
>> and a lot of jumps. Help compilers to optimise it.
>>
>> Tested with gcc 9.2 on x64-86, and as a result, it its output now is a
>> plain code without jumps accumulating in a register before a memory
>> write.
> 
> Humble ping

Anyone?

> 
>>
>> Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx>
>> ---
>>
>> v2: check for 0 flags in advance (Matthew Wilcox)
>>
>>  include/linux/fs.h | 16 +++++++++++-----
>>  1 file changed, 11 insertions(+), 5 deletions(-)
>>
>> diff --git a/include/linux/fs.h b/include/linux/fs.h
>> index 98e0349adb52..22b46fc8fdfa 100644
>> --- a/include/linux/fs.h
>> +++ b/include/linux/fs.h
>> @@ -3402,22 +3402,28 @@ static inline int iocb_flags(struct file *file)
>>  
>>  static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags)
>>  {
>> +	int kiocb_flags = 0;
>> +
>> +	if (!flags)
>> +		return 0;
>>  	if (unlikely(flags & ~RWF_SUPPORTED))
>>  		return -EOPNOTSUPP;
>>  
>>  	if (flags & RWF_NOWAIT) {
>>  		if (!(ki->ki_filp->f_mode & FMODE_NOWAIT))
>>  			return -EOPNOTSUPP;
>> -		ki->ki_flags |= IOCB_NOWAIT;
>> +		kiocb_flags |= IOCB_NOWAIT;
>>  	}
>>  	if (flags & RWF_HIPRI)
>> -		ki->ki_flags |= IOCB_HIPRI;
>> +		kiocb_flags |= IOCB_HIPRI;
>>  	if (flags & RWF_DSYNC)
>> -		ki->ki_flags |= IOCB_DSYNC;
>> +		kiocb_flags |= IOCB_DSYNC;
>>  	if (flags & RWF_SYNC)
>> -		ki->ki_flags |= (IOCB_DSYNC | IOCB_SYNC);
>> +		kiocb_flags |= (IOCB_DSYNC | IOCB_SYNC);
>>  	if (flags & RWF_APPEND)
>> -		ki->ki_flags |= IOCB_APPEND;
>> +		kiocb_flags |= IOCB_APPEND;
>> +
>> +	ki->ki_flags |= kiocb_flags;
>>  	return 0;
>>  }
>>  
>>
> 

-- 
Pavel Begunkov



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux