From: Tejaswi Tanikella <tejaswit@codeaurora.org>
To: netdev@vger.kernel.org
Subject: [PATCH net] ipv4: igmp: hold wakelock to prevent delayed reports
Date: Fri, 1 Jun 2018 19:35:41 +0530 [thread overview]
Message-ID: <20180601140532.GA13253@tejaswit-linux.qualcomm.com> (raw)
On receiving a IGMPv2/v3 query, based on max_delay set in the header a
timer is started to send out a response after a random time within
max_delay. If the system then moves into suspend state, Report is
delayed until system wakes up.
In one reported scenario, on arm64 devices, max_delay was set to 10s,
Reports were consistantly delayed if the timer is scheduled after 5 plus
seconds.
Hold wakelock while starting the timer to prevent moving into suspend
state.
Signed-off-by: Tejaswi Tanikella <tejaswit@codeaurora.org>
---
include/linux/igmp.h | 1 +
net/ipv4/igmp.c | 20 ++++++++++++++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/include/linux/igmp.h b/include/linux/igmp.h
index f823185..9be1c58 100644
--- a/include/linux/igmp.h
+++ b/include/linux/igmp.h
@@ -84,6 +84,7 @@ struct ip_mc_list {
};
struct ip_mc_list __rcu *next_hash;
struct timer_list timer;
+ struct wakeup_source *wakeup_src;
int users;
refcount_t refcnt;
spinlock_t lock;
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index b26a81a..c695e2c 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -107,6 +107,9 @@
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#endif
+#ifdef CONFIG_IP_MULTICAST
+#include <linux/pm_wakeup.h>
+#endif
#ifdef CONFIG_IP_MULTICAST
/* Parameter names and values are taken from igmp-v2-06 draft */
@@ -174,7 +177,13 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
static void ip_ma_put(struct ip_mc_list *im)
{
+#ifdef CONFIG_IP_MULTICAST
+ __pm_relax(im->wakeup_src);
+#endif
if (refcount_dec_and_test(&im->refcnt)) {
+#ifdef CONFIG_IP_MULTICAST
+ wakeup_source_unregister(im->wakeup_src);
+#endif
in_dev_put(im->interface);
kfree_rcu(im, rcu);
}
@@ -199,8 +208,10 @@ static void ip_ma_put(struct ip_mc_list *im)
static void igmp_stop_timer(struct ip_mc_list *im)
{
spin_lock_bh(&im->lock);
- if (del_timer(&im->timer))
+ if (del_timer(&im->timer)) {
+ __pm_relax(im->wakeup_src);
refcount_dec(&im->refcnt);
+ }
im->tm_running = 0;
im->reporter = 0;
im->unsolicit_count = 0;
@@ -213,8 +224,10 @@ static void igmp_start_timer(struct ip_mc_list *im, int max_delay)
int tv = prandom_u32() % max_delay;
im->tm_running = 1;
- if (!mod_timer(&im->timer, jiffies+tv+2))
+ if (!mod_timer(&im->timer, jiffies+tv+2)) {
refcount_inc(&im->refcnt);
+ __pm_stay_awake(im->wakeup_src);
+ }
}
static void igmp_gq_start_timer(struct in_device *in_dev)
@@ -250,6 +263,7 @@ static void igmp_mod_timer(struct ip_mc_list *im, int max_delay)
spin_unlock_bh(&im->lock);
return;
}
+ __pm_relax(im->wakeup_src);
refcount_dec(&im->refcnt);
}
igmp_start_timer(im, max_delay);
@@ -1415,6 +1429,8 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
#ifdef CONFIG_IP_MULTICAST
timer_setup(&im->timer, igmp_timer_expire, 0);
im->unsolicit_count = net->ipv4.sysctl_igmp_qrv;
+ im->wakeup_src = wakeup_source_create("igmp_wakeup_source");
+ wakeup_source_add(im->wakeup_src);
#endif
im->next_rcu = in_dev->mc_list;
--
1.9.1
next reply other threads:[~2018-06-01 14:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-01 14:05 Tejaswi Tanikella [this message]
2018-06-01 14:45 ` [PATCH net] ipv4: igmp: hold wakelock to prevent delayed reports Florian Fainelli
2018-06-04 15:03 ` Tejaswi Tanikella
2018-06-04 15:06 ` David Miller
2018-06-06 14:38 ` Tejaswi Tanikella
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=20180601140532.GA13253@tejaswit-linux.qualcomm.com \
--to=tejaswit@codeaurora.org \
--cc=netdev@vger.kernel.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 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).