mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Prakash Sangappa <prakash.sangappa@oracle.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Manfred Spraul <manfred@colorfullife.com>
Subject: Re: [PATCH] ipc: Update semtimedop() to use hrtimer
Date: Mon, 25 Apr 2022 13:50:53 -0700	[thread overview]
Message-ID: <20220425135053.a74082b68d26f4f3f0344500@linux-foundation.org> (raw)
In-Reply-To: <8603345D-9AAD-43FF-B1DF-941BDA799DF5@oracle.com>

On Mon, 25 Apr 2022 19:38:44 +0000 Prakash Sangappa <prakash.sangappa@oracle.com> wrote:

> 
> 
> > On Apr 18, 2022, at 6:51 PM, Prakash Sangappa <prakash.sangappa@oracle.com> wrote:
> > 
> > semtimedop() should be converted to use hrtimer like it has been
> > done for most of the system calls with timeouts. This system call
> > already takes a struct timespec as an argument and can therefore
> > provide finer granularity timed wait.
> > 
> > Signed-off-by: Prakash Sangappa <prakash.sangappa@oracle.com>
> 
> Can I get a review of this patch?

That would be nice.

I looked at it, seemed OK.  Perhaps the usual IPC developers (Davidlohr
and Manfred) can comment?

> Note this patch has been added to Andrew's mm tree.
> 
> 
> > ---
> > ipc/sem.c | 15 +++++++++++----
> > 1 file changed, 11 insertions(+), 4 deletions(-)
> > 
> > diff --git a/ipc/sem.c b/ipc/sem.c
> > index 0dbdb98..6cd1a1b8 100644
> > --- a/ipc/sem.c
> > +++ b/ipc/sem.c
> > @@ -1995,7 +1995,10 @@ long __do_semtimedop(int semid, struct sembuf *sops,
> > 	int max, locknum;
> > 	bool undos = false, alter = false, dupsop = false;
> > 	struct sem_queue queue;
> > -	unsigned long dup = 0, jiffies_left = 0;
> > +	unsigned long dup = 0;
> > +	ktime_t expires;
> > +	int timed_out = 0;
> > +	struct timespec64 end_time;
> > 
> > 	if (nsops < 1 || semid < 0)
> > 		return -EINVAL;
> > @@ -2008,7 +2011,9 @@ long __do_semtimedop(int semid, struct sembuf *sops,
> > 			error = -EINVAL;
> > 			goto out;
> > 		}
> > -		jiffies_left = timespec64_to_jiffies(timeout);
> > +		ktime_get_ts64(&end_time);
> > +		end_time = timespec64_add_safe(end_time, *timeout);
> > +		expires = timespec64_to_ktime(end_time);
> > 	}
> > 
> > 
> > @@ -2167,7 +2172,9 @@ long __do_semtimedop(int semid, struct sembuf *sops,
> > 		rcu_read_unlock();
> > 
> > 		if (timeout)
> > -			jiffies_left = schedule_timeout(jiffies_left);
> > +			timed_out = !schedule_hrtimeout_range(&expires,
> > +						current->timer_slack_ns,
> > +						HRTIMER_MODE_ABS);
> > 		else
> > 			schedule();
> > 
> > @@ -2210,7 +2217,7 @@ long __do_semtimedop(int semid, struct sembuf *sops,
> > 		/*
> > 		 * If an interrupt occurred we have to clean up the queue.
> > 		 */
> > -		if (timeout && jiffies_left == 0)
> > +		if (timeout && timed_out)
> > 			error = -EAGAIN;
> > 	} while (error == -EINTR && !signal_pending(current)); /* spurious */
> > 
> > -- 
> > 2.7.4
> > 
> 

  reply	other threads:[~2022-04-25 20:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-19  1:51 Prakash Sangappa
2022-04-25 19:38 ` Prakash Sangappa
2022-04-25 20:50   ` Andrew Morton [this message]
2022-04-27 22:06 ` Thomas Gleixner
2022-04-27 23:42   ` Prakash Sangappa
2022-04-28  7:47     ` Thomas Gleixner

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=20220425135053.a74082b68d26f4f3f0344500@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dave@stgolabs.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    --cc=peterz@infradead.org \
    --cc=prakash.sangappa@oracle.com \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®