linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] mm/dmapool.c: Replace open-coded list_first_entry()
@ 2020-08-12 15:30 Andy Shevchenko
  2020-08-12 18:41 ` Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2020-08-12 15:30 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: Andy Shevchenko

There is a place in the code where open-coded version of list_first_entry()
is used. Replace that with the standard macro.

While here, separate definitions from the code to avoid a churn by janitors.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 mm/dmapool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/dmapool.c b/mm/dmapool.c
index f9fb9bbd733e..049ac1459714 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -283,8 +283,8 @@ void dma_pool_destroy(struct dma_pool *pool)
 
 	while (!list_empty(&pool->page_list)) {
 		struct dma_page *page;
-		page = list_entry(pool->page_list.next,
-				  struct dma_page, page_list);
+
+		page = list_first_entry(&pool->page_list, struct dma_page, page_list);
 		if (is_page_busy(page)) {
 			if (pool->dev)
 				dev_err(pool->dev,
-- 
2.28.0



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

* Re: [PATCH v1] mm/dmapool.c: Replace open-coded list_first_entry()
  2020-08-12 15:30 [PATCH v1] mm/dmapool.c: Replace open-coded list_first_entry() Andy Shevchenko
@ 2020-08-12 18:41 ` Matthew Wilcox
  2020-08-13 11:09   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2020-08-12 18:41 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Andrew Morton, linux-mm

On Wed, Aug 12, 2020 at 06:30:59PM +0300, Andy Shevchenko wrote:
>  	while (!list_empty(&pool->page_list)) {
>  		struct dma_page *page;
> -		page = list_entry(pool->page_list.next,
> -				  struct dma_page, page_list);
> +
> +		page = list_first_entry(&pool->page_list, struct dma_page, page_list);

Eh, I'd rather see this as:

		struct dma_page *page = list_first_entry(&pool->page_list,
				struct dma_page, page_list);


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

* Re: [PATCH v1] mm/dmapool.c: Replace open-coded list_first_entry()
  2020-08-12 18:41 ` Matthew Wilcox
@ 2020-08-13 11:09   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2020-08-13 11:09 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Andrew Morton, linux-mm

On Wed, Aug 12, 2020 at 07:41:41PM +0100, Matthew Wilcox wrote:
> On Wed, Aug 12, 2020 at 06:30:59PM +0300, Andy Shevchenko wrote:
> >  	while (!list_empty(&pool->page_list)) {
> >  		struct dma_page *page;
> > -		page = list_entry(pool->page_list.next,
> > -				  struct dma_page, page_list);
> > +
> > +		page = list_first_entry(&pool->page_list, struct dma_page, page_list);
> 
> Eh, I'd rather see this as:
> 
> 		struct dma_page *page = list_first_entry(&pool->page_list,
> 				struct dma_page, page_list);

On the second thought we may convert the entire loop to use
list_for_each_entry_safe() since there is no locking in between, we
should be fine.

-- 
With Best Regards,
Andy Shevchenko




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

end of thread, other threads:[~2020-08-13 11:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-12 15:30 [PATCH v1] mm/dmapool.c: Replace open-coded list_first_entry() Andy Shevchenko
2020-08-12 18:41 ` Matthew Wilcox
2020-08-13 11:09   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).