From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751313AbcBFBw6 (ORCPT ); Fri, 5 Feb 2016 20:52:58 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:52523 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750828AbcBFBw5 (ORCPT ); Fri, 5 Feb 2016 20:52:57 -0500 Date: Fri, 5 Feb 2016 17:56:35 -0800 From: Andrew Morton To: John Stultz Cc: Kees Cook , lkml , Ruchi Kandoi , Arjan van de Ven , Thomas Gleixner , Oren Laadan , Rom Lemarchand , Android Kernel Team Subject: Re: [PATCH] prctl: Add PR_SET_TIMERSLACK_PID for setting timer slack of an arbitrary thread. Message-Id: <20160205175635.25615b9b.akpm@linux-foundation.org> In-Reply-To: References: <1454695723-4393-1-git-send-email-john.stultz@linaro.org> <20160205121353.63d65c6b33a153bd9f863d8b@linux-foundation.org> <20160205123230.bd8bd228a0f3798a281266eb@linux-foundation.org> <20160205125008.15ccbdbe82afc3521a8ee381@linux-foundation.org> X-Mailer: Sylpheed 2.7.1 (GTK+ 2.18.9; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 5 Feb 2016 16:51:02 -0800 John Stultz wrote: > On Fri, Feb 5, 2016 at 2:35 PM, John Stultz wrote: > > On Fri, Feb 5, 2016 at 12:50 PM, Andrew Morton > > wrote: > >> On Fri, 5 Feb 2016 12:44:04 -0800 Kees Cook wrote: > >>> Could this be exposed as a writable /proc entry instead? Like the oom_* stuff? > >> > >> /proc//timer_slack_ns, guarded by ptrace_may_access(), documented > >> under Documentation/? Yup, that would work. It's there for all > >> architectures from day one and there is precedent. It's not as nice, > >> but /proc nasties will always be with us. > > > > Ok. I'll start working on that. > > Arjan/Thomas: One curious thing I noticed here while writing some > documentation. The timer_slack_ns value in the task struct is a > unsigned long. > > So this means PR_SET_TIMERSLACK limits the maximum slack on 32 bit > machines to ~4 seconds. Where on 64bit machines it can be quite a bit > longer (unreasonably long, really :). > > While 4 seconds is probably a reasonable interactivity limit, testing > w/ 10 second slack values on a VM showed those timers pushed back to > almost 10 seconds. So it may be useful to have > 4 second slack values > generally. Thus left alone this seems like an unfair disadvantage to > 32bit machines. > > We can't do too much about the PR_GET_TIMERSLACK/PR_SET_TIMERSLACK > interfaces, since its ABI and specifies a long, so one option there > would be to make sure the value specified is capped to UINT_MAX which > would keep the max value to ~4 seconds on all architectures. > > Alternatively, with the /proc/pid/timerslack_ns interface I'm working > on, we can make the backing storage a long long and support 64bits of > nanoseconds on all architectures. (But again, we can't really change > PR_SET/GET_TIMERSLACK, so 32bit systems might see strange values from > that with larger then uint slack values). > > Or I can just leave it as ULONG_MAX on all interfaces. > > Thoughts or preferences? /proc//timer_slack_us?