lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bdc6c53d-a7bb-dcc4-20ba-6c7fa5c57dbd@yandex-team.ru>
Date:   Tue, 23 Jul 2019 11:16:51 +0300
From:   Konstantin Khlebnikov <khlebnikov@...dex-team.ru>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        Tejun Heo <tj@...nel.org>, Jens Axboe <axboe@...nel.dk>,
        Johannes Weiner <hannes@...xchg.org>,
        linux-fsdevel@...r.kernel.org, Jan Kara <jack@...e.cz>
Subject: Re: [PATCH 1/2] mm/filemap: don't initiate writeback if mapping has
 no dirty pages



On 23.07.2019 3:52, Andrew Morton wrote:
> 
> (cc linux-fsdevel and Jan)
> 
> On Mon, 22 Jul 2019 12:36:08 +0300 Konstantin Khlebnikov <khlebnikov@...dex-team.ru> wrote:
> 
>> Functions like filemap_write_and_wait_range() should do nothing if inode
>> has no dirty pages or pages currently under writeback. But they anyway
>> construct struct writeback_control and this does some atomic operations
>> if CONFIG_CGROUP_WRITEBACK=y - on fast path it locks inode->i_lock and
>> updates state of writeback ownership, on slow path might be more work.
>> Current this path is safely avoided only when inode mapping has no pages.
>>
>> For example generic_file_read_iter() calls filemap_write_and_wait_range()
>> at each O_DIRECT read - pretty hot path.
>>
>> This patch skips starting new writeback if mapping has no dirty tags set.
>> If writeback is already in progress filemap_write_and_wait_range() will
>> wait for it.
>>
>> ...
>>
>> --- a/mm/filemap.c
>> +++ b/mm/filemap.c
>> @@ -408,7 +408,8 @@ int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
>>   		.range_end = end,
>>   	};
>>   
>> -	if (!mapping_cap_writeback_dirty(mapping))
>> +	if (!mapping_cap_writeback_dirty(mapping) ||
>> +	    !mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
>>   		return 0;
>>   
>>   	wbc_attach_fdatawrite_inode(&wbc, mapping->host);
> 
> How does this play with tagged_writepages?  We assume that no tagging
> has been performed by any __filemap_fdatawrite_range() caller?
>

Checking also PAGECACHE_TAG_TOWRITE is cheap but seems redundant.

To-write tags are supposed to be a subset of dirty tags:
to-write is set only when dirty is set and cleared after starting writeback.

Special case set_page_writeback_keepwrite() which does not clear to-write
should be for dirty page thus dirty tag is not going to be cleared either.
Ext4 calls it after redirty_page_for_writepage()
XFS even without clear_page_dirty_for_io()

Anyway to-write tag without dirty tag or at clear page is confusing.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ