On Sat, Sep 14, 2024 at 10:06:13PM +0800, Kefeng Wang wrote: > +++ b/mm/shmem.c > @@ -3228,6 +3228,7 @@ static ssize_t shmem_file_write_iter(struct kiocb *iocb, struct iov_iter *from) > { > struct file *file = iocb->ki_filp; > struct inode *inode = file->f_mapping->host; > + pgoff_t index = iocb->ki_pos >> PAGE_SHIFT; > ssize_t ret; > > inode_lock(inode); > @@ -3240,6 +3241,10 @@ static ssize_t shmem_file_write_iter(struct kiocb *iocb, struct iov_iter *from) > ret = file_update_time(file); > if (ret) > goto unlock; > + > + if (!shmem_allowable_huge_orders(inode, NULL, index, 0, false)) > + iocb->ki_flags |= IOCB_NO_LARGE_CHUNK; Wouldn't it be better to call mapping_set_folio_order_range() so we don't need this IOCB flag?