Use a single cleanup timer per wpa_supplicant process

Previously, one timeout per process (by default every 30 seconds) was
used P2P peer expiration and another per-interface timeout (every 10
seconds) was used to expire BSS entries. Merge these to a single
per-process timeout that triggers every 10 seconds to minimize number of
process wakeups due to periodic operations.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2015-07-20 13:11:31 +03:00 committed by Jouni Malinen
parent 7b7e8a2ee7
commit 8c0d0ff22e
4 changed files with 38 additions and 33 deletions

View File

@ -48,9 +48,8 @@ static void p2p_scan_timeout(void *eloop_ctx, void *timeout_ctx);
#define P2P_PEER_EXPIRATION_AGE 60
#endif /* P2P_PEER_EXPIRATION_AGE */
#define P2P_PEER_EXPIRATION_INTERVAL (P2P_PEER_EXPIRATION_AGE / 2)
static void p2p_expire_peers(struct p2p_data *p2p)
void p2p_expire_peers(struct p2p_data *p2p)
{
struct p2p_device *dev, *n;
struct os_reltime now;
@ -103,15 +102,6 @@ static void p2p_expire_peers(struct p2p_data *p2p)
}
static void p2p_expiration_timeout(void *eloop_ctx, void *timeout_ctx)
{
struct p2p_data *p2p = eloop_ctx;
p2p_expire_peers(p2p);
eloop_register_timeout(P2P_PEER_EXPIRATION_INTERVAL, 0,
p2p_expiration_timeout, p2p, NULL);
}
static const char * p2p_state_txt(int state)
{
switch (state) {
@ -2919,9 +2909,6 @@ struct p2p_data * p2p_init(const struct p2p_config *cfg)
dl_list_init(&p2p->devices);
eloop_register_timeout(P2P_PEER_EXPIRATION_INTERVAL, 0,
p2p_expiration_timeout, p2p, NULL);
p2p->go_timeout = 100;
p2p->client_timeout = 20;
p2p->num_p2p_sd_queries = 0;
@ -2950,7 +2937,6 @@ void p2p_deinit(struct p2p_data *p2p)
wpabuf_free(p2p->wfd_coupled_sink_info);
#endif /* CONFIG_WIFI_DISPLAY */
eloop_cancel_timeout(p2p_expiration_timeout, p2p, NULL);
eloop_cancel_timeout(p2p_ext_listen_timeout, p2p, NULL);
eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL);
eloop_cancel_timeout(p2p_go_neg_start, p2p, NULL);

View File

@ -2256,4 +2256,13 @@ int p2p_service_del_asp(struct p2p_data *p2p, u32 adv_id);
void p2p_service_flush_asp(struct p2p_data *p2p);
struct p2ps_advertisement * p2p_get_p2ps_adv_list(struct p2p_data *p2p);
/**
* p2p_expire_peers - Periodic cleanup function to expire peers
* @p2p: P2P module context from p2p_init()
*
* This is a cleanup function that the entity calling p2p_init() is
* expected to call periodically to clean up expired peer entries.
*/
void p2p_expire_peers(struct p2p_data *p2p);
#endif /* P2P_H */

View File

@ -19,11 +19,6 @@
#include "bss.h"
/**
* WPA_BSS_EXPIRATION_PERIOD - Period of expiration run in seconds
*/
#define WPA_BSS_EXPIRATION_PERIOD 10
#define WPA_BSS_FREQ_CHANGED_FLAG BIT(0)
#define WPA_BSS_SIGNAL_CHANGED_FLAG BIT(1)
#define WPA_BSS_PRIVACY_CHANGED_FLAG BIT(2)
@ -828,16 +823,6 @@ void wpa_bss_flush_by_age(struct wpa_supplicant *wpa_s, int age)
}
static void wpa_bss_timeout(void *eloop_ctx, void *timeout_ctx)
{
struct wpa_supplicant *wpa_s = eloop_ctx;
wpa_bss_flush_by_age(wpa_s, wpa_s->conf->bss_expiration_age);
eloop_register_timeout(WPA_BSS_EXPIRATION_PERIOD, 0,
wpa_bss_timeout, wpa_s, NULL);
}
/**
* wpa_bss_init - Initialize BSS table
* @wpa_s: Pointer to wpa_supplicant data
@ -850,8 +835,6 @@ int wpa_bss_init(struct wpa_supplicant *wpa_s)
{
dl_list_init(&wpa_s->bss);
dl_list_init(&wpa_s->bss_id);
eloop_register_timeout(WPA_BSS_EXPIRATION_PERIOD, 0,
wpa_bss_timeout, wpa_s, NULL);
return 0;
}
@ -883,7 +866,6 @@ void wpa_bss_flush(struct wpa_supplicant *wpa_s)
*/
void wpa_bss_deinit(struct wpa_supplicant *wpa_s)
{
eloop_cancel_timeout(wpa_bss_timeout, wpa_s, NULL);
wpa_bss_flush(wpa_s);
}

View File

@ -4742,6 +4742,29 @@ static const char * wpa_supplicant_msg_ifname_cb(void *ctx)
#endif /* CONFIG_NO_WPA_MSG */
#ifndef WPA_SUPPLICANT_CLEANUP_INTERVAL
#define WPA_SUPPLICANT_CLEANUP_INTERVAL 10
#endif /* WPA_SUPPLICANT_CLEANUP_INTERVAL */
/* Periodic cleanup tasks */
static void wpas_periodic(void *eloop_ctx, void *timeout_ctx)
{
struct wpa_global *global = eloop_ctx;
struct wpa_supplicant *wpa_s;
eloop_register_timeout(WPA_SUPPLICANT_CLEANUP_INTERVAL, 0,
wpas_periodic, global, NULL);
#ifdef CONFIG_P2P
if (global->p2p)
p2p_expire_peers(global->p2p);
#endif /* CONFIG_P2P */
for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
wpa_bss_flush_by_age(wpa_s, wpa_s->conf->bss_expiration_age);
}
/**
* wpa_supplicant_init - Initialize %wpa_supplicant
* @params: Parameters for %wpa_supplicant
@ -4865,6 +4888,9 @@ struct wpa_global * wpa_supplicant_init(struct wpa_params *params)
}
#endif /* CONFIG_WIFI_DISPLAY */
eloop_register_timeout(WPA_SUPPLICANT_CLEANUP_INTERVAL, 0,
wpas_periodic, global, NULL);
return global;
}
@ -4916,6 +4942,8 @@ void wpa_supplicant_deinit(struct wpa_global *global)
if (global == NULL)
return;
eloop_cancel_timeout(wpas_periodic, global, NULL);
#ifdef CONFIG_WIFI_DISPLAY
wifi_display_deinit(global);
#endif /* CONFIG_WIFI_DISPLAY */