Message ID | 1503081850-10671-2-git-send-email-vallish@amazon.com |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
On Fri, Aug 18, 2017 at 11:44 AM, Vallish Vaidyeshwara <vallish@amazon.com> wrote: > - *timeo_p = schedule_timeout(*timeo_p); > + /* Wait using highres timer */ > + expires = ktime_add_ns(ktime_get(), jiffies_to_nsecs(*timeo_p)); > + pre_sched_time = jiffies; > + if (schedule_hrtimeout(&expires, HRTIMER_MODE_ABS)) Does this work with MAX_SCHEDULE_TIMEOUT too??
On Mon, Aug 21, 2017 at 01:10:34PM -0700, Cong Wang wrote: > On Fri, Aug 18, 2017 at 11:44 AM, Vallish Vaidyeshwara > <vallish@amazon.com> wrote: > > - *timeo_p = schedule_timeout(*timeo_p); > > + /* Wait using highres timer */ > > + expires = ktime_add_ns(ktime_get(), jiffies_to_nsecs(*timeo_p)); > > + pre_sched_time = jiffies; > > + if (schedule_hrtimeout(&expires, HRTIMER_MODE_ABS)) > Hello Cong, > Does this work with MAX_SCHEDULE_TIMEOUT too?? > Thanks for pointing out MAX_SCHEDULE_TIMEOUT. I have made minor change to accommodate MAX_SCHEDULE_TIMEOUT and will send out next version of the patch for review. Thanks. -Vallish
diff --git a/net/core/datagram.c b/net/core/datagram.c index ee5647b..c89a104 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c @@ -80,6 +80,7 @@ static int receiver_wake_function(wait_queue_entry_t *wait, unsigned int mode, i return 0; return autoremove_wake_function(wait, mode, sync, key); } + /* * Wait for the last received packet to be different from skb */ @@ -87,6 +88,8 @@ int __skb_wait_for_more_packets(struct sock *sk, int *err, long *timeo_p, const struct sk_buff *skb) { int error; + ktime_t expires; + unsigned long pre_sched_time; DEFINE_WAIT_FUNC(wait, receiver_wake_function); prepare_to_wait_exclusive(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); @@ -116,7 +119,13 @@ int __skb_wait_for_more_packets(struct sock *sk, int *err, long *timeo_p, goto interrupted; error = 0; - *timeo_p = schedule_timeout(*timeo_p); + /* Wait using highres timer */ + expires = ktime_add_ns(ktime_get(), jiffies_to_nsecs(*timeo_p)); + pre_sched_time = jiffies; + if (schedule_hrtimeout(&expires, HRTIMER_MODE_ABS)) + *timeo_p = jiffies - pre_sched_time; + else + *timeo_p = 0; out: finish_wait(sk_sleep(sk), &wait); return error;