Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1381621 > unrolled thread

[PATCH] net/mlx4_en: do batched put_page using atomic_sub

Started byKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
First post2016-04-18 13:50 +0200
Last post2016-04-20 02:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] net/mlx4_en: do batched put_page using atomic_sub Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2016-04-18 13:50 +0200
    Re: [PATCH] net/mlx4_en: do batched put_page using atomic_sub David Miller <davem@davemloft.net> - 2016-04-20 02:10 +0200

#1381621 — [PATCH] net/mlx4_en: do batched put_page using atomic_sub

FromKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
Date2016-04-18 13:50 +0200
Subject[PATCH] net/mlx4_en: do batched put_page using atomic_sub
Message-ID<rpfQJ-4Ut-9@gated-at.bofh.it>
This patch fixes couple error paths after allocation failures.
Atomic set of page reference counter is safe only if it is zero,
otherwise set can race with any speculative get_page_unless_zero.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
 drivers/net/ethernet/mellanox/mlx4/en_rx.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 56d070d9cf01..7d25bc9c1b22 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -126,7 +126,9 @@ out:
 			dma_unmap_page(priv->ddev, page_alloc[i].dma,
 				page_alloc[i].page_size, PCI_DMA_FROMDEVICE);
 			page = page_alloc[i].page;
-			set_page_count(page, 1);
+			/* Revert changes done by mlx4_alloc_pages */
+			page_ref_sub(page, page_alloc[i].page_size /
+					   priv->frag_info[i].frag_stride - 1);
 			put_page(page);
 		}
 	}
@@ -176,7 +178,9 @@ out:
 		dma_unmap_page(priv->ddev, page_alloc->dma,
 			       page_alloc->page_size, PCI_DMA_FROMDEVICE);
 		page = page_alloc->page;
-		set_page_count(page, 1);
+		/* Revert changes done by mlx4_alloc_pages */
+		page_ref_sub(page, page_alloc->page_size /
+				   priv->frag_info[i].frag_stride - 1);
 		put_page(page);
 		page_alloc->page = NULL;
 	}

[toc] | [next] | [standalone]


#1382913

FromDavid Miller <davem@davemloft.net>
Date2016-04-20 02:10 +0200
Message-ID<rpNSq-7ey-11@gated-at.bofh.it>
In reply to#1381621
From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Date: Mon, 18 Apr 2016 14:34:05 +0300

> This patch fixes couple error paths after allocation failures.
> Atomic set of page reference counter is safe only if it is zero,
> otherwise set can race with any speculative get_page_unless_zero.
> 
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>

Applied.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web