All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yibo Zhao <yiboz@codeaurora.org>
To: Felix Fietkau <nbd@nbd.name>
Cc: linux-wireless@vger.kernel.org, johannes@sipsolutions.net,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	linux-wireless-owner@vger.kernel.org
Subject: Re: [PATCH] mac80211: rework locking for txq scheduling / airtime fairness
Date: Thu, 10 Oct 2019 10:43:49 +0800	[thread overview]
Message-ID: <b2bded992cb02bad84fc738b7e4b1837@codeaurora.org> (raw)
In-Reply-To: <20190315100335.91445-1-nbd@nbd.name>

> diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
> index ca23abbf5c0b..51cc37802439 100644
> --- a/net/mac80211/tx.c
> +++ b/net/mac80211/tx.c
> @@ -3653,16 +3653,17 @@ EXPORT_SYMBOL(ieee80211_tx_dequeue);
>  struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 
> ac)
>  {
>  	struct ieee80211_local *local = hw_to_local(hw);
> +	struct ieee80211_txq *ret = NULL;
>  	struct txq_info *txqi = NULL;
> 
> -	lockdep_assert_held(&local->active_txq_lock[ac]);
> +	spin_lock_bh(&local->active_txq_lock[ac]);
> 
>   begin:
>  	txqi = list_first_entry_or_null(&local->active_txqs[ac],
>  					struct txq_info,
>  					schedule_order);
>  	if (!txqi)
> -		return NULL;
> +		goto out;
> 
>  	if (txqi->txq.sta) {
>  		struct sta_info *sta = container_of(txqi->txq.sta,
> @@ -3679,21 +3680,25 @@ struct ieee80211_txq
> *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac)
> 
> 
>  	if (txqi->schedule_round == local->schedule_round[ac])
> -		return NULL;
> +		goto out;
> 
>  	list_del_init(&txqi->schedule_order);
>  	txqi->schedule_round = local->schedule_round[ac];
> -	return &txqi->txq;
> +	ret = &txqi->txq;
> +
> +out:
> +	spin_unlock_bh(&local->active_txq_lock[ac]);
> +	return ret;
>  }
>  EXPORT_SYMBOL(ieee80211_next_txq);
> 
> -void ieee80211_return_txq(struct ieee80211_hw *hw,
> -			  struct ieee80211_txq *txq)
> +void ieee80211_schedule_txq(struct ieee80211_hw *hw,
> +			    struct ieee80211_txq *txq)
>  {
>  	struct ieee80211_local *local = hw_to_local(hw);
>  	struct txq_info *txqi = to_txq_info(txq);
> 
> -	lockdep_assert_held(&local->active_txq_lock[txq->ac]);
> +	spin_lock_bh(&local->active_txq_lock[txq->ac]);
> 
>  	if (list_empty(&txqi->schedule_order) &&
>  	    (!skb_queue_empty(&txqi->frags) || txqi->tin.backlog_packets)) {
> @@ -3713,17 +3718,7 @@ void ieee80211_return_txq(struct ieee80211_hw 
> *hw,
>  			list_add_tail(&txqi->schedule_order,
>  				      &local->active_txqs[txq->ac]);
>  	}
> -}
> -EXPORT_SYMBOL(ieee80211_return_txq);
> 
> -void ieee80211_schedule_txq(struct ieee80211_hw *hw,
> -			    struct ieee80211_txq *txq)
> -	__acquires(txq_lock) __releases(txq_lock)
> -{
> -	struct ieee80211_local *local = hw_to_local(hw);
> -
> -	spin_lock_bh(&local->active_txq_lock[txq->ac]);
> -	ieee80211_return_txq(hw, txq);
>  	spin_unlock_bh(&local->active_txq_lock[txq->ac]);
>  }
>  EXPORT_SYMBOL(ieee80211_schedule_txq);
> @@ -3736,7 +3731,7 @@ bool ieee80211_txq_may_transmit(struct 
> ieee80211_hw *hw,
>  	struct sta_info *sta;
>  	u8 ac = txq->ac;
> 
> -	lockdep_assert_held(&local->active_txq_lock[ac]);
> +	spin_lock_bh(&local->active_txq_lock[ac]);
> 
>  	if (!txqi->txq.sta)
>  		goto out;
> @@ -3766,34 +3761,27 @@ bool ieee80211_txq_may_transmit(struct 
> ieee80211_hw *hw,
> 
>  	sta->airtime[ac].deficit += sta->airtime_weight;
>  	list_move_tail(&txqi->schedule_order, &local->active_txqs[ac]);
> +	spin_unlock_bh(&local->active_txq_lock[ac]);
> 
>  	return false;
>  out:
>  	if (!list_empty(&txqi->schedule_order))
>  		list_del_init(&txqi->schedule_order);
> +	spin_unlock_bh(&local->active_txq_lock[ac]);
> 
>  	return true;
>  }
>  EXPORT_SYMBOL(ieee80211_txq_may_transmit);
> 
>  void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac)
> -	__acquires(txq_lock)
>  {
>  	struct ieee80211_local *local = hw_to_local(hw);
> 
>  	spin_lock_bh(&local->active_txq_lock[ac]);
>  	local->schedule_round[ac]++;
Hi Felix,

In ath10k, we might have situations like,

           CPU0                           CPU1
...                                   ieee80211_txq_schedule_start()
...                                   while(ieee80211_next_txq()) {
...                                       driver dequeue packets from 
txq
...                                       ieee80211_return_txq()
ieee80211_txq_schedule_start()            ...
ieee80211_next_txq()                  }
driver dequeue packets from txq       ieee80211_txq_schedule_end()
ieee80211_return_txq()
ieee80211_txq_schedule_end()

The problem is while CPU1 is looping to dequeue txqs, the schedule_round 
which is used to make sure no infinite loop will be changed in CPU0. So 
a txq has already been scheduled will be scheduled again then the loop 
won't be end at that point as our expected.

> -}
> -EXPORT_SYMBOL(ieee80211_txq_schedule_start);
> -
> -void ieee80211_txq_schedule_end(struct ieee80211_hw *hw, u8 ac)
> -	__releases(txq_lock)
> -{
> -	struct ieee80211_local *local = hw_to_local(hw);
> -
>  	spin_unlock_bh(&local->active_txq_lock[ac]);
>  }
> -EXPORT_SYMBOL(ieee80211_txq_schedule_end);
> +EXPORT_SYMBOL(ieee80211_txq_schedule_start);
> 
>  void __ieee80211_subif_start_xmit(struct sk_buff *skb,
>  				  struct net_device *dev,

-- 
Yibo

  parent reply	other threads:[~2019-10-10  2:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-15 10:03 [PATCH] mac80211: rework locking for txq scheduling / airtime fairness Felix Fietkau
2019-03-15 13:04 ` Toke Høiland-Jørgensen
2019-10-10  2:43 ` Yibo Zhao [this message]
2019-10-10  5:56   ` Felix Fietkau

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=b2bded992cb02bad84fc738b7e4b1837@codeaurora.org \
    --to=yiboz@codeaurora.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless-owner@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nbd@nbd.name \
    --cc=toke@redhat.com \
    /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 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.