ret = __splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_file);
        if (ret > 0) {
+               unsigned long nr_pages;
+
                *ppos += ret;
+               nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
 
                /*
                 * If file or inode is SYNC and we actually wrote some data,
                        if (err)
                                ret = err;
                }
-               balance_dirty_pages_ratelimited(mapping);
+               balance_dirty_pages_ratelimited_nr(mapping, nr_pages);
        }
 
        return ret;
 
        ret = splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_file);
        if (ret > 0) {
+               unsigned long nr_pages;
+
                *ppos += ret;
+               nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
 
                /*
                 * If file or inode is SYNC and we actually wrote some data,
                        if (err)
                                ret = err;
                }
-               balance_dirty_pages_ratelimited(mapping);
+               balance_dirty_pages_ratelimited_nr(mapping, nr_pages);
        }
 
        return ret;