Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: make __end_folio_writeback() return void

Rather than check the result of test-and-clear, just check that we have
the writeback bit set at the start. This wouldn't catch every case, but
it's good enough (and enables the next patch).

Link: https://lkml.kernel.org/r/20231004165317.1061855-17-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Matthew Wilcox (Oracle) and committed by
Andrew Morton
7d0795d0 0410cd84

+23 -24
+7 -2
mm/filemap.c
··· 1593 1593 /** 1594 1594 * folio_end_writeback - End writeback against a folio. 1595 1595 * @folio: The folio. 1596 + * 1597 + * The folio must actually be under writeback. 1598 + * 1599 + * Context: May be called from process or interrupt context. 1596 1600 */ 1597 1601 void folio_end_writeback(struct folio *folio) 1598 1602 { 1603 + VM_BUG_ON_FOLIO(!folio_test_writeback(folio), folio); 1604 + 1599 1605 /* 1600 1606 * folio_test_clear_reclaim() could be used here but it is an 1601 1607 * atomic operation and overkill in this particular case. Failing ··· 1621 1615 * reused before the folio_wake(). 1622 1616 */ 1623 1617 folio_get(folio); 1624 - if (!__folio_end_writeback(folio)) 1625 - BUG(); 1618 + __folio_end_writeback(folio); 1626 1619 1627 1620 smp_mb__after_atomic(); 1628 1621 folio_wake(folio, PG_writeback);
+1 -1
mm/internal.h
··· 105 105 106 106 vm_fault_t do_swap_page(struct vm_fault *vmf); 107 107 void folio_rotate_reclaimable(struct folio *folio); 108 - bool __folio_end_writeback(struct folio *folio); 108 + void __folio_end_writeback(struct folio *folio); 109 109 void deactivate_file_folio(struct folio *folio); 110 110 void folio_activate(struct folio *folio); 111 111
+15 -21
mm/page-writeback.c
··· 2940 2940 spin_unlock_irqrestore(&wb->work_lock, flags); 2941 2941 } 2942 2942 2943 - bool __folio_end_writeback(struct folio *folio) 2943 + void __folio_end_writeback(struct folio *folio) 2944 2944 { 2945 2945 long nr = folio_nr_pages(folio); 2946 2946 struct address_space *mapping = folio_mapping(folio); 2947 - bool ret; 2948 2947 2949 2948 folio_memcg_lock(folio); 2950 2949 if (mapping && mapping_use_writeback_tags(mapping)) { ··· 2952 2953 unsigned long flags; 2953 2954 2954 2955 xa_lock_irqsave(&mapping->i_pages, flags); 2955 - ret = folio_test_clear_writeback(folio); 2956 - if (ret) { 2957 - __xa_clear_mark(&mapping->i_pages, folio_index(folio), 2958 - PAGECACHE_TAG_WRITEBACK); 2959 - if (bdi->capabilities & BDI_CAP_WRITEBACK_ACCT) { 2960 - struct bdi_writeback *wb = inode_to_wb(inode); 2956 + folio_test_clear_writeback(folio); 2957 + __xa_clear_mark(&mapping->i_pages, folio_index(folio), 2958 + PAGECACHE_TAG_WRITEBACK); 2959 + if (bdi->capabilities & BDI_CAP_WRITEBACK_ACCT) { 2960 + struct bdi_writeback *wb = inode_to_wb(inode); 2961 2961 2962 - wb_stat_mod(wb, WB_WRITEBACK, -nr); 2963 - __wb_writeout_add(wb, nr); 2964 - if (!mapping_tagged(mapping, 2965 - PAGECACHE_TAG_WRITEBACK)) 2966 - wb_inode_writeback_end(wb); 2967 - } 2962 + wb_stat_mod(wb, WB_WRITEBACK, -nr); 2963 + __wb_writeout_add(wb, nr); 2964 + if (!mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) 2965 + wb_inode_writeback_end(wb); 2968 2966 } 2969 2967 2970 2968 if (mapping->host && !mapping_tagged(mapping, ··· 2970 2974 2971 2975 xa_unlock_irqrestore(&mapping->i_pages, flags); 2972 2976 } else { 2973 - ret = folio_test_clear_writeback(folio); 2977 + folio_test_clear_writeback(folio); 2974 2978 } 2975 - if (ret) { 2976 - lruvec_stat_mod_folio(folio, NR_WRITEBACK, -nr); 2977 - zone_stat_mod_folio(folio, NR_ZONE_WRITE_PENDING, -nr); 2978 - node_stat_mod_folio(folio, NR_WRITTEN, nr); 2979 - } 2979 + 2980 + lruvec_stat_mod_folio(folio, NR_WRITEBACK, -nr); 2981 + zone_stat_mod_folio(folio, NR_ZONE_WRITE_PENDING, -nr); 2982 + node_stat_mod_folio(folio, NR_WRITTEN, nr); 2980 2983 folio_memcg_unlock(folio); 2981 - return ret; 2982 2984 } 2983 2985 2984 2986 bool __folio_start_writeback(struct folio *folio, bool keep_write)