From: Johannes Berg <johannes@sipsolutions.net>
To: Christian Lamparter <chunkeey@googlemail.com>
Cc: "John W. Linville" <linville@tuxdriver.com>,
linux-wireless@vger.kernel.org,
Ben Greear <greearb@candelatech.com>,
Ming Lei <tom.leiming@gmail.com>
Subject: Re: [PATCH] mac80211: hoist sta->lock from reorder release timer
Date: Fri, 08 Oct 2010 20:45:26 +0200 [thread overview]
Message-ID: <1286563526.3612.33.camel@jlt3.sipsolutions.net> (raw)
In-Reply-To: <201010082012.07007.chunkeey@googlemail.com>
On Fri, 2010-10-08 at 20:12 +0200, Christian Lamparter wrote:
> But hey, wait a sec. (This one is about AP mode - It's related to
> IEEE80211_RX_RA_MATCH, but now in a different handler)
Heh.
> NULLFUNCs (set/clear PM) are not reordered and they get
> processed right away, right?
Yeah, I don't think they can be in A-MPDUs. At least not in any scenario
that actually makes sense.
> So what if the reorder release triggers and ap_sta_ps_end
> (called by ieee80211_rx_h_sta_process) accidentally resets
> the "sleeping" flag (because some old frames with a "stale"
> PSM bit was released after 100ms)?
Yeah... that can happen.
> > > Things are a little bit better with ieee80211_rx_h_sta_process.
> > > It updates some statistics and takes care of sta->last_rx
> > > (which is currently not that important giving HT BA is only supported
> > > for AP/STA operation).
> > >
> > > In ieee80211_rx_h_data, there could be another potential problem:
> > > > if (ieee80211_is_data(hdr->frame_control) &&
> > > > !is_multicast_ether_addr(hdr->addr1) &&
> > > > local->hw.conf.dynamic_ps_timeout > 0 && local->ps_sdata) {
> > > > mod_timer(&local->dynamic_ps_timer, jiffies +
> > > > msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout));
> > > > }
> > > I reckon there could be a "hidden" problem. "jiffies" is now
> > > approx 100ms after the packet was received from the interface.
> > > (Sure, a similar issue was also present in the original
> > > reorder release implementation.)
> >
> > This one's more interesting. I guess we need to bypass these things
> > somehow, maybe setting a flag if this was a "recovered" frame?
> (and check the same flag for ap_sta_ps_end/ap_sta_ps_start).
> Ok, that's doable (even for me :D)
Yeah, something like that. I guess there are more things like that and
we have to go through the RX path once -- but it shouldn't be all that
hard.
> > BHs are disabled while processing RX -- and timer is a BH itself so
> > they're also disabled, right?
> hmm, are we talking about BH or tasklets?
RX is currently always processed in a tasklet.
> I read something about the
> occurrence of simultaneous tasklets/timers on multi-core systems?
You're right, it's local_bh_disable ... the local is there for a
reason :-)
> And from a point that all made sense:
> ---
> from kernel-hacking.DocBook:
>
> "For this reason, tasklets are more often used: they are
> dynamically-registrable (meaning you can have as many as you want),
> and they also guarantee that any tasklet will only run on one CPU
> at any time, although different tasklets can run simultaneously."
Yeah.
> and kernel-locking.DocBook:
> "Different Tasklets/Timers:
> If another tasklet/timer wants to share data with your tasklet or timer,
> you will both need to use spin_lock() and spin_unlock() calls.
> spin_lock_bh() is unnecessary here, as you are already in a tasklet, and
> none will be run on the same CPU." <-- "same" CPU.
Indeed.
> So according to statements above, we need a lock for the stats
> too. (and I was wrong about "converting" them all to atomic.)
>
> * ieee80211_rx_h_sta_process
> sta->rx_packets++;
> sta->rx_fragments++;
> sta->rx_bytes += rx->skb->len;
>
> * ieee80211_rx_h_data:
> dev->stats.rx_packets++;
> dev->stats.rx_bytes += rx->skb->len;
Yeah. It's too bad we can't just disable the tasklet while processing
the timer -- but we can't because we might also be processing from
another context, even process context with BHs disabled, from driver
calls to ieee80211_rx() (without _irqsafe).
So we need a lock. Question then is, which one do we use? We could use
the sta lock (and get rid of the reorder lock again), that would allow
processing RX frames for STA A while we're doing timeouts for STA B --
as long as we don't also process a frame for B which would block, but
presumably something is wrong when the timeout happens ...
But then using the sta lock could be fairly expensive. It might actually
be cheaper to simply remove the distinction between _rx() and
_rx_irqsafe() and make it all go through the tasklet -- then we can
simply disable the tasklet while doing the timer processing....
I don't like reverting these patches, but maybe we should simply comment
out the code that arms the timer, thereby disabling all of it, while we
work on this?
johannes
prev parent reply other threads:[~2010-10-08 18:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-06 10:00 [PATCH] mac80211: hoist sta->lock from reorder release timer Christian Lamparter
2010-10-06 10:10 ` Johannes Berg
2010-10-06 10:20 ` Christian Lamparter
2010-10-06 10:41 ` Johannes Berg
2010-10-06 11:43 ` Christian Lamparter
2010-10-06 11:46 ` Johannes Berg
2010-10-06 20:21 ` John W. Linville
2010-10-07 21:03 ` Johannes Berg
2010-10-08 16:42 ` Christian Lamparter
2010-10-08 16:53 ` Johannes Berg
2010-10-08 18:12 ` Christian Lamparter
2010-10-08 18:45 ` Johannes Berg [this message]
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=1286563526.3612.33.camel@jlt3.sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=chunkeey@googlemail.com \
--cc=greearb@candelatech.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=tom.leiming@gmail.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 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).