public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: John Stultz <john.stultz@linaro.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Ruchi Kandoi <kandoiruchi@google.com>,
	Arjan van de Ven <arjan@linux.intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Oren Laadan <orenl@cellrox.com>,
	Rom Lemarchand <romlem@android.com>,
	Kees Cook <keescook@chromium.org>,
	Android Kernel Team <kernel-team@android.com>
Subject: Re: [PATCH] prctl: Add PR_SET_TIMERSLACK_PID for setting timer slack of an arbitrary thread.
Date: Fri, 5 Feb 2016 12:13:53 -0800	[thread overview]
Message-ID: <20160205121353.63d65c6b33a153bd9f863d8b@linux-foundation.org> (raw)
In-Reply-To: <1454695723-4393-1-git-send-email-john.stultz@linaro.org>

On Fri,  5 Feb 2016 10:08:43 -0800 John Stultz <john.stultz@linaro.org> wrote:

> From: Ruchi Kandoi <kandoiruchi@google.com>
> 
> This allows power/performance management software to set timer
> slack for other threads according to its policy for the thread
> (such as when the thread is designated foreground vs. background
> activity)
> 
> Second argument is similar to PR_SET_TIMERSLACK, if non-zero
> then the slack is set to that value otherwise sets it to the
> default for the thread.
> 
> Takes PID of the thread as the third argument.
> 
> This interface checks that the calling task has permissions to
> to use PTRACE_MODE_ATTACH on the target task, so that we can
> ensure arbitrary apps do not change the timer slack for other
> apps.
> 
> Additional fixes from Ruchi and Micha Kalfon <micha@cellrox.com>
> have been folded into this patch to make it easier to reivew.
> 
> ...
>
> @@ -2218,6 +2222,27 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
>  	case PR_GET_TID_ADDRESS:
>  		error = prctl_get_tid_address(me, (int __user **)arg2);
>  		break;
> +	case PR_SET_TIMERSLACK_PID:
> +		rcu_read_lock();
> +		tsk = find_task_by_vpid((pid_t)arg3);

hm, as far as I can tell this is the first instance in which prctl() is
used to play with a task other than "current".  Maybe this isn't a good
precedent.

If you look at all the other diddle-other-task functions in
kernel/sys.c, you'll see that they are standalone syscalls.  What
you've done here is just a bit lazy: added what is effectively a new
standalone syscall, only it has been hidden within the prctl() switch
statement.

I don't see a practical problem with this - we could have implemented
all those other syscalls as prctl submodes as well.  But we didn't...

IOW, it would be more consistent to add sys_set_timer_slack()?

  parent reply	other threads:[~2016-02-05 20:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-05 18:08 [PATCH] prctl: Add PR_SET_TIMERSLACK_PID for setting timer slack of an arbitrary thread John Stultz
2016-02-05 20:10 ` Kees Cook
2016-02-05 20:18   ` John Stultz
2016-02-05 20:13 ` Andrew Morton [this message]
2016-02-05 20:23   ` John Stultz
2016-02-05 20:32     ` Andrew Morton
2016-02-05 20:39       ` John Stultz
2016-02-05 20:44         ` Kees Cook
2016-02-05 20:50           ` Andrew Morton
2016-02-05 22:35             ` John Stultz
2016-02-06  0:51               ` John Stultz
2016-02-06  1:56                 ` Andrew Morton
2016-02-06  2:41                   ` John Stultz
2016-02-06  2:15                 ` Arjan van de Ven
2016-02-06  2:50                   ` John Stultz
2016-02-06  2:54                     ` Arjan van de Ven

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=20160205121353.63d65c6b33a153bd9f863d8b@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=arjan@linux.intel.com \
    --cc=john.stultz@linaro.org \
    --cc=kandoiruchi@google.com \
    --cc=keescook@chromium.org \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=orenl@cellrox.com \
    --cc=romlem@android.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