mm/filemap.c:2439:9: warning: stack frame size of 2096 bytes in function 'generic_file_buffered_read'
From: kernel test robot
Date: Mon Dec 21 2020 - 01:25:44 EST
Hi Kees,
First bad commit (maybe != root cause):
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 467f8165a2b0e6accf3d0dd9c8089b1dbde29f7f
commit: cdf8a76fda4ae3b53c5a09e5a8c79e27b7b65d68 ubsan: move cc-option tests into Kconfig
date: 5 days ago
config: powerpc-randconfig-r002-20201220 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project cee1e7d14f4628d6174b33640d502bff3b54ae45)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install powerpc cross compiling tool for clang build
# apt-get install binutils-powerpc-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cdf8a76fda4ae3b53c5a09e5a8c79e27b7b65d68
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout cdf8a76fda4ae3b53c5a09e5a8c79e27b7b65d68
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
All warnings (new ones prefixed by >>):
In file included from arch/powerpc/include/asm/io.h:604:
arch/powerpc/include/asm/io-defs.h:45:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:156:1: note: expanded from here
__do_insw
^
arch/powerpc/include/asm/io.h:542:56: note: expanded from macro '__do_insw'
#define __do_insw(p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from mm/filemap.c:20:
In file included from include/linux/kernel_stat.h:9:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:10:
In file included from arch/powerpc/include/asm/hardirq.h:6:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:604:
arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:160:1: note: expanded from here
__do_insl
^
arch/powerpc/include/asm/io.h:543:56: note: expanded from macro '__do_insl'
#define __do_insl(p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from mm/filemap.c:20:
In file included from include/linux/kernel_stat.h:9:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:10:
In file included from arch/powerpc/include/asm/hardirq.h:6:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:604:
arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:164:1: note: expanded from here
__do_outsb
^
arch/powerpc/include/asm/io.h:544:58: note: expanded from macro '__do_outsb'
#define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from mm/filemap.c:20:
In file included from include/linux/kernel_stat.h:9:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:10:
In file included from arch/powerpc/include/asm/hardirq.h:6:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:604:
arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:168:1: note: expanded from here
__do_outsw
^
arch/powerpc/include/asm/io.h:545:58: note: expanded from macro '__do_outsw'
#define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from mm/filemap.c:20:
In file included from include/linux/kernel_stat.h:9:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:10:
In file included from arch/powerpc/include/asm/hardirq.h:6:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:604:
arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:172:1: note: expanded from here
__do_outsl
^
arch/powerpc/include/asm/io.h:546:58: note: expanded from macro '__do_outsl'
#define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~~~~~~~~~~~~~~~~~~~~~^
mm/filemap.c:830:14: warning: no previous prototype for function '__add_to_page_cache_locked' [-Wmissing-prototypes]
noinline int __add_to_page_cache_locked(struct page *page,
^
mm/filemap.c:830:10: note: declare 'static' if the function is not intended to be used outside of this translation unit
noinline int __add_to_page_cache_locked(struct page *page,
^
static
>> mm/filemap.c:2439:9: warning: stack frame size of 2096 bytes in function 'generic_file_buffered_read' [-Wframe-larger-than=]
ssize_t generic_file_buffered_read(struct kiocb *iocb,
^
14 warnings generated.
--
In file included from kernel/debug/gdbstub.c:35:
In file included from include/linux/serial_core.h:13:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:10:
In file included from arch/powerpc/include/asm/hardirq.h:6:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:604:
arch/powerpc/include/asm/io-defs.h:45:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:85:1: note: expanded from here
__do_insw
^
arch/powerpc/include/asm/io.h:542:56: note: expanded from macro '__do_insw'
#define __do_insw(p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from kernel/debug/gdbstub.c:35:
In file included from include/linux/serial_core.h:13:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:10:
In file included from arch/powerpc/include/asm/hardirq.h:6:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:604:
arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:89:1: note: expanded from here
__do_insl
^
arch/powerpc/include/asm/io.h:543:56: note: expanded from macro '__do_insl'
#define __do_insl(p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from kernel/debug/gdbstub.c:35:
In file included from include/linux/serial_core.h:13:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:10:
In file included from arch/powerpc/include/asm/hardirq.h:6:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:604:
arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:93:1: note: expanded from here
__do_outsb
^
arch/powerpc/include/asm/io.h:544:58: note: expanded from macro '__do_outsb'
#define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from kernel/debug/gdbstub.c:35:
In file included from include/linux/serial_core.h:13:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:10:
In file included from arch/powerpc/include/asm/hardirq.h:6:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:604:
arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:97:1: note: expanded from here
__do_outsw
^
arch/powerpc/include/asm/io.h:545:58: note: expanded from macro '__do_outsw'
#define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from kernel/debug/gdbstub.c:35:
In file included from include/linux/serial_core.h:13:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:10:
In file included from arch/powerpc/include/asm/hardirq.h:6:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:604:
arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:101:1: note: expanded from here
__do_outsl
^
arch/powerpc/include/asm/io.h:546:58: note: expanded from macro '__do_outsl'
#define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~~~~~~~~~~~~~~~~~~~~~^
>> kernel/debug/gdbstub.c:957:5: warning: stack frame size of 2192 bytes in function 'gdb_serial_stub' [-Wframe-larger-than=]
int gdb_serial_stub(struct kgdb_state *ks)
^
13 warnings generated.
vim +/generic_file_buffered_read +2439 mm/filemap.c
06c0444290cecf0 Kent Overstreet 2020-12-14 2422
723ef24b9b379e5 Kent Overstreet 2020-12-14 2423 /**
723ef24b9b379e5 Kent Overstreet 2020-12-14 2424 * generic_file_buffered_read - generic file read routine
723ef24b9b379e5 Kent Overstreet 2020-12-14 2425 * @iocb: the iocb to read
723ef24b9b379e5 Kent Overstreet 2020-12-14 2426 * @iter: data destination
723ef24b9b379e5 Kent Overstreet 2020-12-14 2427 * @written: already copied
723ef24b9b379e5 Kent Overstreet 2020-12-14 2428 *
723ef24b9b379e5 Kent Overstreet 2020-12-14 2429 * This is a generic file read routine, and uses the
723ef24b9b379e5 Kent Overstreet 2020-12-14 2430 * mapping->a_ops->readpage() function for the actual low-level stuff.
723ef24b9b379e5 Kent Overstreet 2020-12-14 2431 *
723ef24b9b379e5 Kent Overstreet 2020-12-14 2432 * This is really ugly. But the goto's actually try to clarify some
723ef24b9b379e5 Kent Overstreet 2020-12-14 2433 * of the logic when it comes to error handling etc.
723ef24b9b379e5 Kent Overstreet 2020-12-14 2434 *
723ef24b9b379e5 Kent Overstreet 2020-12-14 2435 * Return:
723ef24b9b379e5 Kent Overstreet 2020-12-14 2436 * * total number of bytes copied, including those the were already @written
723ef24b9b379e5 Kent Overstreet 2020-12-14 2437 * * negative error code if nothing was copied
723ef24b9b379e5 Kent Overstreet 2020-12-14 2438 */
723ef24b9b379e5 Kent Overstreet 2020-12-14 @2439 ssize_t generic_file_buffered_read(struct kiocb *iocb,
723ef24b9b379e5 Kent Overstreet 2020-12-14 2440 struct iov_iter *iter, ssize_t written)
723ef24b9b379e5 Kent Overstreet 2020-12-14 2441 {
723ef24b9b379e5 Kent Overstreet 2020-12-14 2442 struct file *filp = iocb->ki_filp;
06c0444290cecf0 Kent Overstreet 2020-12-14 2443 struct file_ra_state *ra = &filp->f_ra;
723ef24b9b379e5 Kent Overstreet 2020-12-14 2444 struct address_space *mapping = filp->f_mapping;
723ef24b9b379e5 Kent Overstreet 2020-12-14 2445 struct inode *inode = mapping->host;
06c0444290cecf0 Kent Overstreet 2020-12-14 2446 struct page *pages_onstack[PAGEVEC_SIZE], **pages = NULL;
06c0444290cecf0 Kent Overstreet 2020-12-14 2447 unsigned int nr_pages = min_t(unsigned int, 512,
06c0444290cecf0 Kent Overstreet 2020-12-14 2448 ((iocb->ki_pos + iter->count + PAGE_SIZE - 1) >> PAGE_SHIFT) -
06c0444290cecf0 Kent Overstreet 2020-12-14 2449 (iocb->ki_pos >> PAGE_SHIFT));
06c0444290cecf0 Kent Overstreet 2020-12-14 2450 int i, pg_nr, error = 0;
06c0444290cecf0 Kent Overstreet 2020-12-14 2451 bool writably_mapped;
06c0444290cecf0 Kent Overstreet 2020-12-14 2452 loff_t isize, end_offset;
723ef24b9b379e5 Kent Overstreet 2020-12-14 2453
723ef24b9b379e5 Kent Overstreet 2020-12-14 2454 if (unlikely(iocb->ki_pos >= inode->i_sb->s_maxbytes))
723ef24b9b379e5 Kent Overstreet 2020-12-14 2455 return 0;
723ef24b9b379e5 Kent Overstreet 2020-12-14 2456 iov_iter_truncate(iter, inode->i_sb->s_maxbytes);
723ef24b9b379e5 Kent Overstreet 2020-12-14 2457
06c0444290cecf0 Kent Overstreet 2020-12-14 2458 if (nr_pages > ARRAY_SIZE(pages_onstack))
06c0444290cecf0 Kent Overstreet 2020-12-14 2459 pages = kmalloc_array(nr_pages, sizeof(void *), GFP_KERNEL);
06c0444290cecf0 Kent Overstreet 2020-12-14 2460
06c0444290cecf0 Kent Overstreet 2020-12-14 2461 if (!pages) {
06c0444290cecf0 Kent Overstreet 2020-12-14 2462 pages = pages_onstack;
06c0444290cecf0 Kent Overstreet 2020-12-14 2463 nr_pages = min_t(unsigned int, nr_pages, ARRAY_SIZE(pages_onstack));
06c0444290cecf0 Kent Overstreet 2020-12-14 2464 }
06c0444290cecf0 Kent Overstreet 2020-12-14 2465
06c0444290cecf0 Kent Overstreet 2020-12-14 2466 do {
06c0444290cecf0 Kent Overstreet 2020-12-14 2467 cond_resched();
723ef24b9b379e5 Kent Overstreet 2020-12-14 2468
^1da177e4c3f415 Linus Torvalds 2005-04-16 2469 /*
723ef24b9b379e5 Kent Overstreet 2020-12-14 2470 * If we've already successfully copied some data, then we
723ef24b9b379e5 Kent Overstreet 2020-12-14 2471 * can no longer safely return -EIOCBQUEUED. Hence mark
723ef24b9b379e5 Kent Overstreet 2020-12-14 2472 * an async read NOWAIT at that point.
^1da177e4c3f415 Linus Torvalds 2005-04-16 2473 */
06c0444290cecf0 Kent Overstreet 2020-12-14 2474 if ((iocb->ki_flags & IOCB_WAITQ) && written)
723ef24b9b379e5 Kent Overstreet 2020-12-14 2475 iocb->ki_flags |= IOCB_NOWAIT;
^1da177e4c3f415 Linus Torvalds 2005-04-16 2476
06c0444290cecf0 Kent Overstreet 2020-12-14 2477 i = 0;
06c0444290cecf0 Kent Overstreet 2020-12-14 2478 pg_nr = generic_file_buffered_read_get_pages(iocb, iter,
06c0444290cecf0 Kent Overstreet 2020-12-14 2479 pages, nr_pages);
06c0444290cecf0 Kent Overstreet 2020-12-14 2480 if (pg_nr < 0) {
06c0444290cecf0 Kent Overstreet 2020-12-14 2481 error = pg_nr;
06c0444290cecf0 Kent Overstreet 2020-12-14 2482 break;
723ef24b9b379e5 Kent Overstreet 2020-12-14 2483 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 2484
^1da177e4c3f415 Linus Torvalds 2005-04-16 2485 /*
06c0444290cecf0 Kent Overstreet 2020-12-14 2486 * i_size must be checked after we know the pages are Uptodate.
06c0444290cecf0 Kent Overstreet 2020-12-14 2487 *
06c0444290cecf0 Kent Overstreet 2020-12-14 2488 * Checking i_size after the check allows us to calculate
06c0444290cecf0 Kent Overstreet 2020-12-14 2489 * the correct value for "nr", which means the zero-filled
06c0444290cecf0 Kent Overstreet 2020-12-14 2490 * part of the page is not copied back to userspace (unless
06c0444290cecf0 Kent Overstreet 2020-12-14 2491 * another truncate extends the file - this is desired though).
^1da177e4c3f415 Linus Torvalds 2005-04-16 2492 */
06c0444290cecf0 Kent Overstreet 2020-12-14 2493 isize = i_size_read(inode);
06c0444290cecf0 Kent Overstreet 2020-12-14 2494 if (unlikely(iocb->ki_pos >= isize))
06c0444290cecf0 Kent Overstreet 2020-12-14 2495 goto put_pages;
723ef24b9b379e5 Kent Overstreet 2020-12-14 2496
06c0444290cecf0 Kent Overstreet 2020-12-14 2497 end_offset = min_t(loff_t, isize, iocb->ki_pos + iter->count);
723ef24b9b379e5 Kent Overstreet 2020-12-14 2498
06c0444290cecf0 Kent Overstreet 2020-12-14 2499 while ((iocb->ki_pos >> PAGE_SHIFT) + pg_nr >
06c0444290cecf0 Kent Overstreet 2020-12-14 2500 (end_offset + PAGE_SIZE - 1) >> PAGE_SHIFT)
06c0444290cecf0 Kent Overstreet 2020-12-14 2501 put_page(pages[--pg_nr]);
723ef24b9b379e5 Kent Overstreet 2020-12-14 2502
06c0444290cecf0 Kent Overstreet 2020-12-14 2503 /*
06c0444290cecf0 Kent Overstreet 2020-12-14 2504 * Once we start copying data, we don't want to be touching any
06c0444290cecf0 Kent Overstreet 2020-12-14 2505 * cachelines that might be contended:
06c0444290cecf0 Kent Overstreet 2020-12-14 2506 */
06c0444290cecf0 Kent Overstreet 2020-12-14 2507 writably_mapped = mapping_writably_mapped(mapping);
06c0444290cecf0 Kent Overstreet 2020-12-14 2508
06c0444290cecf0 Kent Overstreet 2020-12-14 2509 /*
06c0444290cecf0 Kent Overstreet 2020-12-14 2510 * When a sequential read accesses a page several times, only
06c0444290cecf0 Kent Overstreet 2020-12-14 2511 * mark it as accessed the first time.
06c0444290cecf0 Kent Overstreet 2020-12-14 2512 */
06c0444290cecf0 Kent Overstreet 2020-12-14 2513 if (iocb->ki_pos >> PAGE_SHIFT !=
06c0444290cecf0 Kent Overstreet 2020-12-14 2514 ra->prev_pos >> PAGE_SHIFT)
06c0444290cecf0 Kent Overstreet 2020-12-14 2515 mark_page_accessed(pages[0]);
06c0444290cecf0 Kent Overstreet 2020-12-14 2516 for (i = 1; i < pg_nr; i++)
06c0444290cecf0 Kent Overstreet 2020-12-14 2517 mark_page_accessed(pages[i]);
06c0444290cecf0 Kent Overstreet 2020-12-14 2518
06c0444290cecf0 Kent Overstreet 2020-12-14 2519 for (i = 0; i < pg_nr; i++) {
06c0444290cecf0 Kent Overstreet 2020-12-14 2520 unsigned int offset = iocb->ki_pos & ~PAGE_MASK;
06c0444290cecf0 Kent Overstreet 2020-12-14 2521 unsigned int bytes = min_t(loff_t, end_offset - iocb->ki_pos,
06c0444290cecf0 Kent Overstreet 2020-12-14 2522 PAGE_SIZE - offset);
06c0444290cecf0 Kent Overstreet 2020-12-14 2523 unsigned int copied;
06c0444290cecf0 Kent Overstreet 2020-12-14 2524
06c0444290cecf0 Kent Overstreet 2020-12-14 2525 /*
06c0444290cecf0 Kent Overstreet 2020-12-14 2526 * If users can be writing to this page using arbitrary
06c0444290cecf0 Kent Overstreet 2020-12-14 2527 * virtual addresses, take care about potential aliasing
06c0444290cecf0 Kent Overstreet 2020-12-14 2528 * before reading the page on the kernel side.
06c0444290cecf0 Kent Overstreet 2020-12-14 2529 */
06c0444290cecf0 Kent Overstreet 2020-12-14 2530 if (writably_mapped)
06c0444290cecf0 Kent Overstreet 2020-12-14 2531 flush_dcache_page(pages[i]);
06c0444290cecf0 Kent Overstreet 2020-12-14 2532
06c0444290cecf0 Kent Overstreet 2020-12-14 2533 copied = copy_page_to_iter(pages[i], offset, bytes, iter);
06c0444290cecf0 Kent Overstreet 2020-12-14 2534
06c0444290cecf0 Kent Overstreet 2020-12-14 2535 written += copied;
06c0444290cecf0 Kent Overstreet 2020-12-14 2536 iocb->ki_pos += copied;
06c0444290cecf0 Kent Overstreet 2020-12-14 2537 ra->prev_pos = iocb->ki_pos;
06c0444290cecf0 Kent Overstreet 2020-12-14 2538
06c0444290cecf0 Kent Overstreet 2020-12-14 2539 if (copied < bytes) {
06c0444290cecf0 Kent Overstreet 2020-12-14 2540 error = -EFAULT;
06c0444290cecf0 Kent Overstreet 2020-12-14 2541 break;
^1da177e4c3f415 Linus Torvalds 2005-04-16 2542 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 2543 }
06c0444290cecf0 Kent Overstreet 2020-12-14 2544 put_pages:
06c0444290cecf0 Kent Overstreet 2020-12-14 2545 for (i = 0; i < pg_nr; i++)
06c0444290cecf0 Kent Overstreet 2020-12-14 2546 put_page(pages[i]);
06c0444290cecf0 Kent Overstreet 2020-12-14 2547 } while (iov_iter_count(iter) && iocb->ki_pos < isize && !error);
^1da177e4c3f415 Linus Torvalds 2005-04-16 2548
^1da177e4c3f415 Linus Torvalds 2005-04-16 2549 file_accessed(filp);
06c0444290cecf0 Kent Overstreet 2020-12-14 2550
06c0444290cecf0 Kent Overstreet 2020-12-14 2551 if (pages != pages_onstack)
06c0444290cecf0 Kent Overstreet 2020-12-14 2552 kfree(pages);
723ef24b9b379e5 Kent Overstreet 2020-12-14 2553
6e58e79db8a1622 Al Viro 2014-02-03 2554 return written ? written : error;
^1da177e4c3f415 Linus Torvalds 2005-04-16 2555 }
d85dc2e116fdce7 Goldwyn Rodrigues 2019-08-30 2556 EXPORT_SYMBOL_GPL(generic_file_buffered_read);
^1da177e4c3f415 Linus Torvalds 2005-04-16 2557
:::::: The code at line 2439 was first introduced by commit
:::::: 723ef24b9b379e59facc65de8c065c8b89d479cd mm/filemap/c: break generic_file_buffered_read up into multiple functions
:::::: TO: Kent Overstreet <kent.overstreet@xxxxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip