[PATCH v2 1/7] mm: change release_pages() to use unsigned long for npages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The various callers of release_pages() are passing in either various
types (signed or unsigned) and lengths (int or long) of integers, for
the second argument (number of pages). To make this conversion accurate
and to avoid having to check for overflow (or deal with type conversion
warnings), let's just change release_pages() to accept an unsigned long
for the number of pages.

Also change the name of the argument, from "nr" to "npages", for
clarity, as long as that line is being changed anyway.

Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>
---
 include/linux/mm.h | 2 +-
 mm/swap.c          | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 21f8b27bd9fd..61c5dc37370e 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1145,7 +1145,7 @@ static inline void folio_put_refs(struct folio *folio, int refs)
 		__folio_put(folio);
 }
 
-void release_pages(struct page **pages, int nr);
+void release_pages(struct page **pages, unsigned long npages);
 
 /**
  * folios_put - Decrement the reference count on an array of folios.
diff --git a/mm/swap.c b/mm/swap.c
index 9cee7f6a3809..ac6482d86187 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -931,15 +931,15 @@ void lru_cache_disable(void)
  * Decrement the reference count on all the pages in @pages.  If it
  * fell to zero, remove the page from the LRU and free it.
  */
-void release_pages(struct page **pages, int nr)
+void release_pages(struct page **pages, unsigned long npages)
 {
-	int i;
+	unsigned long i;
 	LIST_HEAD(pages_to_free);
 	struct lruvec *lruvec = NULL;
 	unsigned long flags = 0;
 	unsigned int lock_batch;
 
-	for (i = 0; i < nr; i++) {
+	for (i = 0; i < npages; i++) {
 		struct folio *folio = page_folio(pages[i]);
 
 		/*
-- 
2.37.2




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux