On Tue, Jun 13, 2023 at 05:54:35PM +1000, Dave Chinner wrote: > If I hadn't looked at the code closely and saw a trace with this > sort of behaviour (i.e. I understood large folios were in use, > but not exactly how they worked), I'd be very surprised to see a > weird repeated pattern of varying folio sizes. I'd probably think > it was a bug in the implementation.... > > > I'd prefer the low-risk approach for now; we can change it later! > > That's fine by me - just document the limitations and expected > behaviour in the code rather than expect people to have to discover > this behaviour for themselves. How about this? +++ b/include/linux/pagemap.h @@ -548,6 +548,17 @@ typedef unsigned int __bitwise fgf_t; #define FGP_WRITEBEGIN (FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE) +/** + * fgf_set_order - Encode a length in the fgf_t flags. + * @size: The suggested size of the folio to create. + * + * The caller of __filemap_get_folio() can use this to suggest a preferred + * size for the folio that is created. If there is already a folio at + * the index, it will be returned, no matter what its size. If a folio + * is freshly created, it may be of a different size than requested + * due to alignment constraints, memory pressure, or the presence of + * other folios at nearby indices. + */ static inline fgf_t fgf_set_order(size_t size) { unsigned int shift = ilog2(size);