From patchwork Sat Jan 28 00:59:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 92741 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp498858qgi; Fri, 27 Jan 2017 16:59:38 -0800 (PST) X-Received: by 10.84.171.195 with SMTP id l61mr16104213plb.84.1485565178375; Fri, 27 Jan 2017 16:59:38 -0800 (PST) Return-Path: Received: from mail-pg0-x230.google.com (mail-pg0-x230.google.com. [2607:f8b0:400e:c05::230]) by mx.google.com with ESMTPS id z14si3150614pgo.209.2017.01.27.16.59.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jan 2017 16:59:38 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::230 as permitted sender) client-ip=2607:f8b0:400e:c05::230; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::230 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x230.google.com with SMTP id 194so85207640pgd.2 for ; Fri, 27 Jan 2017 16:59:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vyKeZ4D1I23GO0GOfUliR2ADQhdgZAToSx6UOVM93c4=; b=Bf+2uPFgLgMHi4Z/smT5N8t49bQ5HTJc6ghnoLDFqp49nNlYsfyj1XsAMBWXuI1P5d KI7elimBHc79hgZjKdSqxOBTduZU8H46hhUpI/4t2o55rxpK2y/T3/vfBgMxwZnUtq38 Sw/StC8lDueBJEqo4wCaySbeIZGvzwlu9wCPM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vyKeZ4D1I23GO0GOfUliR2ADQhdgZAToSx6UOVM93c4=; b=gFxrNOiS4fzJUj2buBicDG1aY+QU2MUZewXCKrVLqcJ1/jHaUAjY9oKQ5BYjm7yfbz kgQ3HT+ttjsRE60AWG92zGV0k7i0USxaUifn81qNLM0+CFssxEFXbdy6ftYiZhHNNfr1 YTIMnfvaR5QTOI2IzaJMui8uBjvXm54po3Bxd9APAnkkhy1uYSligv2wnh25AXjvSYd3 QXBS+nouQajodMta1sATGXYYNQRMs39NfurTh0+slhJBWxCVP7Qli49pvjD0mc20Ipxr /JGpy4qZ7M+k1ph8lf3FkMFrjqHHVs39nLxb5VIsVH9GQ06DXKCJkOI+yAuSxmpFTOfJ DPQQ== X-Gm-Message-State: AIkVDXIBt+CVEkd35Hkei/JgJSp4iV+nxBpCNDwD9YfP/AfPnmkImv+3pPR5q6XiIYfaIcE8DzM= X-Received: by 10.98.27.149 with SMTP id b143mr11985611pfb.5.1485565178014; Fri, 27 Jan 2017 16:59:38 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id l25sm14025441pfb.24.2017.01.27.16.59.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Jan 2017 16:59:37 -0800 (PST) From: John Stultz To: lkml Cc: Stephen Boyd , Thomas Gleixner , Richard Cochran , Prarit Bhargava , Ingo Molnar , John Stultz Subject: [PATCH 1/3] timekeeping: Remove unused timekeeping_{get, set}_tai_offset() Date: Fri, 27 Jan 2017 16:59:29 -0800 Message-Id: <1485565171-21223-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485565171-21223-1-git-send-email-john.stultz@linaro.org> References: <1485565171-21223-1-git-send-email-john.stultz@linaro.org> From: Stephen Boyd The last caller to timekeeping_set_tai_offset() was in commit 0b5154fb9040 (timekeeping: Simplify tai updating from do_adjtimex, 2013-03-22) and the last caller to timekeeping_get_tai_offset() was in commit 76f4108892d9 (hrtimer: Cleanup hrtimer accessors to the timekepeing state, 2014-07-16). Remove these unused functions now that we handle TAI offsets differently. Cc: Thomas Gleixner Cc: Richard Cochran Cc: Prarit Bhargava Cc: Ingo Molnar Signed-off-by: Stephen Boyd Signed-off-by: John Stultz --- kernel/time/timekeeping.c | 39 +-------------------------------------- kernel/time/timekeeping.h | 2 -- 2 files changed, 1 insertion(+), 40 deletions(-) -- 2.7.4 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index db087d7e1..95b258d 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1275,27 +1275,8 @@ int timekeeping_inject_offset(struct timespec *ts) } EXPORT_SYMBOL(timekeeping_inject_offset); - -/** - * timekeeping_get_tai_offset - Returns current TAI offset from UTC - * - */ -s32 timekeeping_get_tai_offset(void) -{ - struct timekeeper *tk = &tk_core.timekeeper; - unsigned int seq; - s32 ret; - - do { - seq = read_seqcount_begin(&tk_core.seq); - ret = tk->tai_offset; - } while (read_seqcount_retry(&tk_core.seq, seq)); - - return ret; -} - /** - * __timekeeping_set_tai_offset - Lock free worker function + * __timekeeping_set_tai_offset - Sets the TAI offset from UTC and monotonic * */ static void __timekeeping_set_tai_offset(struct timekeeper *tk, s32 tai_offset) @@ -1305,24 +1286,6 @@ static void __timekeeping_set_tai_offset(struct timekeeper *tk, s32 tai_offset) } /** - * timekeeping_set_tai_offset - Sets the current TAI offset from UTC - * - */ -void timekeeping_set_tai_offset(s32 tai_offset) -{ - struct timekeeper *tk = &tk_core.timekeeper; - unsigned long flags; - - raw_spin_lock_irqsave(&timekeeper_lock, flags); - write_seqcount_begin(&tk_core.seq); - __timekeeping_set_tai_offset(tk, tai_offset); - timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); - write_seqcount_end(&tk_core.seq); - raw_spin_unlock_irqrestore(&timekeeper_lock, flags); - clock_was_set(); -} - -/** * change_clocksource - Swaps clocksources if a new one is available * * Accumulates current time interval and initializes new clocksource diff --git a/kernel/time/timekeeping.h b/kernel/time/timekeeping.h index 704f595..d091467 100644 --- a/kernel/time/timekeeping.h +++ b/kernel/time/timekeeping.h @@ -11,8 +11,6 @@ extern ktime_t ktime_get_update_offsets_now(unsigned int *cwsseq, extern int timekeeping_valid_for_hres(void); extern u64 timekeeping_max_deferment(void); extern int timekeeping_inject_offset(struct timespec *ts); -extern s32 timekeeping_get_tai_offset(void); -extern void timekeeping_set_tai_offset(s32 tai_offset); extern int timekeeping_suspend(void); extern void timekeeping_resume(void); From patchwork Sat Jan 28 00:59:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 92742 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp498860qgi; Fri, 27 Jan 2017 16:59:39 -0800 (PST) X-Received: by 10.99.101.199 with SMTP id z190mr12096722pgb.219.1485565179337; Fri, 27 Jan 2017 16:59:39 -0800 (PST) Return-Path: Received: from mail-pg0-x22b.google.com (mail-pg0-x22b.google.com. [2607:f8b0:400e:c05::22b]) by mx.google.com with ESMTPS id 35si3144734pgx.238.2017.01.27.16.59.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jan 2017 16:59:39 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22b as permitted sender) client-ip=2607:f8b0:400e:c05::22b; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22b as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x22b.google.com with SMTP id 204so85353673pge.0 for ; Fri, 27 Jan 2017 16:59:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wwu3mZYr/RVdPOpHEPwOoGrFvM/OfyLATa9ThbM1wzk=; b=ECjgoDPhkkSRosXn0TFzhuokgsMhOfJOz6zknFhPQmEkiqVejvOBqruUpJmWjpr73B J+3qdpOBnKpkip5r2Bf71MLbFGny8D38xXQwpFpbK7hhfYptxnRW0ipzLrczQxqDSIKQ 4SZQhcweF599HUExAtUufS9jBgR3SH0G3WgXc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wwu3mZYr/RVdPOpHEPwOoGrFvM/OfyLATa9ThbM1wzk=; b=J9dwgzeoeS1DT1WIZzPPjIzlDcVuDDk2gbjob4PESlnqjcirZM5BPQDtKwZKJcqEOS +O7c96RHBpkM6mY6eAK/nTrMnO/S3Difb7Syyb57uMAda1sQGH9EObClFfQ+xNLcOri5 YAw6HPdGaudxPxRMnefENS9YbQRccB4U0n1NRfqJ8IUqjxIlhcpSghMLElzoAyZtHrTq J7VU1wd+tU18G0gQrsRABEqyrUDZIPYyxULSnWJmGyDo2gvzvFw7jLeiqXgVbC1HJT+Y fqa5FbwhcUsM6SXhsCo6FO5SvZppKhEvifNfFtJpyRHG9ClzMmLeIL4nPq8s/zeEwRDD 0Gbw== X-Gm-Message-State: AIkVDXLUPdbgpCR1TVGcHZT09D7L5SQymT1gpYVMBKPGV7woe36QlnP+t711lPrq18kC6WsU4k4= X-Received: by 10.98.133.11 with SMTP id u11mr12065168pfd.132.1485565179029; Fri, 27 Jan 2017 16:59:39 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id l25sm14025441pfb.24.2017.01.27.16.59.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Jan 2017 16:59:38 -0800 (PST) From: John Stultz To: lkml Cc: Russell King , David Riley , Thomas Gleixner , Richard Cochran , Prarit Bhargava , Ingo Molnar , John Stultz Subject: [PATCH 2/3] delay: Add explanation of udelay() inaccuracy Date: Fri, 27 Jan 2017 16:59:30 -0800 Message-Id: <1485565171-21223-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485565171-21223-1-git-send-email-john.stultz@linaro.org> References: <1485565171-21223-1-git-send-email-john.stultz@linaro.org> From: Russell King There seems to be some misunderstanding that udelay() and friends will always guarantee the specified delay. This is a false understanding. When udelay() is based on CPU cycles, it can return early for many reasons which are detailed by Linus' reply to me in a thread in 2011: http://lists.openwall.net/linux-kernel/2011/01/12/372 However, a udelay test module was created in 2014 which allows udelay() to only be 0.5% fast, which is outside of the CPU-cycles udelay() results I measured back in 2011, which were deemed to be in the "we don't care" region. test_udelay() should be fixed to reflect the real allowable tolerance on udelay(), rather than 0.5%. Cc: David Riley Cc: Thomas Gleixner Cc: Richard Cochran Cc: Prarit Bhargava Cc: Ingo Molnar Signed-off-by: Russell King Signed-off-by: John Stultz --- include/linux/delay.h | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.7.4 diff --git a/include/linux/delay.h b/include/linux/delay.h index a6ecb34..2ecb3c4 100644 --- a/include/linux/delay.h +++ b/include/linux/delay.h @@ -5,6 +5,17 @@ * Copyright (C) 1993 Linus Torvalds * * Delay routines, using a pre-computed "loops_per_jiffy" value. + * + * Please note that ndelay(), udelay() and mdelay() may return early for + * several reasons: + * 1. computed loops_per_jiffy too low (due to the time taken to + * execute the timer interrupt.) + * 2. cache behaviour affecting the time it takes to execute the + * loop function. + * 3. CPU clock rate changes. + * + * Please see this thread: + * http://lists.openwall.net/linux-kernel/2011/01/09/56 */ #include From patchwork Sat Jan 28 00:59:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 92743 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp498862qgi; Fri, 27 Jan 2017 16:59:40 -0800 (PST) X-Received: by 10.84.216.91 with SMTP id f27mr16095906plj.92.1485565180357; Fri, 27 Jan 2017 16:59:40 -0800 (PST) Return-Path: Received: from mail-pg0-x22b.google.com (mail-pg0-x22b.google.com. [2607:f8b0:400e:c05::22b]) by mx.google.com with ESMTPS id i1si5915615pfb.292.2017.01.27.16.59.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jan 2017 16:59:40 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22b as permitted sender) client-ip=2607:f8b0:400e:c05::22b; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22b as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x22b.google.com with SMTP id 204so85353765pge.0 for ; Fri, 27 Jan 2017 16:59:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wcpF5wYq/biLkdgah8ljAh3whGa5E31MRfuI1Gb5gQ0=; b=AfdEZmfcZujdbufRyF0mgPqNgqtLQejk965/elJLnJma+tXvFj6U50dEGXgPkhRTGi c7ZtrxhjMvxEqEVQAHWZKTHISs7OAeQIoUAQjt9inwPrqVxxQg3hg4YGUpuEAH5Kvp2u HZz3MtumCbBlKe/EzlfAiV7sK7FqpzOFzq2ck= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wcpF5wYq/biLkdgah8ljAh3whGa5E31MRfuI1Gb5gQ0=; b=KoaXEfMI/ESMMsgONUZw+++VoHjDRMTCfQPQSlNNIgDxoLYvb6l/30zZdvmHPrSDoA Q5qfyeA+Y7hZJTM4sF+AEE7nWxNmTMPgtEao/qsCtQU+gvHJlFEAKw/b5MQ31ewUVyFq n+PzNbvrZQm8b1A08q0L8EIcrsiRBWkoAx4E2yxCIau/rumBA+PvZZ5M53J8FxXIdBNm MM7OKHZYnbGg8ySnjizg2LcU0vU29wGhotZ7Tll6wLJKlBOQMhht2Pcq3f1MBFMdUW0s d5Uh7A9wJQbJFUEJ6OXbsMO6jCYS9SuVWSPc+M7vLd0zJnoXYr8Rbi+cnzEf7cWeDtDC juZQ== X-Gm-Message-State: AIkVDXKqk9YJDNQM5CS5K98jPaDPO0c3t/kiwntw/pCZyWdjoyn/xXBChgh/zwSCY2h+AV8HPtU= X-Received: by 10.98.35.207 with SMTP id q76mr11919974pfj.112.1485565180001; Fri, 27 Jan 2017 16:59:40 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id l25sm14025441pfb.24.2017.01.27.16.59.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Jan 2017 16:59:39 -0800 (PST) From: John Stultz To: lkml Cc: Nicolas Pitre , Thomas Gleixner , Richard Cochran , Prarit Bhargava , Ingo Molnar , Nicolas Pitre , John Stultz Subject: [PATCH 3/3] timers: Omit POSIX timer stuff from task_struct when disabled Date: Fri, 27 Jan 2017 16:59:31 -0800 Message-Id: <1485565171-21223-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485565171-21223-1-git-send-email-john.stultz@linaro.org> References: <1485565171-21223-1-git-send-email-john.stultz@linaro.org> From: Nicolas Pitre When CONFIG_POSIX_TIMERS is disabled, it is preferable to remove related structures from struct task_struct and struct signal_struct as they won't contain anything useful and shouldn't be relied upon by mistake. Code still referencing those structures is also disabled here. Cc: Thomas Gleixner Cc: Richard Cochran Cc: Prarit Bhargava Cc: Ingo Molnar Signed-off-by: Nicolas Pitre Signed-off-by: John Stultz --- fs/proc/base.c | 4 ++-- include/linux/init_task.h | 40 +++++++++++++++++++++++++--------------- include/linux/sched.h | 13 ++++++++++--- kernel/fork.c | 10 +++++++++- kernel/sched/rt.c | 4 ++++ kernel/sched/stats.h | 32 ++++++++++++++++++++------------ 6 files changed, 70 insertions(+), 33 deletions(-) -- 2.7.4 diff --git a/fs/proc/base.c b/fs/proc/base.c index 8e7e61b..03deeac 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2179,7 +2179,7 @@ static const struct file_operations proc_map_files_operations = { .llseek = generic_file_llseek, }; -#ifdef CONFIG_CHECKPOINT_RESTORE +#if defined(CONFIG_CHECKPOINT_RESTORE) && defined(CONFIG_POSIX_TIMERS) struct timers_private { struct pid *pid; struct task_struct *task; @@ -2936,7 +2936,7 @@ static const struct pid_entry tgid_base_stuff[] = { REG("projid_map", S_IRUGO|S_IWUSR, proc_projid_map_operations), REG("setgroups", S_IRUGO|S_IWUSR, proc_setgroups_operations), #endif -#ifdef CONFIG_CHECKPOINT_RESTORE +#if defined(CONFIG_CHECKPOINT_RESTORE) && defined(CONFIG_POSIX_TIMERS) REG("timers", S_IRUGO, proc_timers_operations), #endif REG("timerslack_ns", S_IRUGO|S_IWUGO, proc_pid_set_timerslack_ns_operations), diff --git a/include/linux/init_task.h b/include/linux/init_task.h index 325f649..3a85d61 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h @@ -42,6 +42,27 @@ extern struct fs_struct init_fs; #define INIT_PREV_CPUTIME(x) #endif +#ifdef CONFIG_POSIX_TIMERS +#define INIT_POSIX_TIMERS(s) \ + .posix_timers = LIST_HEAD_INIT(s.posix_timers), +#define INIT_CPU_TIMERS(s) \ + .cpu_timers = { \ + LIST_HEAD_INIT(s.cpu_timers[0]), \ + LIST_HEAD_INIT(s.cpu_timers[1]), \ + LIST_HEAD_INIT(s.cpu_timers[2]), \ + }, +#define INIT_CPUTIMER(s) \ + .cputimer = { \ + .cputime_atomic = INIT_CPUTIME_ATOMIC, \ + .running = false, \ + .checking_timer = false, \ + }, +#else +#define INIT_POSIX_TIMERS(s) +#define INIT_CPU_TIMERS(s) +#define INIT_CPUTIMER(s) +#endif + #define INIT_SIGNALS(sig) { \ .nr_threads = 1, \ .thread_head = LIST_HEAD_INIT(init_task.thread_node), \ @@ -49,14 +70,10 @@ extern struct fs_struct init_fs; .shared_pending = { \ .list = LIST_HEAD_INIT(sig.shared_pending.list), \ .signal = {{0}}}, \ - .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \ - .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \ + INIT_POSIX_TIMERS(sig) \ + INIT_CPU_TIMERS(sig) \ .rlim = INIT_RLIMITS, \ - .cputimer = { \ - .cputime_atomic = INIT_CPUTIME_ATOMIC, \ - .running = false, \ - .checking_timer = false, \ - }, \ + INIT_CPUTIMER(sig) \ INIT_PREV_CPUTIME(sig) \ .cred_guard_mutex = \ __MUTEX_INITIALIZER(sig.cred_guard_mutex), \ @@ -247,7 +264,7 @@ extern struct task_group root_task_group; .blocked = {{0}}, \ .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \ .journal_info = NULL, \ - .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ + INIT_CPU_TIMERS(tsk) \ .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock), \ .timer_slack_ns = 50000, /* 50 usec default slack */ \ .pids = { \ @@ -274,13 +291,6 @@ extern struct task_group root_task_group; } -#define INIT_CPU_TIMERS(cpu_timers) \ -{ \ - LIST_HEAD_INIT(cpu_timers[0]), \ - LIST_HEAD_INIT(cpu_timers[1]), \ - LIST_HEAD_INIT(cpu_timers[2]), \ -} - /* Attach to the init_task data structure for proper alignment */ #define __init_task_data __attribute__((__section__(".data..init_task"))) diff --git a/include/linux/sched.h b/include/linux/sched.h index 4d19052..e8f6af5 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -734,13 +734,14 @@ struct signal_struct { unsigned int is_child_subreaper:1; unsigned int has_child_subreaper:1; +#ifdef CONFIG_POSIX_TIMERS + /* POSIX.1b Interval Timers */ int posix_timer_id; struct list_head posix_timers; /* ITIMER_REAL timer for the process */ struct hrtimer real_timer; - struct pid *leader_pid; ktime_t it_real_incr; /* @@ -759,12 +760,16 @@ struct signal_struct { /* Earliest-expiration cache. */ struct task_cputime cputime_expires; + struct list_head cpu_timers[3]; + +#endif + + struct pid *leader_pid; + #ifdef CONFIG_NO_HZ_FULL atomic_t tick_dep_mask; #endif - struct list_head cpu_timers[3]; - struct pid *tty_old_pgrp; /* boolean value for session group leader */ @@ -1681,8 +1686,10 @@ struct task_struct { /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */ unsigned long min_flt, maj_flt; +#ifdef CONFIG_POSIX_TIMERS struct task_cputime cputime_expires; struct list_head cpu_timers[3]; +#endif /* process credentials */ const struct cred __rcu *ptracer_cred; /* Tracer's credentials at attach */ diff --git a/kernel/fork.c b/kernel/fork.c index 11c5c8a..105c667 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1304,6 +1304,7 @@ void __cleanup_sighand(struct sighand_struct *sighand) } } +#ifdef CONFIG_POSIX_TIMERS /* * Initialize POSIX timer handling for a thread group. */ @@ -1322,6 +1323,9 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig) INIT_LIST_HEAD(&sig->cpu_timers[1]); INIT_LIST_HEAD(&sig->cpu_timers[2]); } +#else +static inline void posix_cpu_timers_init_group(struct signal_struct *sig) { } +#endif static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) { @@ -1346,11 +1350,11 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) init_waitqueue_head(&sig->wait_chldexit); sig->curr_target = tsk; init_sigpending(&sig->shared_pending); - INIT_LIST_HEAD(&sig->posix_timers); seqlock_init(&sig->stats_lock); prev_cputime_init(&sig->prev_cputime); #ifdef CONFIG_POSIX_TIMERS + INIT_LIST_HEAD(&sig->posix_timers); hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); sig->real_timer.function = it_real_fn; #endif @@ -1425,6 +1429,7 @@ static void rt_mutex_init_task(struct task_struct *p) #endif } +#ifdef CONFIG_POSIX_TIMERS /* * Initialize POSIX timer handling for a single task. */ @@ -1437,6 +1442,9 @@ static void posix_cpu_timers_init(struct task_struct *tsk) INIT_LIST_HEAD(&tsk->cpu_timers[1]); INIT_LIST_HEAD(&tsk->cpu_timers[2]); } +#else +static inline void posix_cpu_timers_init(struct task_struct *tsk) { } +#endif static inline void init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 2516b8d..a688a82 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -2246,6 +2246,7 @@ prio_changed_rt(struct rq *rq, struct task_struct *p, int oldprio) } } +#ifdef CONFIG_POSIX_TIMERS static void watchdog(struct rq *rq, struct task_struct *p) { unsigned long soft, hard; @@ -2267,6 +2268,9 @@ static void watchdog(struct rq *rq, struct task_struct *p) p->cputime_expires.sched_exp = p->se.sum_exec_runtime; } } +#else +static inline void watchdog(struct rq *rq, struct task_struct *p) { } +#endif static void task_tick_rt(struct rq *rq, struct task_struct *p, int queued) { diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h index 34659a8..c69a987 100644 --- a/kernel/sched/stats.h +++ b/kernel/sched/stats.h @@ -172,18 +172,19 @@ sched_info_switch(struct rq *rq, */ /** - * cputimer_running - return true if cputimer is running + * get_running_cputimer - return &tsk->signal->cputimer if cputimer is running * * @tsk: Pointer to target task. */ -static inline bool cputimer_running(struct task_struct *tsk) - +#ifdef CONFIG_POSIX_TIMERS +static inline +struct thread_group_cputimer *get_running_cputimer(struct task_struct *tsk) { struct thread_group_cputimer *cputimer = &tsk->signal->cputimer; /* Check if cputimer isn't running. This is accessed without locking. */ if (!READ_ONCE(cputimer->running)) - return false; + return NULL; /* * After we flush the task's sum_exec_runtime to sig->sum_sched_runtime @@ -200,10 +201,17 @@ static inline bool cputimer_running(struct task_struct *tsk) * clock delta is behind the expiring timer value. */ if (unlikely(!tsk->sighand)) - return false; + return NULL; - return true; + return cputimer; +} +#else +static inline +struct thread_group_cputimer *get_running_cputimer(struct task_struct *tsk) +{ + return NULL; } +#endif /** * account_group_user_time - Maintain utime for a thread group. @@ -218,9 +226,9 @@ static inline bool cputimer_running(struct task_struct *tsk) static inline void account_group_user_time(struct task_struct *tsk, cputime_t cputime) { - struct thread_group_cputimer *cputimer = &tsk->signal->cputimer; + struct thread_group_cputimer *cputimer = get_running_cputimer(tsk); - if (!cputimer_running(tsk)) + if (!cputimer) return; atomic64_add(cputime, &cputimer->cputime_atomic.utime); @@ -239,9 +247,9 @@ static inline void account_group_user_time(struct task_struct *tsk, static inline void account_group_system_time(struct task_struct *tsk, cputime_t cputime) { - struct thread_group_cputimer *cputimer = &tsk->signal->cputimer; + struct thread_group_cputimer *cputimer = get_running_cputimer(tsk); - if (!cputimer_running(tsk)) + if (!cputimer) return; atomic64_add(cputime, &cputimer->cputime_atomic.stime); @@ -260,9 +268,9 @@ static inline void account_group_system_time(struct task_struct *tsk, static inline void account_group_exec_runtime(struct task_struct *tsk, unsigned long long ns) { - struct thread_group_cputimer *cputimer = &tsk->signal->cputimer; + struct thread_group_cputimer *cputimer = get_running_cputimer(tsk); - if (!cputimer_running(tsk)) + if (!cputimer) return; atomic64_add(ns, &cputimer->cputime_atomic.sum_exec_runtime);