Re: [PATCH v14 011/138] mm/lru: Add folio LRU functions

From
Matthew Wilcox <willy@infradead.org>
Date
2021-08-10 18:16:42
Also in
linux-fsdevel, lkml
Reply to
Vlastimil Babka, 2021-08-10
On Tue, Aug 10, 2021 at 06:01:16PM +0200, Vlastimil Babka wrote:
Actually looking at the git version, which has also this:

 static __always_inline void update_lru_size(struct lruvec *lruvec,
                                enum lru_list lru, enum zone_type zid,
-                               int nr_pages)
+                               long nr_pages)
 {

Why now and here? Some of the functions called from update_lru_size()
still take int so this looks arbitrary?
I'm still a little freaked out about the lack of warning for:

void f(long n);
void g(unsigned int n) { f(-n); }

so I've decided that the count of pages in a folio is always of type
long.  The actual number is positive, and currently it's between 1 and
1024 (inclusive on both bounds), so it's always going to be
representable in an int.  Narrowing it doesn't cause a bug, so we don't
need to change nr_pages anywhere, but it does no harm to make functions
take a long instead of an int (it may even cause slightly better code
generation, based on the sample of functions I've looked at).

Maybe changing update_lru_size() in this patch is wrong.  I can drop it
if you like.
Thread (389 messages) 389 messages, 13 authors, last reply 2021-08-21
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help