linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/mempolicy: Use a folio in do_mbind()
@ 2024-02-29 15:29 Matthew Wilcox (Oracle)
  2024-02-29 15:41 ` Gregory Price
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-02-29 15:29 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: Matthew Wilcox (Oracle)

We actually add folios to the pagelist already, but then work with them
as pages.  Removes a call to compound_head() in PageKsm() and removes
a reference to page->index.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/mempolicy.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index f60b4c99f130..adc036980713 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1356,29 +1356,30 @@ static long do_mbind(unsigned long start, unsigned long len,
 		 */
 		if (new->mode == MPOL_INTERLEAVE ||
 		    new->mode == MPOL_WEIGHTED_INTERLEAVE) {
-			struct page *page;
+			struct folio *folio;
 			unsigned int order;
 			unsigned long addr = -EFAULT;
 
-			list_for_each_entry(page, &pagelist, lru) {
-				if (!PageKsm(page))
+			list_for_each_entry(folio, &pagelist, lru) {
+				if (!folio_test_ksm(folio))
 					break;
 			}
-			if (!list_entry_is_head(page, &pagelist, lru)) {
+			if (!list_entry_is_head(folio, &pagelist, lru)) {
 				vma_iter_init(&vmi, mm, start);
 				for_each_vma_range(vmi, vma, end) {
-					addr = page_address_in_vma(page, vma);
+					addr = page_address_in_vma(
+						folio_page(folio, 0), vma);
 					if (addr != -EFAULT)
 						break;
 				}
 			}
 			if (addr != -EFAULT) {
-				order = compound_order(page);
+				order = folio_order(folio);
 				/* We already know the pol, but not the ilx */
 				mpol_cond_put(get_vma_policy(vma, addr, order,
 							     &mmpol.ilx));
 				/* Set base from which to increment by index */
-				mmpol.ilx -= page->index >> order;
+				mmpol.ilx -= folio->index >> order;
 			}
 		}
 	}
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm/mempolicy: Use a folio in do_mbind()
  2024-02-29 15:29 [PATCH] mm/mempolicy: Use a folio in do_mbind() Matthew Wilcox (Oracle)
@ 2024-02-29 15:41 ` Gregory Price
  0 siblings, 0 replies; 2+ messages in thread
From: Gregory Price @ 2024-02-29 15:41 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle); +Cc: Andrew Morton, linux-mm

On Thu, Feb 29, 2024 at 03:29:45PM +0000, Matthew Wilcox (Oracle) wrote:
> We actually add folios to the pagelist already, but then work with them
> as pages.  Removes a call to compound_head() in PageKsm() and removes
> a reference to page->index.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  mm/mempolicy.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 

Reviewed-by: Gregory Price <gregory.price@memverge.com>

> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index f60b4c99f130..adc036980713 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -1356,29 +1356,30 @@ static long do_mbind(unsigned long start, unsigned long len,
>  		 */
>  		if (new->mode == MPOL_INTERLEAVE ||
>  		    new->mode == MPOL_WEIGHTED_INTERLEAVE) {
> -			struct page *page;
> +			struct folio *folio;
>  			unsigned int order;
>  			unsigned long addr = -EFAULT;
>  
> -			list_for_each_entry(page, &pagelist, lru) {
> -				if (!PageKsm(page))
> +			list_for_each_entry(folio, &pagelist, lru) {
> +				if (!folio_test_ksm(folio))
>  					break;
>  			}
> -			if (!list_entry_is_head(page, &pagelist, lru)) {
> +			if (!list_entry_is_head(folio, &pagelist, lru)) {
>  				vma_iter_init(&vmi, mm, start);
>  				for_each_vma_range(vmi, vma, end) {
> -					addr = page_address_in_vma(page, vma);
> +					addr = page_address_in_vma(
> +						folio_page(folio, 0), vma);
>  					if (addr != -EFAULT)
>  						break;
>  				}
>  			}
>  			if (addr != -EFAULT) {
> -				order = compound_order(page);
> +				order = folio_order(folio);
>  				/* We already know the pol, but not the ilx */
>  				mpol_cond_put(get_vma_policy(vma, addr, order,
>  							     &mmpol.ilx));
>  				/* Set base from which to increment by index */
> -				mmpol.ilx -= page->index >> order;
> +				mmpol.ilx -= folio->index >> order;
>  			}
>  		}
>  	}
> -- 
> 2.43.0
> 
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-29 15:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-29 15:29 [PATCH] mm/mempolicy: Use a folio in do_mbind() Matthew Wilcox (Oracle)
2024-02-29 15:41 ` Gregory Price

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).