From: Felix Fietkau <nbd@openwrt.org>
To: ath9k-devel@lists.ath9k.org
Subject: [ath9k-devel] [RFC 03/10] ath9k: add dynamic ack timeout estimation
Date: Mon, 07 Jul 2014 14:02:37 +0200 [thread overview]
Message-ID: <53BA8C5D.4000604@openwrt.org> (raw)
In-Reply-To: <0D7AC98D-7356-44BC-8DBC-2916DF58F41F@net.t-labs.tu-berlin.de>
On 2014-07-07 13:41, Thomas H?hn wrote:
>> +{
>> + struct ath_node *an;
>> + u32 to = 0;
>> + struct ath_dynack *da = &ah->dynack;
>> + struct ath_common *common = ath9k_hw_common(ah);
>> +
>
>> + list_for_each_entry(an, &da->nodes, list)
>> + if (an->ackto > to)
>> + to = an->ackto;
>> +
>
> This list parsing would probably need rcu protection like:
>
> rcu_read_lock();
> list_for_each_entry(an, &da->nodes, list)
> if (an->ackto > to)
> to = an->ackto;
> rcu_read_unlock();
Nope, that's already done in the calling code.
> I am not sure that you need to call the entire function with spin_lock as you do it now.
>
>> + if (to && da->ackto != to) {
>> + u32 slottime;
>> +
>> + slottime = (to - 3) / 2;
>
> Should the case to < 3 be covered or is it safe to have potentially slottime = 0 ?
slottime should never be 0. It is not user configurable.
>> +/**
>> + * ath_dynack_compute_to - compute ack timeout
>> + * @ah: ath hw
>> + *
>> + * should be called while holding qlock
>> + */
>> +static void ath_dynack_compute_to(struct ath_hw *ah)
>> +{
>> + u32 ackto, ack_ts;
>> + u8 *dst, *src;
>> + struct ieee80211_sta *sta;
>> + struct ath_node *an;
>> + struct ts_info *st_ts;
>> + struct ath_dynack *da = &ah->dynack;
>> +
>> + rcu_read_lock();
>> +
>> + while (da->st_rbf.h_rb != da->st_rbf.t_rb &&
>> + da->ack_rbf.h_rb != da->ack_rbf.t_rb) {
>> + ack_ts = da->ack_rbf.tstamp[da->ack_rbf.h_rb];
>> + st_ts = &da->st_rbf.ts[da->st_rbf.h_rb];
>> + dst = da->st_rbf.addr[da->st_rbf.h_rb].h_dest;
>> + src = da->st_rbf.addr[da->st_rbf.h_rb].h_src;
>> +
>> + ath_dbg(ath9k_hw_common(ah), DYNACK,
>> + "ack_ts %u st_ts %u st_dur %u [%u-%u]\n",
>> + ack_ts, st_ts->tstamp, st_ts->dur,
>> + da->ack_rbf.h_rb, da->st_rbf.h_rb);
>> +
>> + if (ack_ts > st_ts->tstamp + st_ts->dur) {
>> + ackto = ack_ts - st_ts->tstamp - st_ts->dur;
>> +
>> + if (ackto < MAX_DELAY) {
>> + sta = ieee80211_find_sta_by_ifaddr(ah->hw, dst,
>> + src);
>> + if (sta) {
>> + an = (struct ath_node *)sta->drv_priv;
>> + an->ackto = DYNACK_EWMA((u32)ackto,
>> + an->ackto);
>> + ath_dbg(ath9k_hw_common(ah), DYNACK,
>> + "%pM to %u\n", dst, an->ackto);
>> + if (time_is_before_jiffies(da->lto)) {
>> + ath_dynack_compute_ackto(ah);
>> + da->lto = jiffies + COMPUTE_TO;
>> + }
>> + }
>> + INCR(da->ack_rbf.h_rb, ATH_DYN_BUF);
>> + }
>> + INCR(da->st_rbf.h_rb, ATH_DYN_BUF);
>> + } else {
>> + INCR(da->ack_rbf.h_rb, ATH_DYN_BUF);
>> + }
>> + }
>> +
>> + rcu_read_unlock();
>
> I think it is sufficient to have the rcu_read_unlock just around
> ieee80211_find_sta_by_ifaddr(). So the lock does not need to
> include the whole while loop under lock.
That doesn't make things any better - rcu_read_lock is not like a normal
lock. Doing it once outside of the loop is not only simpler, but also
slightly more efficient.
- Felix
WARNING: multiple messages have this Message-ID (diff)
From: Felix Fietkau <nbd@openwrt.org>
To: "Thomas Hühn" <thomas@net.t-labs.tu-berlin.de>,
"Lorenzo Bianconi" <lorenzo.bianconi83@gmail.com>
Cc: ath9k-devel <ath9k-devel@lists.ath9k.org>,
linux-wireless <linux-wireless@vger.kernel.org>
Subject: Re: [ath9k-devel] [RFC 03/10] ath9k: add dynamic ack timeout estimation
Date: Mon, 07 Jul 2014 14:02:37 +0200 [thread overview]
Message-ID: <53BA8C5D.4000604@openwrt.org> (raw)
In-Reply-To: <0D7AC98D-7356-44BC-8DBC-2916DF58F41F@net.t-labs.tu-berlin.de>
On 2014-07-07 13:41, Thomas Hühn wrote:
>> +{
>> + struct ath_node *an;
>> + u32 to = 0;
>> + struct ath_dynack *da = &ah->dynack;
>> + struct ath_common *common = ath9k_hw_common(ah);
>> +
>
>> + list_for_each_entry(an, &da->nodes, list)
>> + if (an->ackto > to)
>> + to = an->ackto;
>> +
>
> This list parsing would probably need rcu protection like:
>
> rcu_read_lock();
> list_for_each_entry(an, &da->nodes, list)
> if (an->ackto > to)
> to = an->ackto;
> rcu_read_unlock();
Nope, that's already done in the calling code.
> I am not sure that you need to call the entire function with spin_lock as you do it now.
>
>> + if (to && da->ackto != to) {
>> + u32 slottime;
>> +
>> + slottime = (to - 3) / 2;
>
> Should the case to < 3 be covered or is it safe to have potentially slottime = 0 ?
slottime should never be 0. It is not user configurable.
>> +/**
>> + * ath_dynack_compute_to - compute ack timeout
>> + * @ah: ath hw
>> + *
>> + * should be called while holding qlock
>> + */
>> +static void ath_dynack_compute_to(struct ath_hw *ah)
>> +{
>> + u32 ackto, ack_ts;
>> + u8 *dst, *src;
>> + struct ieee80211_sta *sta;
>> + struct ath_node *an;
>> + struct ts_info *st_ts;
>> + struct ath_dynack *da = &ah->dynack;
>> +
>> + rcu_read_lock();
>> +
>> + while (da->st_rbf.h_rb != da->st_rbf.t_rb &&
>> + da->ack_rbf.h_rb != da->ack_rbf.t_rb) {
>> + ack_ts = da->ack_rbf.tstamp[da->ack_rbf.h_rb];
>> + st_ts = &da->st_rbf.ts[da->st_rbf.h_rb];
>> + dst = da->st_rbf.addr[da->st_rbf.h_rb].h_dest;
>> + src = da->st_rbf.addr[da->st_rbf.h_rb].h_src;
>> +
>> + ath_dbg(ath9k_hw_common(ah), DYNACK,
>> + "ack_ts %u st_ts %u st_dur %u [%u-%u]\n",
>> + ack_ts, st_ts->tstamp, st_ts->dur,
>> + da->ack_rbf.h_rb, da->st_rbf.h_rb);
>> +
>> + if (ack_ts > st_ts->tstamp + st_ts->dur) {
>> + ackto = ack_ts - st_ts->tstamp - st_ts->dur;
>> +
>> + if (ackto < MAX_DELAY) {
>> + sta = ieee80211_find_sta_by_ifaddr(ah->hw, dst,
>> + src);
>> + if (sta) {
>> + an = (struct ath_node *)sta->drv_priv;
>> + an->ackto = DYNACK_EWMA((u32)ackto,
>> + an->ackto);
>> + ath_dbg(ath9k_hw_common(ah), DYNACK,
>> + "%pM to %u\n", dst, an->ackto);
>> + if (time_is_before_jiffies(da->lto)) {
>> + ath_dynack_compute_ackto(ah);
>> + da->lto = jiffies + COMPUTE_TO;
>> + }
>> + }
>> + INCR(da->ack_rbf.h_rb, ATH_DYN_BUF);
>> + }
>> + INCR(da->st_rbf.h_rb, ATH_DYN_BUF);
>> + } else {
>> + INCR(da->ack_rbf.h_rb, ATH_DYN_BUF);
>> + }
>> + }
>> +
>> + rcu_read_unlock();
>
> I think it is sufficient to have the rcu_read_unlock just around
> ieee80211_find_sta_by_ifaddr(). So the lock does not need to
> include the whole while loop under lock.
That doesn't make things any better - rcu_read_lock is not like a normal
lock. Doing it once outside of the loop is not only simpler, but also
slightly more efficient.
- Felix
next prev parent reply other threads:[~2014-07-07 12:02 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-07 9:31 [ath9k-devel] [RFC 00/10] add support for ack timeout estimation in ath9k driver Lorenzo Bianconi
2014-07-07 9:31 ` Lorenzo Bianconi
2014-07-07 9:31 ` [ath9k-devel] [RFC 01/10] ath9k: export methods related to ack timeout estimation Lorenzo Bianconi
2014-07-07 9:31 ` Lorenzo Bianconi
2014-07-07 9:31 ` [ath9k-devel] [RFC 02/10] ath9k: add duration field to ath_tx_status Lorenzo Bianconi
2014-07-07 9:31 ` Lorenzo Bianconi
2014-07-07 9:31 ` [ath9k-devel] [RFC 03/10] ath9k: add dynamic ack timeout estimation Lorenzo Bianconi
2014-07-07 9:31 ` Lorenzo Bianconi
2014-07-07 11:41 ` [ath9k-devel] " Thomas Hühn
2014-07-07 11:41 ` Thomas Hühn
2014-07-07 12:02 ` Felix Fietkau [this message]
2014-07-07 12:02 ` Felix Fietkau
2014-07-07 18:36 ` Lorenzo Bianconi
2014-07-07 18:36 ` Lorenzo Bianconi
2014-07-09 14:49 ` Sujith Manoharan
2014-07-09 14:49 ` Sujith Manoharan
2014-07-09 17:47 ` [ath9k-devel] " Lorenzo Bianconi
2014-07-09 17:47 ` Lorenzo Bianconi
2014-07-10 10:17 ` [ath9k-devel] " Hosam Hittini
2014-07-07 9:31 ` [ath9k-devel] [RFC 04/10] ath9k: add config for (en|dis)abling " Lorenzo Bianconi
2014-07-07 9:31 ` Lorenzo Bianconi
2014-07-07 9:31 ` [ath9k-devel] [RFC 05/10] ath9k: do not overwrite " Lorenzo Bianconi
2014-07-07 9:31 ` Lorenzo Bianconi
2014-07-07 9:31 ` [ath9k-devel] [RFC 06/10] ath9k: add sampling methods for (tx|rx) timestamp Lorenzo Bianconi
2014-07-07 9:31 ` Lorenzo Bianconi
2014-07-07 9:31 ` [ath9k-devel] [RFC 07/10] ath9k: enable control frame reception Lorenzo Bianconi
2014-07-07 9:31 ` Lorenzo Bianconi
2014-07-07 9:31 ` [ath9k-devel] [RFC 08/10] ath9k: add debugfs support for dynack Lorenzo Bianconi
2014-07-07 9:31 ` Lorenzo Bianconi
2014-07-07 9:31 ` [ath9k-devel] [RFC 09/10] ath9k: disable dynack algorithm when coverage class is set Lorenzo Bianconi
2014-07-07 9:31 ` Lorenzo Bianconi
2014-07-07 9:31 ` [ath9k-devel] [RFC 10/10] ath9k: add ath_node linked list Lorenzo Bianconi
2014-07-07 9:31 ` Lorenzo Bianconi
2014-07-11 22:08 ` [ath9k-devel] [RFC 00/10] add support for ack timeout estimation in ath9k driver Philippe DUCHEIN
2014-07-11 22:08 ` Philippe DUCHEIN
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=53BA8C5D.4000604@openwrt.org \
--to=nbd@openwrt.org \
--cc=ath9k-devel@lists.ath9k.org \
/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.