* [PATCH net-next 0/3] r8169: use new macros from netdev_queues.h
@ 2023-04-13 19:13 Heiner Kallweit
2023-04-13 19:14 ` [PATCH net-next 1/3] net: add macro netif_subqueue_completed_wake Heiner Kallweit
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Heiner Kallweit @ 2023-04-13 19:13 UTC (permalink / raw)
To: Jakub Kicinski, David Miller, Paolo Abeni, Eric Dumazet,
Realtek linux nic maintainers
Cc: netdev
Add one missing subqueue version of the macros, and use the new macros
in r8169 to simplify the code.
Heiner Kallweit (3):
net: add macro netif_subqueue_completed_wake
r8169: use new macro netif_subqueue_maybe_stop in rtl8169_start_xmit
r8169: use new macro netif_subqueue_completed_wake in the tx cleanup path
drivers/net/ethernet/realtek/r8169_main.c | 54 +++++++----------------
include/net/netdev_queues.h | 10 +++++
2 files changed, 25 insertions(+), 39 deletions(-)
--
2.40.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH net-next 1/3] net: add macro netif_subqueue_completed_wake
2023-04-13 19:13 [PATCH net-next 0/3] r8169: use new macros from netdev_queues.h Heiner Kallweit
@ 2023-04-13 19:14 ` Heiner Kallweit
2023-04-13 19:22 ` Jacob Keller
2023-04-13 19:15 ` [PATCH net-next 2/3] r8169: use new macro netif_subqueue_maybe_stop in rtl8169_start_xmit Heiner Kallweit
` (2 subsequent siblings)
3 siblings, 1 reply; 12+ messages in thread
From: Heiner Kallweit @ 2023-04-13 19:14 UTC (permalink / raw)
To: Jakub Kicinski, David Miller, Paolo Abeni, Eric Dumazet,
Realtek linux nic maintainers
Cc: netdev
Add netif_subqueue_completed_wake, complementing the subqueue versions
netif_subqueue_try_stop and netif_subqueue_maybe_stop.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
include/net/netdev_queues.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h
index b26fdb441..d68b0a483 100644
--- a/include/net/netdev_queues.h
+++ b/include/net/netdev_queues.h
@@ -160,4 +160,14 @@ netdev_txq_completed_mb(struct netdev_queue *dev_queue,
netif_txq_maybe_stop(txq, get_desc, stop_thrs, start_thrs); \
})
+#define netif_subqueue_completed_wake(dev, idx, pkts, bytes, \
+ get_desc, start_thrs) \
+ ({ \
+ struct netdev_queue *txq; \
+ \
+ txq = netdev_get_tx_queue(dev, idx); \
+ netif_txq_completed_wake(txq, pkts, bytes, \
+ get_desc, start_thrs); \
+ })
+
#endif
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH net-next 2/3] r8169: use new macro netif_subqueue_maybe_stop in rtl8169_start_xmit
2023-04-13 19:13 [PATCH net-next 0/3] r8169: use new macros from netdev_queues.h Heiner Kallweit
2023-04-13 19:14 ` [PATCH net-next 1/3] net: add macro netif_subqueue_completed_wake Heiner Kallweit
@ 2023-04-13 19:15 ` Heiner Kallweit
2023-04-13 19:24 ` Jacob Keller
2023-04-15 1:53 ` Jakub Kicinski
2023-04-13 19:16 ` [PATCH net-next 3/3] r8169: use new macro netif_subqueue_completed_wake in the tx cleanup path Heiner Kallweit
2023-04-13 19:17 ` [PATCH net-next 0/3] r8169: use new macros from netdev_queues.h Jacob Keller
3 siblings, 2 replies; 12+ messages in thread
From: Heiner Kallweit @ 2023-04-13 19:15 UTC (permalink / raw)
To: Jakub Kicinski, David Miller, Paolo Abeni, Eric Dumazet,
Realtek linux nic maintainers
Cc: netdev
Use new net core macro netif_subqueue_maybe_stop in the start_xmit path
to simplify the code. Whilst at it, set the tx queue start threshold to
twice the stop threshold. Before values were the same, resulting in
stopping/starting the queue more often than needed.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8169_main.c | 42 +++++++----------------
1 file changed, 13 insertions(+), 29 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 9f8357bbc..3f0b78fd9 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -30,6 +30,7 @@
#include <linux/ipv6.h>
#include <asm/unaligned.h>
#include <net/ip6_checksum.h>
+#include <net/netdev_queues.h>
#include "r8169.h"
#include "r8169_firmware.h"
@@ -68,6 +69,8 @@
#define NUM_RX_DESC 256 /* Number of Rx descriptor registers */
#define R8169_TX_RING_BYTES (NUM_TX_DESC * sizeof(struct TxDesc))
#define R8169_RX_RING_BYTES (NUM_RX_DESC * sizeof(struct RxDesc))
+#define R8169_TX_STOP_THRS (MAX_SKB_FRAGS + 1)
+#define R8169_TX_START_THRS (2 * R8169_TX_STOP_THRS)
#define OCP_STD_PHY_BASE 0xa400
@@ -4162,13 +4165,9 @@ static bool rtl8169_tso_csum_v2(struct rtl8169_private *tp,
return true;
}
-static bool rtl_tx_slots_avail(struct rtl8169_private *tp)
+static unsigned int rtl_tx_slots_avail(struct rtl8169_private *tp)
{
- unsigned int slots_avail = READ_ONCE(tp->dirty_tx) + NUM_TX_DESC
- - READ_ONCE(tp->cur_tx);
-
- /* A skbuff with nr_frags needs nr_frags+1 entries in the tx queue */
- return slots_avail > MAX_SKB_FRAGS;
+ return READ_ONCE(tp->dirty_tx) + NUM_TX_DESC - READ_ONCE(tp->cur_tx);
}
/* Versions RTL8102e and from RTL8168c onwards support csum_v2 */
@@ -4198,7 +4197,8 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
struct rtl8169_private *tp = netdev_priv(dev);
unsigned int entry = tp->cur_tx % NUM_TX_DESC;
struct TxDesc *txd_first, *txd_last;
- bool stop_queue, door_bell;
+ bool door_bell;
+ int stop_queue;
u32 opts[2];
if (unlikely(!rtl_tx_slots_avail(tp))) {
@@ -4245,27 +4245,10 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
WRITE_ONCE(tp->cur_tx, tp->cur_tx + frags + 1);
- stop_queue = !rtl_tx_slots_avail(tp);
- if (unlikely(stop_queue)) {
- /* Avoid wrongly optimistic queue wake-up: rtl_tx thread must
- * not miss a ring update when it notices a stopped queue.
- */
- smp_wmb();
- netif_stop_queue(dev);
- /* Sync with rtl_tx:
- * - publish queue status and cur_tx ring index (write barrier)
- * - refresh dirty_tx ring index (read barrier).
- * May the current thread have a pessimistic view of the ring
- * status and forget to wake up queue, a racing rtl_tx thread
- * can't.
- */
- smp_mb__after_atomic();
- if (rtl_tx_slots_avail(tp))
- netif_start_queue(dev);
- door_bell = true;
- }
-
- if (door_bell)
+ stop_queue = netif_subqueue_maybe_stop(dev, 0, rtl_tx_slots_avail(tp),
+ R8169_TX_STOP_THRS,
+ R8169_TX_START_THRS);
+ if (door_bell || stop_queue < 0)
rtl8169_doorbell(tp);
return NETDEV_TX_OK;
@@ -4400,7 +4383,8 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
* ring status.
*/
smp_store_mb(tp->dirty_tx, dirty_tx);
- if (netif_queue_stopped(dev) && rtl_tx_slots_avail(tp))
+ if (netif_queue_stopped(dev) &&
+ rtl_tx_slots_avail(tp) >= R8169_TX_START_THRS)
netif_wake_queue(dev);
/*
* 8168 hack: TxPoll requests are lost when the Tx packets are
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH net-next 3/3] r8169: use new macro netif_subqueue_completed_wake in the tx cleanup path
2023-04-13 19:13 [PATCH net-next 0/3] r8169: use new macros from netdev_queues.h Heiner Kallweit
2023-04-13 19:14 ` [PATCH net-next 1/3] net: add macro netif_subqueue_completed_wake Heiner Kallweit
2023-04-13 19:15 ` [PATCH net-next 2/3] r8169: use new macro netif_subqueue_maybe_stop in rtl8169_start_xmit Heiner Kallweit
@ 2023-04-13 19:16 ` Heiner Kallweit
2023-04-13 19:25 ` Jacob Keller
2023-04-13 19:17 ` [PATCH net-next 0/3] r8169: use new macros from netdev_queues.h Jacob Keller
3 siblings, 1 reply; 12+ messages in thread
From: Heiner Kallweit @ 2023-04-13 19:16 UTC (permalink / raw)
To: Jakub Kicinski, David Miller, Paolo Abeni, Eric Dumazet,
Realtek linux nic maintainers
Cc: netdev
Use new net core macro netif_subqueue_completed_wake to simplify
the code of the tx cleanup path.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8169_main.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 3f0b78fd9..5cfdb60ab 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -4372,20 +4372,12 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
}
if (tp->dirty_tx != dirty_tx) {
- netdev_completed_queue(dev, pkts_compl, bytes_compl);
dev_sw_netstats_tx_add(dev, pkts_compl, bytes_compl);
+ WRITE_ONCE(tp->dirty_tx, dirty_tx);
- /* Sync with rtl8169_start_xmit:
- * - publish dirty_tx ring index (write barrier)
- * - refresh cur_tx ring index and queue status (read barrier)
- * May the current thread miss the stopped queue condition,
- * a racing xmit thread can only have a right view of the
- * ring status.
- */
- smp_store_mb(tp->dirty_tx, dirty_tx);
- if (netif_queue_stopped(dev) &&
- rtl_tx_slots_avail(tp) >= R8169_TX_START_THRS)
- netif_wake_queue(dev);
+ netif_subqueue_completed_wake(dev, 0, pkts_compl, bytes_compl,
+ rtl_tx_slots_avail(tp),
+ R8169_TX_START_THRS);
/*
* 8168 hack: TxPoll requests are lost when the Tx packets are
* too close. Let's kick an extra TxPoll request when a burst
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 0/3] r8169: use new macros from netdev_queues.h
2023-04-13 19:13 [PATCH net-next 0/3] r8169: use new macros from netdev_queues.h Heiner Kallweit
` (2 preceding siblings ...)
2023-04-13 19:16 ` [PATCH net-next 3/3] r8169: use new macro netif_subqueue_completed_wake in the tx cleanup path Heiner Kallweit
@ 2023-04-13 19:17 ` Jacob Keller
3 siblings, 0 replies; 12+ messages in thread
From: Jacob Keller @ 2023-04-13 19:17 UTC (permalink / raw)
To: Heiner Kallweit, Jakub Kicinski, David Miller, Paolo Abeni,
Eric Dumazet, Realtek linux nic maintainers
Cc: netdev
On 4/13/2023 12:13 PM, Heiner Kallweit wrote:
> Add one missing subqueue version of the macros, and use the new macros
> in r8169 to simplify the code.
>
> Heiner Kallweit (3):
> net: add macro netif_subqueue_completed_wake
> r8169: use new macro netif_subqueue_maybe_stop in rtl8169_start_xmit
> r8169: use new macro netif_subqueue_completed_wake in the tx cleanup path
>
> drivers/net/ethernet/realtek/r8169_main.c | 54 +++++++----------------
> include/net/netdev_queues.h | 10 +++++
> 2 files changed, 25 insertions(+), 39 deletions(-)
>
The actual patches don't seem to have hit the list.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 1/3] net: add macro netif_subqueue_completed_wake
2023-04-13 19:14 ` [PATCH net-next 1/3] net: add macro netif_subqueue_completed_wake Heiner Kallweit
@ 2023-04-13 19:22 ` Jacob Keller
0 siblings, 0 replies; 12+ messages in thread
From: Jacob Keller @ 2023-04-13 19:22 UTC (permalink / raw)
To: Heiner Kallweit, Jakub Kicinski, David Miller, Paolo Abeni,
Eric Dumazet, Realtek linux nic maintainers
Cc: netdev
On 4/13/2023 12:14 PM, Heiner Kallweit wrote:
> Add netif_subqueue_completed_wake, complementing the subqueue versions
> netif_subqueue_try_stop and netif_subqueue_maybe_stop.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> include/net/netdev_queues.h | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h
> index b26fdb441..d68b0a483 100644
> --- a/include/net/netdev_queues.h
> +++ b/include/net/netdev_queues.h
> @@ -160,4 +160,14 @@ netdev_txq_completed_mb(struct netdev_queue *dev_queue,
> netif_txq_maybe_stop(txq, get_desc, stop_thrs, start_thrs); \
> })
>
> +#define netif_subqueue_completed_wake(dev, idx, pkts, bytes, \
> + get_desc, start_thrs) \
> + ({ \
> + struct netdev_queue *txq; \
> + \
> + txq = netdev_get_tx_queue(dev, idx); \
> + netif_txq_completed_wake(txq, pkts, bytes, \
> + get_desc, start_thrs); \
> + })
> +
> #endif
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 2/3] r8169: use new macro netif_subqueue_maybe_stop in rtl8169_start_xmit
2023-04-13 19:15 ` [PATCH net-next 2/3] r8169: use new macro netif_subqueue_maybe_stop in rtl8169_start_xmit Heiner Kallweit
@ 2023-04-13 19:24 ` Jacob Keller
2023-04-15 1:53 ` Jakub Kicinski
1 sibling, 0 replies; 12+ messages in thread
From: Jacob Keller @ 2023-04-13 19:24 UTC (permalink / raw)
To: Heiner Kallweit, Jakub Kicinski, David Miller, Paolo Abeni,
Eric Dumazet, Realtek linux nic maintainers
Cc: netdev
On 4/13/2023 12:15 PM, Heiner Kallweit wrote:
> Use new net core macro netif_subqueue_maybe_stop in the start_xmit path
> to simplify the code. Whilst at it, set the tx queue start threshold to
> twice the stop threshold. Before values were the same, resulting in
> stopping/starting the queue more often than needed.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> drivers/net/ethernet/realtek/r8169_main.c | 42 +++++++----------------
> 1 file changed, 13 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index 9f8357bbc..3f0b78fd9 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -30,6 +30,7 @@
> #include <linux/ipv6.h>
> #include <asm/unaligned.h>
> #include <net/ip6_checksum.h>
> +#include <net/netdev_queues.h>
>
> #include "r8169.h"
> #include "r8169_firmware.h"
> @@ -68,6 +69,8 @@
> #define NUM_RX_DESC 256 /* Number of Rx descriptor registers */
> #define R8169_TX_RING_BYTES (NUM_TX_DESC * sizeof(struct TxDesc))
> #define R8169_RX_RING_BYTES (NUM_RX_DESC * sizeof(struct RxDesc))
> +#define R8169_TX_STOP_THRS (MAX_SKB_FRAGS + 1)
> +#define R8169_TX_START_THRS (2 * R8169_TX_STOP_THRS)
>
> #define OCP_STD_PHY_BASE 0xa400
>
> @@ -4162,13 +4165,9 @@ static bool rtl8169_tso_csum_v2(struct rtl8169_private *tp,
> return true;
> }
>
> -static bool rtl_tx_slots_avail(struct rtl8169_private *tp)
> +static unsigned int rtl_tx_slots_avail(struct rtl8169_private *tp)
> {
> - unsigned int slots_avail = READ_ONCE(tp->dirty_tx) + NUM_TX_DESC
> - - READ_ONCE(tp->cur_tx);
> -
> - /* A skbuff with nr_frags needs nr_frags+1 entries in the tx queue */
> - return slots_avail > MAX_SKB_FRAGS;
> + return READ_ONCE(tp->dirty_tx) + NUM_TX_DESC - READ_ONCE(tp->cur_tx);
> }
>
Ok so now we just directly return the slots available. We used to check
MAX_SKB_FRAGS vs now we check MAX_SBK_FAGS + 1 (or double that for the
start threshhold). Ok.
> /* Versions RTL8102e and from RTL8168c onwards support csum_v2 */
> @@ -4198,7 +4197,8 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
> struct rtl8169_private *tp = netdev_priv(dev);
> unsigned int entry = tp->cur_tx % NUM_TX_DESC;
> struct TxDesc *txd_first, *txd_last;
> - bool stop_queue, door_bell;
> + bool door_bell;
> + int stop_queue;
> u32 opts[2];
>
> if (unlikely(!rtl_tx_slots_avail(tp))) {
> @@ -4245,27 +4245,10 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
>
> WRITE_ONCE(tp->cur_tx, tp->cur_tx + frags + 1);
>
> - stop_queue = !rtl_tx_slots_avail(tp);
> - if (unlikely(stop_queue)) {
> - /* Avoid wrongly optimistic queue wake-up: rtl_tx thread must
> - * not miss a ring update when it notices a stopped queue.
> - */
> - smp_wmb();
> - netif_stop_queue(dev);
> - /* Sync with rtl_tx:
> - * - publish queue status and cur_tx ring index (write barrier)
> - * - refresh dirty_tx ring index (read barrier).
> - * May the current thread have a pessimistic view of the ring
> - * status and forget to wake up queue, a racing rtl_tx thread
> - * can't.
> - */
> - smp_mb__after_atomic();
> - if (rtl_tx_slots_avail(tp))
> - netif_start_queue(dev);
> - door_bell = true;
> - }
> -
> - if (door_bell)
> + stop_queue = netif_subqueue_maybe_stop(dev, 0, rtl_tx_slots_avail(tp),
> + R8169_TX_STOP_THRS,
> + R8169_TX_START_THRS);
> + if (door_bell || stop_queue < 0)
Nice reduction in code here :D
> rtl8169_doorbell(tp);
>
> return NETDEV_TX_OK;
> @@ -4400,7 +4383,8 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
> * ring status.
> */
> smp_store_mb(tp->dirty_tx, dirty_tx);
> - if (netif_queue_stopped(dev) && rtl_tx_slots_avail(tp))
> + if (netif_queue_stopped(dev) &&
> + rtl_tx_slots_avail(tp) >= R8169_TX_START_THRS)
> netif_wake_queue(dev);
> /*
> * 8168 hack: TxPoll requests are lost when the Tx packets are
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 3/3] r8169: use new macro netif_subqueue_completed_wake in the tx cleanup path
2023-04-13 19:16 ` [PATCH net-next 3/3] r8169: use new macro netif_subqueue_completed_wake in the tx cleanup path Heiner Kallweit
@ 2023-04-13 19:25 ` Jacob Keller
2023-04-13 19:36 ` Heiner Kallweit
0 siblings, 1 reply; 12+ messages in thread
From: Jacob Keller @ 2023-04-13 19:25 UTC (permalink / raw)
To: Heiner Kallweit, Jakub Kicinski, David Miller, Paolo Abeni,
Eric Dumazet, Realtek linux nic maintainers
Cc: netdev
On 4/13/2023 12:16 PM, Heiner Kallweit wrote:
> Use new net core macro netif_subqueue_completed_wake to simplify
> the code of the tx cleanup path.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/net/ethernet/realtek/r8169_main.c | 16 ++++------------
> 1 file changed, 4 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index 3f0b78fd9..5cfdb60ab 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -4372,20 +4372,12 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
> }
>
> if (tp->dirty_tx != dirty_tx) {
> - netdev_completed_queue(dev, pkts_compl, bytes_compl);
> dev_sw_netstats_tx_add(dev, pkts_compl, bytes_compl);
> + WRITE_ONCE(tp->dirty_tx, dirty_tx);
>
> - /* Sync with rtl8169_start_xmit:
> - * - publish dirty_tx ring index (write barrier)
> - * - refresh cur_tx ring index and queue status (read barrier)
> - * May the current thread miss the stopped queue condition,
> - * a racing xmit thread can only have a right view of the
> - * ring status.
> - */
> - smp_store_mb(tp->dirty_tx, dirty_tx);
We used to use a smp_store_mb here, but now its safe to just WRITE_ONCE?
Assuming that's correct:
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> - if (netif_queue_stopped(dev) &&
> - rtl_tx_slots_avail(tp) >= R8169_TX_START_THRS)
> - netif_wake_queue(dev);
> + netif_subqueue_completed_wake(dev, 0, pkts_compl, bytes_compl,
> + rtl_tx_slots_avail(tp),
> + R8169_TX_START_THRS);
> /*
> * 8168 hack: TxPoll requests are lost when the Tx packets are
> * too close. Let's kick an extra TxPoll request when a burst
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 3/3] r8169: use new macro netif_subqueue_completed_wake in the tx cleanup path
2023-04-13 19:25 ` Jacob Keller
@ 2023-04-13 19:36 ` Heiner Kallweit
2023-04-13 21:04 ` Jacob Keller
0 siblings, 1 reply; 12+ messages in thread
From: Heiner Kallweit @ 2023-04-13 19:36 UTC (permalink / raw)
To: Jacob Keller, Jakub Kicinski, David Miller, Paolo Abeni,
Eric Dumazet, Realtek linux nic maintainers
Cc: netdev
On 13.04.2023 21:25, Jacob Keller wrote:
>
>
> On 4/13/2023 12:16 PM, Heiner Kallweit wrote:
>> Use new net core macro netif_subqueue_completed_wake to simplify
>> the code of the tx cleanup path.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
>> drivers/net/ethernet/realtek/r8169_main.c | 16 ++++------------
>> 1 file changed, 4 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
>> index 3f0b78fd9..5cfdb60ab 100644
>> --- a/drivers/net/ethernet/realtek/r8169_main.c
>> +++ b/drivers/net/ethernet/realtek/r8169_main.c
>> @@ -4372,20 +4372,12 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
>> }
>>
>> if (tp->dirty_tx != dirty_tx) {
>> - netdev_completed_queue(dev, pkts_compl, bytes_compl);
>> dev_sw_netstats_tx_add(dev, pkts_compl, bytes_compl);
>> + WRITE_ONCE(tp->dirty_tx, dirty_tx);
>>
>> - /* Sync with rtl8169_start_xmit:
>> - * - publish dirty_tx ring index (write barrier)
>> - * - refresh cur_tx ring index and queue status (read barrier)
>> - * May the current thread miss the stopped queue condition,
>> - * a racing xmit thread can only have a right view of the
>> - * ring status.
>> - */
>> - smp_store_mb(tp->dirty_tx, dirty_tx);
>
>
> We used to use a smp_store_mb here, but now its safe to just WRITE_ONCE?
> Assuming that's correct:
>
netdev_completed_queue() has a smp_mb() and is called from
netif_subqueue_completed_wake(). So it's supposed to be safe.
> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
>
>> - if (netif_queue_stopped(dev) &&
>> - rtl_tx_slots_avail(tp) >= R8169_TX_START_THRS)
>> - netif_wake_queue(dev);
>> + netif_subqueue_completed_wake(dev, 0, pkts_compl, bytes_compl,
>> + rtl_tx_slots_avail(tp),
>> + R8169_TX_START_THRS);
>> /*
>> * 8168 hack: TxPoll requests are lost when the Tx packets are
>> * too close. Let's kick an extra TxPoll request when a burst
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 3/3] r8169: use new macro netif_subqueue_completed_wake in the tx cleanup path
2023-04-13 19:36 ` Heiner Kallweit
@ 2023-04-13 21:04 ` Jacob Keller
0 siblings, 0 replies; 12+ messages in thread
From: Jacob Keller @ 2023-04-13 21:04 UTC (permalink / raw)
To: Heiner Kallweit, Jakub Kicinski, David Miller, Paolo Abeni,
Eric Dumazet, Realtek linux nic maintainers
Cc: netdev
On 4/13/2023 12:36 PM, Heiner Kallweit wrote:
> On 13.04.2023 21:25, Jacob Keller wrote:
>>
>>
>> On 4/13/2023 12:16 PM, Heiner Kallweit wrote:
>>> Use new net core macro netif_subqueue_completed_wake to simplify
>>> the code of the tx cleanup path.
>>>
>>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>>> ---
>>> drivers/net/ethernet/realtek/r8169_main.c | 16 ++++------------
>>> 1 file changed, 4 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
>>> index 3f0b78fd9..5cfdb60ab 100644
>>> --- a/drivers/net/ethernet/realtek/r8169_main.c
>>> +++ b/drivers/net/ethernet/realtek/r8169_main.c
>>> @@ -4372,20 +4372,12 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
>>> }
>>>
>>> if (tp->dirty_tx != dirty_tx) {
>>> - netdev_completed_queue(dev, pkts_compl, bytes_compl);
>>> dev_sw_netstats_tx_add(dev, pkts_compl, bytes_compl);
>>> + WRITE_ONCE(tp->dirty_tx, dirty_tx);
>>>
>>> - /* Sync with rtl8169_start_xmit:
>>> - * - publish dirty_tx ring index (write barrier)
>>> - * - refresh cur_tx ring index and queue status (read barrier)
>>> - * May the current thread miss the stopped queue condition,
>>> - * a racing xmit thread can only have a right view of the
>>> - * ring status.
>>> - */
>>> - smp_store_mb(tp->dirty_tx, dirty_tx);
>>
>>
>> We used to use a smp_store_mb here, but now its safe to just WRITE_ONCE?
>> Assuming that's correct:
>>
> netdev_completed_queue() has a smp_mb() and is called from
> netif_subqueue_completed_wake(). So it's supposed to be safe.
>
Perfect, thanks for the explanation!
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 2/3] r8169: use new macro netif_subqueue_maybe_stop in rtl8169_start_xmit
2023-04-13 19:15 ` [PATCH net-next 2/3] r8169: use new macro netif_subqueue_maybe_stop in rtl8169_start_xmit Heiner Kallweit
2023-04-13 19:24 ` Jacob Keller
@ 2023-04-15 1:53 ` Jakub Kicinski
2023-04-15 7:14 ` Heiner Kallweit
1 sibling, 1 reply; 12+ messages in thread
From: Jakub Kicinski @ 2023-04-15 1:53 UTC (permalink / raw)
To: Heiner Kallweit
Cc: David Miller, Paolo Abeni, Eric Dumazet,
Realtek linux nic maintainers, netdev
On Thu, 13 Apr 2023 21:15:37 +0200 Heiner Kallweit wrote:
> + stop_queue = netif_subqueue_maybe_stop(dev, 0, rtl_tx_slots_avail(tp),
> + R8169_TX_STOP_THRS,
> + R8169_TX_START_THRS);
> + if (door_bell || stop_queue < 0)
Macro returns 0 if it did the action. So I'd have expected <= or !
Maybe better to invert the return value at the call site..
stopped = !netif_subqueue_maybe_stop(...
if (door_bell || stopped)
..
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 2/3] r8169: use new macro netif_subqueue_maybe_stop in rtl8169_start_xmit
2023-04-15 1:53 ` Jakub Kicinski
@ 2023-04-15 7:14 ` Heiner Kallweit
0 siblings, 0 replies; 12+ messages in thread
From: Heiner Kallweit @ 2023-04-15 7:14 UTC (permalink / raw)
To: Jakub Kicinski
Cc: David Miller, Paolo Abeni, Eric Dumazet,
Realtek linux nic maintainers, netdev
On 15.04.2023 03:53, Jakub Kicinski wrote:
> On Thu, 13 Apr 2023 21:15:37 +0200 Heiner Kallweit wrote:
>> + stop_queue = netif_subqueue_maybe_stop(dev, 0, rtl_tx_slots_avail(tp),
>> + R8169_TX_STOP_THRS,
>> + R8169_TX_START_THRS);
>> + if (door_bell || stop_queue < 0)
>
> Macro returns 0 if it did the action. So I'd have expected <= or !
> Maybe better to invert the return value at the call site..
>
I didn't encounter a problem in my tests, but you're right, this should
be changed. Currently we ring the door bell if the queue was stopped or
re-started. Should be sufficient to do it if queue is stopped.
> stopped = !netif_subqueue_maybe_stop(...
> if (door_bell || stopped)
> ..
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-04-15 7:16 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13 19:13 [PATCH net-next 0/3] r8169: use new macros from netdev_queues.h Heiner Kallweit
2023-04-13 19:14 ` [PATCH net-next 1/3] net: add macro netif_subqueue_completed_wake Heiner Kallweit
2023-04-13 19:22 ` Jacob Keller
2023-04-13 19:15 ` [PATCH net-next 2/3] r8169: use new macro netif_subqueue_maybe_stop in rtl8169_start_xmit Heiner Kallweit
2023-04-13 19:24 ` Jacob Keller
2023-04-15 1:53 ` Jakub Kicinski
2023-04-15 7:14 ` Heiner Kallweit
2023-04-13 19:16 ` [PATCH net-next 3/3] r8169: use new macro netif_subqueue_completed_wake in the tx cleanup path Heiner Kallweit
2023-04-13 19:25 ` Jacob Keller
2023-04-13 19:36 ` Heiner Kallweit
2023-04-13 21:04 ` Jacob Keller
2023-04-13 19:17 ` [PATCH net-next 0/3] r8169: use new macros from netdev_queues.h Jacob Keller
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.