* [question] panic when calling drv_get_tsf [not found] <55E9A07E.8070005@gmail.com> @ 2015-09-07 17:44 ` ferran 2015-09-08 1:20 ` Bob Copeland 0 siblings, 1 reply; 3+ messages in thread From: ferran @ 2015-09-07 17:44 UTC (permalink / raw) To: linux-wireless Dear all, I'm having some issues in a modified version of mac80211, which I hope you will help me with. I want to report a lower bound of the channel utilization to which a mesh device is tuned in for a research project. So far, I can read successfully from debugfs this new statistic updated periodically, targeting mesh interfaces and tested only with atheros cards. However, I would like to improve it as I describe at the end. The strategy is to keep adding the rx and tx used time until a [mesh] beacon is sent, and then, trigger a custom function that derives the utilization for that given interval. This one reads the elapsed time since the previous beacon (should be 1000 TU in mesh mode) and resets the counters. Caller function: --- tx.c --- struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 *tim_offset, u16 *tim_length) { struct ieee80211_local *local = hw_to_local(hw); ... rcu_read_lock(); sdata = vif_to_sdata(vif); ... out: rcu_read_unlock(); /* HERE */ my_function(local, sdata->name, sdata); return skb; } My function. Note that I've modified ieee80211_local to share data between "rx", "tx status" and "beacon tx" contexts. The line comments fix the error. --- tx.c --- static void my_function(struct ieee80211_local *local, char *if_name, struct ieee80211_sub_if_data *sdata){ u64 beacon_interval = 1000 * 1024 // 1.024 seconds. /* Retrieve counters and add them up */ /* ↓ KERNEL PANIC HERE ↓ */ // current_tsf = drv_get_tsf(local, sdata); // beacon_interval = current_tsf - local->ch_load.last_tsf_channel_load_update; rem = do_div(total_used_time, beacon_interval); // compute utilization /* do some averaging and save */ /* reset counters */ } So firstly, why can't I call drv_get_tsf from there? Is it because TSF is exactly then being reset? Secondly, I feel unsafe about synchronization. Should I rcu-protect all operations on ieee80211_sub_if_data, ieee80211_hw and sk_buff? Worker functions on rx.c and status.c do read values from those structures. Finally, I would be interested on using TSF to measure the time passed since a packet is scheduled to transmit in tx.c and its report is received at status.c. Do you think that TSF be usable for this? Thanks for your help! Ferran ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [question] panic when calling drv_get_tsf 2015-09-07 17:44 ` [question] panic when calling drv_get_tsf ferran @ 2015-09-08 1:20 ` Bob Copeland 2015-09-14 17:40 ` ferran 0 siblings, 1 reply; 3+ messages in thread From: Bob Copeland @ 2015-09-08 1:20 UTC (permalink / raw) To: ferran; +Cc: linux-wireless@vger.kernel.org On Mon, Sep 7, 2015 at 1:44 PM, ferran <ranker72@gmail.com> wrote: > > So firstly, why can't I call drv_get_tsf from there? Is it because TSF > is exactly then being reset? Secondly, I feel unsafe about You left out posting the actual panic/warning you got, but one possibility is beacon_get is called under a lock that the driver also takes inside drv_get_tsf(). Usually this function just reads a register so it's unlikely that reading the tsf itself during an update will give any troubles (other than wrong values). > Finally, I would be interested on using TSF to measure the time passed > since a packet is scheduled to transmit in tx.c and its report is > received at status.c. Do you think that TSF be usable for this? I am not sure what you want to do, but some things to think about regarding TSF: - reading the TSF from the driver with drv_get_tsf() will give you something that may or may not be usable. For example, depending on calling context, the process that reads the TSF might get scheduled out for an unknown amount of time between when you read it and when you use it. - in mesh, the TSF changes as the network operates. The stations try to adjust their clocks so that their timing offsets are synchronized (making it possible to know a neighbor's TBTT). -- Bob Copeland %% www.bobcopeland.com ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [question] panic when calling drv_get_tsf 2015-09-08 1:20 ` Bob Copeland @ 2015-09-14 17:40 ` ferran 0 siblings, 0 replies; 3+ messages in thread From: ferran @ 2015-09-14 17:40 UTC (permalink / raw) To: linux-wireless Qm9iIENvcGVsYW5kIDxtZUAuLi4+IHdyaXRlczoKCgpIaSBCb2IsCgpUaGFuayB5b3UgZm9yIGNvbnRyaWJ1dGluZyBhbmQgc3VwcG9ydGluZyBzbyBhY3RpdmVseSB0aGUgbWVzaCBkZXZlbG9wbWVudC4KSSB1bmRlcnN0b29kIHRoZSBpc3N1ZXMgd2l0aCBUU0YsIHNvIEkgc3RvcHBlZCB1c2luZyBpdC4KCk15IGFpbSBpcyB0byBhcHByb3h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CBmdXR1cmUuCgpUaGFuayB5b3UsCkZlcnJhbg== ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-09-14 17:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <55E9A07E.8070005@gmail.com>
2015-09-07 17:44 ` [question] panic when calling drv_get_tsf ferran
2015-09-08 1:20 ` Bob Copeland
2015-09-14 17:40 ` ferran
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).