Message ID | 413866f2f2d996cfbb5c906467b36c96b1a82e2d.1718690645.git.baolin.wang@linux.alibaba.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | support large folio swap-out and swap-in for shmem | expand |
On Tue, Jun 18, 2024 at 12:54 AM Baolin Wang <baolin.wang@linux.alibaba.com> wrote: > > Add swap available space validation before spliting shmem large folio to > avoid redundant split, since we can not write shmem folio to the swap device > in this case. We don't scan anon LRU unless we know we may be able to swap. Even if there is swap space, we may still not be able to swap. See can_reclaim_anon_pages(). > Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com> > --- > mm/vmscan.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 1807e5d95dda..61465f92283f 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -1237,6 +1237,14 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, > } > } else if (folio_test_swapbacked(folio) && > folio_test_large(folio)) { > + > + /* > + * Do not split shmem folio if no swap memory > + * available. > + */ > + if (!total_swap_pages) > + goto activate_locked; > + > /* Split shmem folio */ > if (split_folio_to_list(folio, folio_list)) > goto keep_locked; > -- > 2.39.3 > >
On 2024/6/20 14:12, Yu Zhao wrote: > On Tue, Jun 18, 2024 at 12:54 AM Baolin Wang > <baolin.wang@linux.alibaba.com> wrote: >> >> Add swap available space validation before spliting shmem large folio to >> avoid redundant split, since we can not write shmem folio to the swap device >> in this case. > > We don't scan anon LRU unless we know we may be able to swap. Even if > there is swap space, we may still not be able to swap. See > can_reclaim_anon_pages(). Right. Another case is MADV_PAGEOUT can still split a large shmem folio even without a swap device. I know this is not a common case, and I can drop this patch if it is less helpful. Thanks for your input. >> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com> >> --- >> mm/vmscan.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/mm/vmscan.c b/mm/vmscan.c >> index 1807e5d95dda..61465f92283f 100644 >> --- a/mm/vmscan.c >> +++ b/mm/vmscan.c >> @@ -1237,6 +1237,14 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, >> } >> } else if (folio_test_swapbacked(folio) && >> folio_test_large(folio)) { >> + >> + /* >> + * Do not split shmem folio if no swap memory >> + * available. >> + */ >> + if (!total_swap_pages) >> + goto activate_locked; >> + >> /* Split shmem folio */ >> if (split_folio_to_list(folio, folio_list)) >> goto keep_locked; >> -- >> 2.39.3 >> >>
diff --git a/mm/vmscan.c b/mm/vmscan.c index 1807e5d95dda..61465f92283f 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1237,6 +1237,14 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, } } else if (folio_test_swapbacked(folio) && folio_test_large(folio)) { + + /* + * Do not split shmem folio if no swap memory + * available. + */ + if (!total_swap_pages) + goto activate_locked; + /* Split shmem folio */ if (split_folio_to_list(folio, folio_list)) goto keep_locked;
Add swap available space validation before spliting shmem large folio to avoid redundant split, since we can not write shmem folio to the swap device in this case. Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com> --- mm/vmscan.c | 8 ++++++++ 1 file changed, 8 insertions(+)