Message ID | 20230313124526.1207490-1-fengwei.yin@intel.com (mailing list archive) |
---|---|
Headers | show |
Series | batched remove rmap in try_to_unmap_one() | expand |
On Mon, 13 Mar 2023 20:45:21 +0800 Yin Fengwei <fengwei.yin@intel.com> wrote: > This series is trying to bring the batched rmap removing to > try_to_unmap_one(). It's expected that the batched rmap > removing bring performance gain than remove rmap per page. > > This series reconstruct the try_to_unmap_one() from: > loop: > clear and update PTE > unmap one page > goto loop > to: > loop: > clear and update PTE > goto loop > unmap the range of folio in one call > It is one step to always map/unmap the entire folio in one call. > Which can simplify the folio mapcount handling by avoid dealing > with each page map/unmap. > > ... > > For performance gain demonstration, changed the MADV_PAGEOUT not > to split the large folio for page cache and created a micro > benchmark mainly as following: Please remind me why it's necessary to patch the kernel to actually performance test this? And why it's proving so hard to demonstrate benefits in real-world workloads? (Yes, this was touched on in earlier discussion, but I do think these considerations should be spelled out in the [0/N] changelog). Thanks.
On 3/14/23 02:49, Andrew Morton wrote: > On Mon, 13 Mar 2023 20:45:21 +0800 Yin Fengwei <fengwei.yin@intel.com> wrote: > >> This series is trying to bring the batched rmap removing to >> try_to_unmap_one(). It's expected that the batched rmap >> removing bring performance gain than remove rmap per page. >> >> This series reconstruct the try_to_unmap_one() from: >> loop: >> clear and update PTE >> unmap one page >> goto loop >> to: >> loop: >> clear and update PTE >> goto loop >> unmap the range of folio in one call >> It is one step to always map/unmap the entire folio in one call. >> Which can simplify the folio mapcount handling by avoid dealing >> with each page map/unmap. >> >> ... >> >> For performance gain demonstration, changed the MADV_PAGEOUT not >> to split the large folio for page cache and created a micro >> benchmark mainly as following: > > Please remind me why it's necessary to patch the kernel to actually > performance test this? And why it's proving so hard to demonstrate > benefits in real-world workloads? > > (Yes, this was touched on in earlier discussion, but I do think these > considerations should be spelled out in the [0/N] changelog). OK. What about add following in cover letter: " The performance gain of this series can be demonstrated with large folio reclaim. In current kernel, vmscan() path will be benefited by the changes. But there is no workload/benchmark can show the exact performance gain for vmscan() path as far as I am aware. Another way to demonstrate the performance benefit is using MADV_PAGEOUT which can trigger page reclaim also. The problem is that MADV_PAGEOUT always split the large folio because it's not aware of large folio for page cache currently. To show the performance benefit, MADV_PAGEOUT is updated not to split the large folio. For long term with wider adoption of large folio in kernel (like large folio for anonymous page), MADV_PAGEOUT needs be updated to handle large folio as whole to avoid splitting it always. " Regards Yin, Fengwei > > Thanks.
On 14.03.23 04:09, Yin Fengwei wrote: > On 3/14/23 02:49, Andrew Morton wrote: >> On Mon, 13 Mar 2023 20:45:21 +0800 Yin Fengwei <fengwei.yin@intel.com> wrote: >> >>> This series is trying to bring the batched rmap removing to >>> try_to_unmap_one(). It's expected that the batched rmap >>> removing bring performance gain than remove rmap per page. >>> >>> This series reconstruct the try_to_unmap_one() from: >>> loop: >>> clear and update PTE >>> unmap one page >>> goto loop >>> to: >>> loop: >>> clear and update PTE >>> goto loop >>> unmap the range of folio in one call >>> It is one step to always map/unmap the entire folio in one call. >>> Which can simplify the folio mapcount handling by avoid dealing >>> with each page map/unmap. >>> >>> ... >>> >>> For performance gain demonstration, changed the MADV_PAGEOUT not >>> to split the large folio for page cache and created a micro >>> benchmark mainly as following: >> >> Please remind me why it's necessary to patch the kernel to actually >> performance test this? And why it's proving so hard to demonstrate >> benefits in real-world workloads? >> >> (Yes, this was touched on in earlier discussion, but I do think these >> considerations should be spelled out in the [0/N] changelog). > OK. What about add following in cover letter: > " > The performance gain of this series can be demonstrated with large > folio reclaim. In current kernel, vmscan() path will be benefited by > the changes. But there is no workload/benchmark can show the exact > performance gain for vmscan() path as far as I am aware. > > Another way to demonstrate the performance benefit is using > MADV_PAGEOUT which can trigger page reclaim also. The problem is that > MADV_PAGEOUT always split the large folio because it's not aware of > large folio for page cache currently. To show the performance benefit, > MADV_PAGEOUT is updated not to split the large folio. > > For long term with wider adoption of large folio in kernel (like large > folio for anonymous page), MADV_PAGEOUT needs be updated to handle > large folio as whole to avoid splitting it always. Just curious what the last sentence implies. Large folios are supposed to be a transparent optimization. So why should we pageout all surrounding subpages simply because a single subpage was requested to be paged out? That might harm performance of some workloads ... more than the actual split. So it's not immediately obvious to me why "avoid splitting" is the correct answer to the problem at hand.
On Tue, Mar 14, 2023 at 10:16:09AM +0100, David Hildenbrand wrote: > On 14.03.23 04:09, Yin Fengwei wrote: > > For long term with wider adoption of large folio in kernel (like large > > folio for anonymous page), MADV_PAGEOUT needs be updated to handle > > large folio as whole to avoid splitting it always. > > Just curious what the last sentence implies. Large folios are supposed to be > a transparent optimization. So why should we pageout all surrounding > subpages simply because a single subpage was requested to be paged out? That > might harm performance of some workloads ... more than the actual split. > > So it's not immediately obvious to me why "avoid splitting" is the correct > answer to the problem at hand. Even if your madvise() call says to pageout all pages covered by a folio, the current code will split it. That's what needs to be fixed. At least for anonymous pages, using large folios is an attempt to treat all pages in a particular range the same way. If the user says to only page out some of them, that's a big clue that these pages are different from the other pages, and so we should split a folio where the madvise call does not cover every page in the folio. I'm less convinced that argument holds for page cache pages.
On 14.03.23 10:48, Matthew Wilcox wrote: > On Tue, Mar 14, 2023 at 10:16:09AM +0100, David Hildenbrand wrote: >> On 14.03.23 04:09, Yin Fengwei wrote: >>> For long term with wider adoption of large folio in kernel (like large >>> folio for anonymous page), MADV_PAGEOUT needs be updated to handle >>> large folio as whole to avoid splitting it always. >> >> Just curious what the last sentence implies. Large folios are supposed to be >> a transparent optimization. So why should we pageout all surrounding >> subpages simply because a single subpage was requested to be paged out? That >> might harm performance of some workloads ... more than the actual split. >> >> So it's not immediately obvious to me why "avoid splitting" is the correct >> answer to the problem at hand. > > Even if your madvise() call says to pageout all pages covered by a > folio, the current code will split it. That's what needs to be fixed. Agreed, if possible in the future (swap handling ...). > > At least for anonymous pages, using large folios is an attempt to treat > all pages in a particular range the same way. If the user says to only > page out some of them, that's a big clue that these pages are different > from the other pages, and so we should split a folio where the madvise > call does not cover every page in the folio. Agreed.
On 3/14/2023 5:48 PM, Matthew Wilcox wrote: > On Tue, Mar 14, 2023 at 10:16:09AM +0100, David Hildenbrand wrote: >> On 14.03.23 04:09, Yin Fengwei wrote: >>> For long term with wider adoption of large folio in kernel (like large >>> folio for anonymous page), MADV_PAGEOUT needs be updated to handle >>> large folio as whole to avoid splitting it always. >> >> Just curious what the last sentence implies. Large folios are supposed to be >> a transparent optimization. So why should we pageout all surrounding >> subpages simply because a single subpage was requested to be paged out? That >> might harm performance of some workloads ... more than the actual split. >> >> So it's not immediately obvious to me why "avoid splitting" is the correct >> answer to the problem at hand. > > Even if your madvise() call says to pageout all pages covered by a > folio, the current code will split it. That's what needs to be fixed. Yes. This is my understanding. > > At least for anonymous pages, using large folios is an attempt to treat > all pages in a particular range the same way. If the user says to only > page out some of them, that's a big clue that these pages are different > from the other pages, and so we should split a folio where the madvise > call does not cover every page in the folio. Yes. This is my understanding also. :). > > I'm less convinced that argument holds for page cache pages. Can you explain more about this? My understanding is that if we need to reclaim the large folio for page cache, it's better to reclaim the whole folio. Regards Yin, Fengwei
On Tue, Mar 14, 2023 at 10:50:36PM +0800, Yin, Fengwei wrote: > On 3/14/2023 5:48 PM, Matthew Wilcox wrote: > > On Tue, Mar 14, 2023 at 10:16:09AM +0100, David Hildenbrand wrote: > >> Just curious what the last sentence implies. Large folios are supposed to be > >> a transparent optimization. So why should we pageout all surrounding > >> subpages simply because a single subpage was requested to be paged out? That > >> might harm performance of some workloads ... more than the actual split. > >> > >> So it's not immediately obvious to me why "avoid splitting" is the correct > >> answer to the problem at hand. > > > > At least for anonymous pages, using large folios is an attempt to treat > > all pages in a particular range the same way. If the user says to only > > page out some of them, that's a big clue that these pages are different > > from the other pages, and so we should split a folio where the madvise > > call does not cover every page in the folio. > > Yes. This is my understanding also. :). > > > I'm less convinced that argument holds for page cache pages. > > Can you explain more about this? My understanding is that if we need > to reclaim the large folio for page cache, it's better to reclaim the > whole folio. Pagecache is a shared resource. To determine how best to handle all the memory used to cache a file (ie the correct folio size), ideally we would take into account how all the users of a particular file are using it. If we just listen to the most recent advice from one user, we risk making a decision that's bad for potentially many other users. Of course, we don't have any framework for deciding the correct folio size used for pagecache yet. We have the initial guess based on readahead and we have various paths that will split back to individual pages. But it's something I know we'll want to do at some point.
On 3/14/23 23:01, Matthew Wilcox wrote: > On Tue, Mar 14, 2023 at 10:50:36PM +0800, Yin, Fengwei wrote: >> On 3/14/2023 5:48 PM, Matthew Wilcox wrote: >>> On Tue, Mar 14, 2023 at 10:16:09AM +0100, David Hildenbrand wrote: >>>> Just curious what the last sentence implies. Large folios are supposed to be >>>> a transparent optimization. So why should we pageout all surrounding >>>> subpages simply because a single subpage was requested to be paged out? That >>>> might harm performance of some workloads ... more than the actual split. >>>> >>>> So it's not immediately obvious to me why "avoid splitting" is the correct >>>> answer to the problem at hand. >>> >>> At least for anonymous pages, using large folios is an attempt to treat >>> all pages in a particular range the same way. If the user says to only >>> page out some of them, that's a big clue that these pages are different >>> from the other pages, and so we should split a folio where the madvise >>> call does not cover every page in the folio. >> >> Yes. This is my understanding also. :). >> >>> I'm less convinced that argument holds for page cache pages. >> >> Can you explain more about this? My understanding is that if we need >> to reclaim the large folio for page cache, it's better to reclaim the >> whole folio. > > Pagecache is a shared resource. To determine how best to handle all > the memory used to cache a file (ie the correct folio size), ideally > we would take into account how all the users of a particular file are > using it. If we just listen to the most recent advice from one user, > we risk making a decision that's bad for potentially many other users. > > Of course, we don't have any framework for deciding the correct folio size > used for pagecache yet. We have the initial guess based on readahead > and we have various paths that will split back to individual pages. > But it's something I know we'll want to do at some point. Thanks a lot for detail explanation. Regards Yin, Fengwei
Hi Andrew, David, On 3/14/2023 11:09 AM, Yin Fengwei wrote: > On 3/14/23 02:49, Andrew Morton wrote: >> On Mon, 13 Mar 2023 20:45:21 +0800 Yin Fengwei <fengwei.yin@intel.com> wrote: >> >>> This series is trying to bring the batched rmap removing to >>> try_to_unmap_one(). It's expected that the batched rmap >>> removing bring performance gain than remove rmap per page. >>> >>> This series reconstruct the try_to_unmap_one() from: >>> loop: >>> clear and update PTE >>> unmap one page >>> goto loop >>> to: >>> loop: >>> clear and update PTE >>> goto loop >>> unmap the range of folio in one call >>> It is one step to always map/unmap the entire folio in one call. >>> Which can simplify the folio mapcount handling by avoid dealing >>> with each page map/unmap. >>> >>> ... >>> >>> For performance gain demonstration, changed the MADV_PAGEOUT not >>> to split the large folio for page cache and created a micro >>> benchmark mainly as following: >> >> Please remind me why it's necessary to patch the kernel to actually >> performance test this? And why it's proving so hard to demonstrate >> benefits in real-world workloads? >> >> (Yes, this was touched on in earlier discussion, but I do think these >> considerations should be spelled out in the [0/N] changelog). > OK. What about add following in cover letter: > " > The performance gain of this series can be demonstrated with large > folio reclaim. In current kernel, vmscan() path will be benefited by > the changes. But there is no workload/benchmark can show the exact > performance gain for vmscan() path as far as I am aware. > > Another way to demonstrate the performance benefit is using > MADV_PAGEOUT which can trigger page reclaim also. The problem is that > MADV_PAGEOUT always split the large folio because it's not aware of > large folio for page cache currently. To show the performance benefit, > MADV_PAGEOUT is updated not to split the large folio. > > For long term with wider adoption of large folio in kernel (like large > folio for anonymous page), MADV_PAGEOUT needs be updated to handle > large folio as whole to avoid splitting it always. > " I just want to check how I can move this work forward. Is it enough by adding above message? Or still need some other work be done first? Thanks. Regards Yin, Fengwei > > > Regards > Yin, Fengwei > >> >> Thanks. >
On 20.03.23 14:47, Yin, Fengwei wrote: > Hi Andrew, David, > > On 3/14/2023 11:09 AM, Yin Fengwei wrote: >> On 3/14/23 02:49, Andrew Morton wrote: >>> On Mon, 13 Mar 2023 20:45:21 +0800 Yin Fengwei <fengwei.yin@intel.com> wrote: >>> >>>> This series is trying to bring the batched rmap removing to >>>> try_to_unmap_one(). It's expected that the batched rmap >>>> removing bring performance gain than remove rmap per page. >>>> >>>> This series reconstruct the try_to_unmap_one() from: >>>> loop: >>>> clear and update PTE >>>> unmap one page >>>> goto loop >>>> to: >>>> loop: >>>> clear and update PTE >>>> goto loop >>>> unmap the range of folio in one call >>>> It is one step to always map/unmap the entire folio in one call. >>>> Which can simplify the folio mapcount handling by avoid dealing >>>> with each page map/unmap. >>>> >>>> ... >>>> >>>> For performance gain demonstration, changed the MADV_PAGEOUT not >>>> to split the large folio for page cache and created a micro >>>> benchmark mainly as following: >>> >>> Please remind me why it's necessary to patch the kernel to actually >>> performance test this? And why it's proving so hard to demonstrate >>> benefits in real-world workloads? >>> >>> (Yes, this was touched on in earlier discussion, but I do think these >>> considerations should be spelled out in the [0/N] changelog). >> OK. What about add following in cover letter: >> " >> The performance gain of this series can be demonstrated with large >> folio reclaim. In current kernel, vmscan() path will be benefited by >> the changes. But there is no workload/benchmark can show the exact >> performance gain for vmscan() path as far as I am aware. >> >> Another way to demonstrate the performance benefit is using >> MADV_PAGEOUT which can trigger page reclaim also. The problem is that >> MADV_PAGEOUT always split the large folio because it's not aware of >> large folio for page cache currently. To show the performance benefit, >> MADV_PAGEOUT is updated not to split the large folio. >> >> For long term with wider adoption of large folio in kernel (like large >> folio for anonymous page), MADV_PAGEOUT needs be updated to handle >> large folio as whole to avoid splitting it always. >> " > I just want to check how I can move this work forward. Is it enough > by adding above message? Or still need some other work be done first? Thanks. I think Andrew can add that, no need to resend. But we should see more review (I'm fairly busy ...).
On 3/21/23 22:17, David Hildenbrand wrote: > On 20.03.23 14:47, Yin, Fengwei wrote: >> Hi Andrew, David, >> >> On 3/14/2023 11:09 AM, Yin Fengwei wrote: >>> On 3/14/23 02:49, Andrew Morton wrote: >>>> On Mon, 13 Mar 2023 20:45:21 +0800 Yin Fengwei >>>> <fengwei.yin@intel.com> wrote: >>>> >>>>> This series is trying to bring the batched rmap removing to >>>>> try_to_unmap_one(). It's expected that the batched rmap >>>>> removing bring performance gain than remove rmap per page. >>>>> >>>>> This series reconstruct the try_to_unmap_one() from: >>>>> loop: >>>>> clear and update PTE >>>>> unmap one page >>>>> goto loop >>>>> to: >>>>> loop: >>>>> clear and update PTE >>>>> goto loop >>>>> unmap the range of folio in one call >>>>> It is one step to always map/unmap the entire folio in one call. >>>>> Which can simplify the folio mapcount handling by avoid dealing >>>>> with each page map/unmap. >>>>> >>>>> ... >>>>> >>>>> For performance gain demonstration, changed the MADV_PAGEOUT not >>>>> to split the large folio for page cache and created a micro >>>>> benchmark mainly as following: >>>> >>>> Please remind me why it's necessary to patch the kernel to actually >>>> performance test this? And why it's proving so hard to demonstrate >>>> benefits in real-world workloads? >>>> >>>> (Yes, this was touched on in earlier discussion, but I do think these >>>> considerations should be spelled out in the [0/N] changelog). >>> OK. What about add following in cover letter: >>> " >>> The performance gain of this series can be demonstrated with large >>> folio reclaim. In current kernel, vmscan() path will be benefited by >>> the changes. But there is no workload/benchmark can show the exact >>> performance gain for vmscan() path as far as I am aware. >>> >>> Another way to demonstrate the performance benefit is using >>> MADV_PAGEOUT which can trigger page reclaim also. The problem is that >>> MADV_PAGEOUT always split the large folio because it's not aware of >>> large folio for page cache currently. To show the performance benefit, >>> MADV_PAGEOUT is updated not to split the large folio. >>> >>> For long term with wider adoption of large folio in kernel (like large >>> folio for anonymous page), MADV_PAGEOUT needs be updated to handle >>> large folio as whole to avoid splitting it always. >>> " >> I just want to check how I can move this work forward. Is it enough >> by adding above message? Or still need some other work be done first? >> Thanks. > > I think Andrew can add that, no need to resend. But we should see more > review (I'm fairly busy ...). OK. Regards Yin, Fengwei >