Message ID | 202301131550455361823@zte.com.cn (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [linux-next,v2] swap_state: update shadow_nodes for anonymous page | expand |
On Fri, Jan 13, 2023 at 03:50:45PM +0800, yang.yang29@zte.com.cn wrote: > This patch updates shadow_nodes of anonymous page when swap > cache is add or delete. By what? > diff --git a/mm/swap_state.c b/mm/swap_state.c > index cb9aaa00951d..7a003d8abb37 100644 > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -94,6 +94,8 @@ int add_to_swap_cache(struct folio *folio, swp_entry_t entry, > unsigned long i, nr = folio_nr_pages(folio); > void *old; > > + xas_set_update(&xas, workingset_update_node); > + > VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); > VM_BUG_ON_FOLIO(folio_test_swapcache(folio), folio); > VM_BUG_ON_FOLIO(!folio_test_swapbacked(folio), folio); > @@ -145,6 +147,8 @@ void __delete_from_swap_cache(struct folio *folio, > pgoff_t idx = swp_offset(entry); > XA_STATE(xas, &address_space->i_pages, idx); > > + xas_set_update(&xas, workingset_update_node); > + > VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); > VM_BUG_ON_FOLIO(!folio_test_swapcache(folio), folio); > VM_BUG_ON_FOLIO(folio_test_writeback(folio), folio); > @@ -252,6 +256,8 @@ void clear_shadow_from_swap_cache(int type, unsigned long begin, > struct address_space *address_space = swap_address_space(entry); > XA_STATE(xas, &address_space->i_pages, curr); > > + xas_set_update(&xas, workingset_update_node); > + > xa_lock_irq(&address_space->i_pages); > xas_for_each(&xas, old, end) { > if (!xa_is_value(old)) Adding xas_set_update() call? In any case, please explain what you are doing above in imperative mood (no "This patch does foo" but "Do foo" instead). Thanks.
On Fri, Jan 13, 2023 at 03:47:31PM +0700, Bagas Sanjaya wrote: > On Fri, Jan 13, 2023 at 03:50:45PM +0800, yang.yang29@zte.com.cn wrote: > > This patch updates shadow_nodes of anonymous page when swap > > cache is add or delete. > > By what? This is not a helpful question. > > @@ -252,6 +256,8 @@ void clear_shadow_from_swap_cache(int type, unsigned long begin, > > struct address_space *address_space = swap_address_space(entry); > > XA_STATE(xas, &address_space->i_pages, curr); > > > > + xas_set_update(&xas, workingset_update_node); > > + > > xa_lock_irq(&address_space->i_pages); > > xas_for_each(&xas, old, end) { > > if (!xa_is_value(old)) > > Adding xas_set_update() call? It makes perfect sense to me. > In any case, please explain what you are doing above in imperative mood > (no "This patch does foo" but "Do foo" instead). Not helpful either.
diff --git a/include/linux/xarray.h b/include/linux/xarray.h index 44dd6d6e01bc..5cc1f718fec9 100644 --- a/include/linux/xarray.h +++ b/include/linux/xarray.h @@ -1643,7 +1643,8 @@ static inline void xas_set_order(struct xa_state *xas, unsigned long index, * @update: Function to call when updating a node. * * The XArray can notify a caller after it has updated an xa_node. - * This is advanced functionality and is only needed by the page cache. + * This is advanced functionality and is only needed by the page cache + * and swap cache. */ static inline void xas_set_update(struct xa_state *xas, xa_update_node_t update) { diff --git a/mm/swap_state.c b/mm/swap_state.c index cb9aaa00951d..7a003d8abb37 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -94,6 +94,8 @@ int add_to_swap_cache(struct folio *folio, swp_entry_t entry, unsigned long i, nr = folio_nr_pages(folio); void *old; + xas_set_update(&xas, workingset_update_node); + VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); VM_BUG_ON_FOLIO(folio_test_swapcache(folio), folio); VM_BUG_ON_FOLIO(!folio_test_swapbacked(folio), folio); @@ -145,6 +147,8 @@ void __delete_from_swap_cache(struct folio *folio, pgoff_t idx = swp_offset(entry); XA_STATE(xas, &address_space->i_pages, idx); + xas_set_update(&xas, workingset_update_node); + VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); VM_BUG_ON_FOLIO(!folio_test_swapcache(folio), folio); VM_BUG_ON_FOLIO(folio_test_writeback(folio), folio); @@ -252,6 +256,8 @@ void clear_shadow_from_swap_cache(int type, unsigned long begin, struct address_space *address_space = swap_address_space(entry); XA_STATE(xas, &address_space->i_pages, curr); + xas_set_update(&xas, workingset_update_node); + xa_lock_irq(&address_space->i_pages); xas_for_each(&xas, old, end) { if (!xa_is_value(old))