From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Felix Fietkau <nbd@nbd.name>, linux-wireless@vger.kernel.org
Subject: Re: [PATCH 1/6] mt76: use mac80211 txq scheduling
Date: Sat, 16 Mar 2019 23:28:30 +0100 [thread overview]
Message-ID: <87muluv4hd.fsf@toke.dk> (raw)
In-Reply-To: <20190316204242.73560-1-nbd@nbd.name>
Felix Fietkau <nbd@nbd.name> writes:
> Performance improvement and preparation for adding airtime fairness
> support
Great to see this! Do you have a plan for the airtime fairness part?
I.e., how to get the airtime information?
Only one other comment, below.
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
> ---
> drivers/net/wireless/mediatek/mt76/dma.c | 6 +-
> drivers/net/wireless/mediatek/mt76/mt76.h | 3 +-
> drivers/net/wireless/mediatek/mt76/tx.c | 98 ++++++++++-------------
> drivers/net/wireless/mediatek/mt76/usb.c | 3 +-
> 4 files changed, 50 insertions(+), 60 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
> index 7b8a998103d7..09978757e7d1 100644
> --- a/drivers/net/wireless/mediatek/mt76/dma.c
> +++ b/drivers/net/wireless/mediatek/mt76/dma.c
> @@ -184,9 +184,7 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, enum mt76_txq_id qid, bool flush)
> last = ioread32(&q->regs->dma_idx);
> }
>
> - if (!flush)
> - mt76_txq_schedule(dev, sq);
> - else
> + if (flush)
> mt76_dma_sync_idx(dev, q);
>
> wake = wake && q->stopped &&
> @@ -199,6 +197,8 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, enum mt76_txq_id qid, bool flush)
>
> spin_unlock_bh(&q->lock);
>
> + if (!flush)
> + mt76_txq_schedule(dev, qid);
> if (wake)
> ieee80211_wake_queue(dev->hw, qid);
> }
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
> index edff44f32c8e..5d44f721d184 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76.h
> @@ -224,7 +224,6 @@ struct mt76_wcid {
> };
>
> struct mt76_txq {
> - struct list_head list;
> struct mt76_sw_queue *swq;
> struct mt76_wcid *wcid;
>
> @@ -683,7 +682,7 @@ void mt76_txq_remove(struct mt76_dev *dev, struct ieee80211_txq *txq);
> void mt76_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *txq);
> void mt76_stop_tx_queues(struct mt76_dev *dev, struct ieee80211_sta *sta,
> bool send_bar);
> -void mt76_txq_schedule(struct mt76_dev *dev, struct mt76_sw_queue *sq);
> +void mt76_txq_schedule(struct mt76_dev *dev, enum mt76_txq_id qid);
> void mt76_txq_schedule_all(struct mt76_dev *dev);
> void mt76_release_buffered_frames(struct ieee80211_hw *hw,
> struct ieee80211_sta *sta,
> diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c
> index 2c82db0b5834..ef9a0bbd64c1 100644
> --- a/drivers/net/wireless/mediatek/mt76/tx.c
> +++ b/drivers/net/wireless/mediatek/mt76/tx.c
> @@ -479,23 +479,37 @@ mt76_txq_send_burst(struct mt76_dev *dev, struct mt76_sw_queue *sq,
> }
>
> static int
> -mt76_txq_schedule_list(struct mt76_dev *dev, struct mt76_sw_queue *sq)
> +mt76_txq_schedule_list(struct mt76_dev *dev, enum mt76_txq_id qid)
> {
> + struct mt76_sw_queue *sq = &dev->q_tx[qid];
> struct mt76_queue *hwq = sq->q;
> - struct mt76_txq *mtxq, *mtxq_last;
> - int len = 0;
> + struct ieee80211_txq *txq;
> + struct mt76_txq *mtxq;
> + struct mt76_wcid *wcid;
> + int ret = 0;
>
> -restart:
> - mtxq_last = list_last_entry(&sq->swq, struct mt76_txq, list);
> - while (!list_empty(&sq->swq)) {
> + spin_lock_bh(&hwq->lock);
> + while (1) {
> bool empty = false;
> - int cur;
> +
> + if (sq->swq_queued >= 4)
> + break;
>
> if (test_bit(MT76_OFFCHANNEL, &dev->state) ||
> - test_bit(MT76_RESET, &dev->state))
> - return -EBUSY;
> + test_bit(MT76_RESET, &dev->state)) {
> + ret = -EBUSY;
> + break;
> + }
> +
> + txq = ieee80211_next_txq(dev->hw, qid);
> + if (!txq)
> + break;
> +
> + mtxq = (struct mt76_txq *)txq->drv_priv;
> + wcid = mtxq->wcid;
> + if (wcid && test_bit(MT_WCID_FLAG_PS, &wcid->flags))
> + continue;
>
> - mtxq = list_first_entry(&sq->swq, struct mt76_txq, list);
> if (mtxq->send_bar && mtxq->aggr) {
> struct ieee80211_txq *txq = mtxq_to_txq(mtxq);
> struct ieee80211_sta *sta = txq->sta;
> @@ -507,38 +521,36 @@ mt76_txq_schedule_list(struct mt76_dev *dev, struct mt76_sw_queue *sq)
> spin_unlock_bh(&hwq->lock);
> ieee80211_send_bar(vif, sta->addr, tid, agg_ssn);
> spin_lock_bh(&hwq->lock);
> - goto restart;
> }
>
> - list_del_init(&mtxq->list);
> -
> - cur = mt76_txq_send_burst(dev, sq, mtxq, &empty);
> + ret += mt76_txq_send_burst(dev, sq, mtxq, &empty);
> if (!empty)
> - list_add_tail(&mtxq->list, &sq->swq);
> -
> - if (cur < 0)
> - return cur;
> -
> - len += cur;
> -
> - if (mtxq == mtxq_last)
> - break;
> + ieee80211_return_txq(dev->hw, txq);
The call to ieee80211_return_txq() is really meant to be unconditional.
The TXQ will only actually be scheduled if it still has packets queued.
I know it's slightly more expensive to have the check in mac80211, but
this is what makes it possible to change the implementation without
touching the drivers (such as in the RFC patch I sent earlier that
switches the scheduling algorithm)...
-Toke
next prev parent reply other threads:[~2019-03-16 22:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-16 20:42 [PATCH 1/6] mt76: use mac80211 txq scheduling Felix Fietkau
2019-03-16 20:42 ` [PATCH 2/6] mt76: reduce locking in mt76_dma_tx_cleanup Felix Fietkau
2019-03-16 20:42 ` [PATCH 3/6] mt76: store wcid tx rate info in one u32 reduce locking Felix Fietkau
2019-03-16 20:42 ` [PATCH 4/6] mt76: store software PN/IV in wcid Felix Fietkau
2019-03-18 10:21 ` Stanislaw Gruszka
2019-03-18 10:37 ` Felix Fietkau
2019-03-16 20:42 ` [PATCH 5/6] mt76: move tx tasklet to struct mt76_dev Felix Fietkau
2019-03-16 20:42 ` [PATCH 6/6] mt76: only schedule txqs from the tx tasklet Felix Fietkau
2019-03-16 22:28 ` Toke Høiland-Jørgensen [this message]
2019-03-17 10:44 ` [PATCH 1/6] mt76: use mac80211 txq scheduling Felix Fietkau
2019-03-17 11:32 ` Toke Høiland-Jørgensen
2019-03-17 12:32 ` Felix Fietkau
2019-03-17 21:59 ` Toke Høiland-Jørgensen
2019-03-18 20:08 ` Felix Fietkau
2019-03-18 22:14 ` Toke Høiland-Jørgensen
2019-03-18 22:37 ` Felix Fietkau
2019-03-18 23:05 ` Toke Høiland-Jørgensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87muluv4hd.fsf@toke.dk \
--to=toke@redhat.com \
--cc=linux-wireless@vger.kernel.org \
--cc=nbd@nbd.name \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).