Skip to content

Commit 1a0fc81

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
mm: rename invalidate_mapping_pagevec to mapping_try_invalidate
We don't use pagevecs for the LRU cache any more, and we don't know that the failed invalidations were due to the folio being in an LRU cache. So rename it to be more accurate. Link: https://lkml.kernel.org/r/20230621164557.3510324-12-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 1e0877d commit 1a0fc81

3 files changed

Lines changed: 21 additions & 24 deletions

File tree

mm/fadvise.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ int generic_fadvise(struct file *file, loff_t offset, loff_t len, int advice)
143143
}
144144

145145
if (end_index >= start_index) {
146-
unsigned long nr_pagevec = 0;
146+
unsigned long nr_failed = 0;
147147

148148
/*
149149
* It's common to FADV_DONTNEED right after
@@ -156,17 +156,15 @@ int generic_fadvise(struct file *file, loff_t offset, loff_t len, int advice)
156156
*/
157157
lru_add_drain();
158158

159-
invalidate_mapping_pagevec(mapping,
160-
start_index, end_index,
161-
&nr_pagevec);
159+
mapping_try_invalidate(mapping, start_index, end_index,
160+
&nr_failed);
162161

163162
/*
164-
* If fewer pages were invalidated than expected then
165-
* it is possible that some of the pages were on
166-
* a per-cpu pagevec for a remote CPU. Drain all
167-
* pagevecs and try again.
163+
* The failures may be due to the folio being
164+
* in the LRU cache of a remote CPU. Drain all
165+
* caches and try again.
168166
*/
169-
if (nr_pagevec) {
167+
if (nr_failed) {
170168
lru_add_drain_all();
171169
invalidate_mapping_pages(mapping, start_index,
172170
end_index);

mm/internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ int truncate_inode_folio(struct address_space *mapping, struct folio *folio);
133133
bool truncate_inode_partial_folio(struct folio *folio, loff_t start,
134134
loff_t end);
135135
long invalidate_inode_page(struct page *page);
136-
unsigned long invalidate_mapping_pagevec(struct address_space *mapping,
137-
pgoff_t start, pgoff_t end, unsigned long *nr_pagevec);
136+
unsigned long mapping_try_invalidate(struct address_space *mapping,
137+
pgoff_t start, pgoff_t end, unsigned long *nr_failed);
138138

139139
/**
140140
* folio_evictable - Test whether a folio is evictable.

mm/truncate.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -486,18 +486,17 @@ void truncate_inode_pages_final(struct address_space *mapping)
486486
EXPORT_SYMBOL(truncate_inode_pages_final);
487487

488488
/**
489-
* invalidate_mapping_pagevec - Invalidate all the unlocked pages of one inode
490-
* @mapping: the address_space which holds the pages to invalidate
489+
* mapping_try_invalidate - Invalidate all the evictable folios of one inode
490+
* @mapping: the address_space which holds the folios to invalidate
491491
* @start: the offset 'from' which to invalidate
492492
* @end: the offset 'to' which to invalidate (inclusive)
493-
* @nr_pagevec: invalidate failed page number for caller
493+
* @nr_failed: How many folio invalidations failed
494494
*
495-
* This helper is similar to invalidate_mapping_pages(), except that it accounts
496-
* for pages that are likely on a pagevec and counts them in @nr_pagevec, which
497-
* will be used by the caller.
495+
* This function is similar to invalidate_mapping_pages(), except that it
496+
* returns the number of folios which could not be evicted in @nr_failed.
498497
*/
499-
unsigned long invalidate_mapping_pagevec(struct address_space *mapping,
500-
pgoff_t start, pgoff_t end, unsigned long *nr_pagevec)
498+
unsigned long mapping_try_invalidate(struct address_space *mapping,
499+
pgoff_t start, pgoff_t end, unsigned long *nr_failed)
501500
{
502501
pgoff_t indices[PAGEVEC_SIZE];
503502
struct folio_batch fbatch;
@@ -527,9 +526,9 @@ unsigned long invalidate_mapping_pagevec(struct address_space *mapping,
527526
*/
528527
if (!ret) {
529528
deactivate_file_folio(folio);
530-
/* It is likely on the pagevec of a remote CPU */
531-
if (nr_pagevec)
532-
(*nr_pagevec)++;
529+
/* Likely in the lru cache of a remote CPU */
530+
if (nr_failed)
531+
(*nr_failed)++;
533532
}
534533
count += ret;
535534
}
@@ -552,12 +551,12 @@ unsigned long invalidate_mapping_pagevec(struct address_space *mapping,
552551
* If you want to remove all the pages of one inode, regardless of
553552
* their use and writeback state, use truncate_inode_pages().
554553
*
555-
* Return: the number of the cache entries that were invalidated
554+
* Return: The number of indices that had their contents invalidated
556555
*/
557556
unsigned long invalidate_mapping_pages(struct address_space *mapping,
558557
pgoff_t start, pgoff_t end)
559558
{
560-
return invalidate_mapping_pagevec(mapping, start, end, NULL);
559+
return mapping_try_invalidate(mapping, start, end, NULL);
561560
}
562561
EXPORT_SYMBOL(invalidate_mapping_pages);
563562

0 commit comments

Comments
 (0)