All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] page cache: Convert filemap_range_has_page to XArray
@ 2018-06-19 14:47 Dan Carpenter
  2018-06-19 15:48 ` Matthew Wilcox
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2018-06-19 14:47 UTC (permalink / raw)
  To: willy; +Cc: linux-mm

Hello Matthew Wilcox,

The patch 87345c6b1aa8: "page cache: Convert filemap_range_has_page
to XArray" from Jan 16, 2018, leads to the following static checker
warning:

	mm/filemap.c:469 filemap_range_has_page()
	warn: continue to end of do { ... } while(0); loop

mm/filemap.c
   455  bool filemap_range_has_page(struct address_space *mapping,
   456                             loff_t start_byte, loff_t end_byte)
   457  {
   458          struct page *page;
   459          XA_STATE(xas, &mapping->i_pages, start_byte >> PAGE_SHIFT);
   460          pgoff_t max = end_byte >> PAGE_SHIFT;
   461  
   462          if (end_byte < start_byte)
   463                  return false;
   464  
   465          rcu_read_lock();
   466          do {
   467                  page = xas_find(&xas, max);
   468                  if (xas_retry(&xas, page))
   469                          continue;
                                ^^^^^^^^
   470                  /* Shadow entries don't count */
   471                  if (xa_is_value(page))
   472                          continue;
                                ^^^^^^^^
This is the same as a break because it's a while(0) loop.

   473                  /*
   474                   * We don't need to try to pin this page; we're about to
   475                   * release the RCU lock anyway.  It is enough to know that
   476                   * there was a page here recently.
   477                   */
   478          } while (0);
   479          rcu_read_unlock();
   480  
   481          return page != NULL;
   482  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] page cache: Convert filemap_range_has_page to XArray
  2018-06-19 14:47 [bug report] page cache: Convert filemap_range_has_page to XArray Dan Carpenter
@ 2018-06-19 15:48 ` Matthew Wilcox
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2018-06-19 15:48 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-mm

On Tue, Jun 19, 2018 at 05:47:05PM +0300, Dan Carpenter wrote:
>    455  bool filemap_range_has_page(struct address_space *mapping,
>    456                             loff_t start_byte, loff_t end_byte)
>    457  {
>    458          struct page *page;
>    459          XA_STATE(xas, &mapping->i_pages, start_byte >> PAGE_SHIFT);
>    460          pgoff_t max = end_byte >> PAGE_SHIFT;
>    461  
>    462          if (end_byte < start_byte)
>    463                  return false;
>    464  
>    465          rcu_read_lock();
>    466          do {
>    467                  page = xas_find(&xas, max);
>    468                  if (xas_retry(&xas, page))
>    469                          continue;
>                                 ^^^^^^^^
>    470                  /* Shadow entries don't count */
>    471                  if (xa_is_value(page))
>    472                          continue;
>                                 ^^^^^^^^
> This is the same as a break because it's a while(0) loop.

Good catch.  Fix pushed.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-19 15:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-19 14:47 [bug report] page cache: Convert filemap_range_has_page to XArray Dan Carpenter
2018-06-19 15:48 ` Matthew Wilcox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.