The patch titled Subject: mm/writeback: move __set_page_dirty() to core mm has been added to the -mm tree. Its filename is mm-writeback-move-__set_page_dirty-to-core-mm.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-writeback-move-__set_page_dirty-to-core-mm.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-writeback-move-__set_page_dirty-to-core-mm.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx> Subject: mm/writeback: move __set_page_dirty() to core mm Patch series "Further set_page_dirty cleanups". Prompted by Christoph's recent patches, here are some more patches to improve the state of set_page_dirty(). They're all from the folio tree, so they've been tested to a certain extent. This patch (of 6): Nothing in __set_page_dirty() is specific to buffer_head, so move it to mm/page-writeback.c. That removes the only caller of account_page_dirtied() outside of page-writeback.c, so make it static. Link: https://lkml.kernel.org/r/20210615162342.1669332-1-willy@xxxxxxxxxxxxx Link: https://lkml.kernel.org/r/20210615162342.1669332-2-willy@xxxxxxxxxxxxx Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Reviewed-by: Christoph Hellwig <hch@xxxxxx> Reviewed-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Cc: Jan Kara <jack@xxxxxxx> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: Dan Williams <dan.j.williams@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/buffer.c | 24 ------------------------ include/linux/mm.h | 1 - mm/page-writeback.c | 27 ++++++++++++++++++++++++++- 3 files changed, 26 insertions(+), 26 deletions(-) --- a/fs/buffer.c~mm-writeback-move-__set_page_dirty-to-core-mm +++ a/fs/buffer.c @@ -589,30 +589,6 @@ void mark_buffer_dirty_inode(struct buff EXPORT_SYMBOL(mark_buffer_dirty_inode); /* - * Mark the page dirty, and set it dirty in the page cache, and mark the inode - * dirty. - * - * If warn is true, then emit a warning if the page is not uptodate and has - * not been truncated. - * - * The caller must hold lock_page_memcg(). - */ -void __set_page_dirty(struct page *page, struct address_space *mapping, - int warn) -{ - unsigned long flags; - - xa_lock_irqsave(&mapping->i_pages, flags); - if (page->mapping) { /* Race with truncate? */ - WARN_ON_ONCE(warn && !PageUptodate(page)); - account_page_dirtied(page, mapping); - __xa_set_mark(&mapping->i_pages, page_index(page), - PAGECACHE_TAG_DIRTY); - } - xa_unlock_irqrestore(&mapping->i_pages, flags); -} - -/* * Add a page to the dirty page list. * * It is a sad fact of life that this function is called from several places --- a/include/linux/mm.h~mm-writeback-move-__set_page_dirty-to-core-mm +++ a/include/linux/mm.h @@ -1855,7 +1855,6 @@ int __set_page_dirty_nobuffers(struct pa int __set_page_dirty_no_writeback(struct page *page); int redirty_page_for_writepage(struct writeback_control *wbc, struct page *page); -void account_page_dirtied(struct page *page, struct address_space *mapping); void account_page_cleaned(struct page *page, struct address_space *mapping, struct bdi_writeback *wb); int set_page_dirty(struct page *page); --- a/mm/page-writeback.c~mm-writeback-move-__set_page_dirty-to-core-mm +++ a/mm/page-writeback.c @@ -2425,7 +2425,8 @@ int __set_page_dirty_no_writeback(struct * * NOTE: This relies on being atomic wrt interrupts. */ -void account_page_dirtied(struct page *page, struct address_space *mapping) +static void account_page_dirtied(struct page *page, + struct address_space *mapping) { struct inode *inode = mapping->host; @@ -2467,6 +2468,30 @@ void account_page_cleaned(struct page *p } /* + * Mark the page dirty, and set it dirty in the page cache, and mark the inode + * dirty. + * + * If warn is true, then emit a warning if the page is not uptodate and has + * not been truncated. + * + * The caller must hold lock_page_memcg(). + */ +void __set_page_dirty(struct page *page, struct address_space *mapping, + int warn) +{ + unsigned long flags; + + xa_lock_irqsave(&mapping->i_pages, flags); + if (page->mapping) { /* Race with truncate? */ + WARN_ON_ONCE(warn && !PageUptodate(page)); + account_page_dirtied(page, mapping); + __xa_set_mark(&mapping->i_pages, page_index(page), + PAGECACHE_TAG_DIRTY); + } + xa_unlock_irqrestore(&mapping->i_pages, flags); +} + +/* * For address_spaces which do not use buffers. Just tag the page as dirty in * the xarray. * _ Patches currently in -mm which might be from willy@xxxxxxxxxxxxx are mm-mark-idle-page-tracking-as-broken.patch writeback-cgroup-release-dying-cgwbs-by-switching-attached-inodes-fix-3.patch mm-writeback-move-__set_page_dirty-to-core-mm.patch mm-writeback-use-__set_page_dirty-in-__set_page_dirty_nobuffers.patch iomap-use-__set_page_dirty_nobuffers.patch fs-remove-anon_set_page_dirty.patch fs-remove-noop_set_page_dirty.patch mm-move-page-dirtying-prototypes-from-mmh.patch mm-make-__dump_page-static.patch mm-debug-factor-pagepoisoned-out-of-__dump_page.patch mm-page_owner-constify-dump_page_owner.patch mm-make-compound_head-const-preserving.patch mm-constify-get_pfnblock_flags_mask-and-get_pfnblock_migratetype.patch mm-constify-page_count-and-page_ref_count.patch mm-optimise-nth_page-for-contiguous-memmap.patch mm-hugetlb-free-the-vmemmap-pages-associated-with-each-hugetlb-page-fix.patch mm-hugetlb-alloc-the-vmemmap-pages-associated-with-each-hugetlb-page-fix-2.patch mm-thp-fix-strncpy-warning.patch