From patchwork Sat Dec 16 03:26:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 13495384 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2E30C4332F for ; Sat, 16 Dec 2023 03:27:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 780F66B0509; Fri, 15 Dec 2023 22:27:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 70A756B050A; Fri, 15 Dec 2023 22:27:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50E6B6B050B; Fri, 15 Dec 2023 22:27:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 39DA06B0509 for ; Fri, 15 Dec 2023 22:27:22 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0D8A5804ED for ; Sat, 16 Dec 2023 03:27:22 +0000 (UTC) X-FDA: 81571245924.17.B0C38E7 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) by imf25.hostedemail.com (Postfix) with ESMTP id 5DD28A0008 for ; Sat, 16 Dec 2023 03:27:20 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=WjeFrxkX; spf=pass (imf25.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.171 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702697240; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=l/AdYiLA1KltWXM4Dxc7KA8BrnvhZi0rzVoxoyzH4FI=; b=DpRfEvWy/aU2v4ZLM7zVEUpFju3h6dVLeags3LDQhUwF1jMDGvx41k5isaDlKt+EHvcjLO FiNwdzGZVLXX8oKiKSbAPuEmp1cdoK0D+Zi/wqyVf8Bm+5Itr9ZobwcZKLzsX4CgXp2BZW DlHHpLCAEcgYQU1XAMugajzHs+lQOrM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702697240; a=rsa-sha256; cv=none; b=LXeodSdj/y9jwZPDtSv329adtdeAP/M3EtDTxA9dWyfApB3bKiCikMISkZaPOljOqlO9IB ObA+7BAcyopEDVMyRWAWQtdXvL79R9Lm4TW8bH5dYtbb8y4RZryBCAJJ6hqGefkMauiq7n WZoN+wtFGYQZ9rGSoMDjRkr5dqorWRw= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=WjeFrxkX; spf=pass (imf25.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.171 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702697239; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l/AdYiLA1KltWXM4Dxc7KA8BrnvhZi0rzVoxoyzH4FI=; b=WjeFrxkXi1mg3nVsknIKn9D4C1XdNFTO0PyYeLNXygJ7fW9bGO8/r5DFvTSy/o7YAO3aDL CwryBhsCe7GWkRdm8opahT7ZQF/7VLDL592uUhZBpKntwuo8AOi4BQytpQ+Wtwy0Y1vswk QI4WciWS+qDGbdeKSjNd2uhUDmIkm/o= From: Kent Overstreet To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: Kent Overstreet , tglx@linutronix.de, x86@kernel.org, tj@kernel.org, peterz@infradead.org, mathieu.desnoyers@efficios.com, paulmck@kernel.org, keescook@chromium.org, dave.hansen@linux.intel.com, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com, brauner@kernel.org Subject: [PATCH 20/50] posix-cpu-timers: Split out posix-timers_types.h Date: Fri, 15 Dec 2023 22:26:19 -0500 Message-ID: <20231216032651.3553101-10-kent.overstreet@linux.dev> In-Reply-To: <20231216032651.3553101-1-kent.overstreet@linux.dev> References: <20231216024834.3510073-1-kent.overstreet@linux.dev> <20231216032651.3553101-1-kent.overstreet@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 5DD28A0008 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: t9k69aguewkwza33yjbyniubipkugb4b X-HE-Tag: 1702697240-104128 X-HE-Meta: U2FsdGVkX19G/vFWwJUsJwsq/t9WZQ9uuZstyO0w4dtMGSMF3psLBVV+iyi9LEMvT91wmbi5JCBFEUsvtyIj2tHkXQwz1cKBcAthspLFpWCaLfpYMMsjMmGmL5aXyODTXO44YqGXgBubRJ+r8MRExYMrDX8lUJCtRCVMwxfmplILr6lB5aanpni8zvLmqjaCTpCyhEuz3GfMF60pq2YJyogwy9Y81PKo2OmepHBqf90EaST+OP/0rcowXcq91oRVkjK70cjVhMi8OPlFPqv3rpBqfET75CYNHeAQQJFF7fwbgNQR1kBEQ2VgbWqMUaC63LXCCn3lICeUPBJMCMkbbsPEoFiSinxVkfcN9z6R9Bbi2Ts3oW8c3ZaACF9ev/AXh5VMp1FQIUQSDBdOqoaPzN2fguwX1knJziYDnKnvwGfqcPz1ssE3KpeTCMu6xKXfv9gDomqRqrqx0VrNaKrlaqYCJRHQBMlKWjQBFIJW2nFl4a3UC7rr6/juFvellutyTqJxvRYs7a7PbOY7iPE7ATkZupqdWnqnsw2FCBm/K8L2PJDT8FkjISes0EuTxvlMQMec1Lk50T8UefrFSXlTjokq/fUlsigG/07pQbR8+OfIRbTmNGa0TzF06mQfw4TFaH1l1Oa6cOn+W9h5JPndigoxbqcJeDHkS1mGXRNaIQanmEjEycOJNeUJLCs8kIKUrpcUWD41SFGrtnWY5VIMxJkbptaXfb3y0y/JsiyIt2xMtTGVYeI0vZ1LRuhIHT4uTfiDmDGAhZStrb2vu0UsyYV5OXRHKrNr5pxt9Ktj+hJJ3tab8jeO/p1t7T2hEgrOZSBAuIr6iVohj6u+MRxdwwXsbeV5ihuIlGeTI4QJ8vZ4C5m2gVKN4lR2HoI+tmF4NGgPmij33QIHQplxL1sE9vtMxq8cwFtf7L6KLkQAWS7htC656G4gEyfSioAxzq4Y3um5AratR6Ax7nsBXsA Wspp+AHz qASnZcI32UIkp1W/MthQVymNRFuLdLVQgBE+AkSpH5JO1VWoqMbrvNKnxce76UwUc5jzsCp8ytmN9Jx5h/H+Ue5jRB77VLUgi589Q6SbmVbOlI37Tqnlerzz9M6+vZ/siphOcGI5DVt7MhriFvkFHqjAZY+zNXxXWE8cye6q+BkYrlojGDvdPbPf/55guJKRFMfTkCvtls8Vjh/g= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Trimming down sched.h dependencies: we don't want to include more than the base types. Cc: Thomas Gleixner Signed-off-by: Kent Overstreet --- include/linux/posix-timers.h | 68 ++-------------------------- include/linux/posix-timers_types.h | 72 ++++++++++++++++++++++++++++++ include/linux/sched.h | 2 +- 3 files changed, 76 insertions(+), 66 deletions(-) create mode 100644 include/linux/posix-timers_types.h diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index d607f51404fc..750b0647258d 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -2,40 +2,16 @@ #ifndef _linux_POSIX_TIMERS_H #define _linux_POSIX_TIMERS_H -#include +#include #include #include -#include +#include +#include #include struct kernel_siginfo; struct task_struct; -/* - * Bit fields within a clockid: - * - * The most significant 29 bits hold either a pid or a file descriptor. - * - * Bit 2 indicates whether a cpu clock refers to a thread or a process. - * - * Bits 1 and 0 give the type: PROF=0, VIRT=1, SCHED=2, or FD=3. - * - * A clockid is invalid if bits 2, 1, and 0 are all set. - */ -#define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3)) -#define CPUCLOCK_PERTHREAD(clock) \ - (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0) - -#define CPUCLOCK_PERTHREAD_MASK 4 -#define CPUCLOCK_WHICH(clock) ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK) -#define CPUCLOCK_CLOCK_MASK 3 -#define CPUCLOCK_PROF 0 -#define CPUCLOCK_VIRT 1 -#define CPUCLOCK_SCHED 2 -#define CPUCLOCK_MAX 3 -#define CLOCKFD CPUCLOCK_MAX -#define CLOCKFD_MASK (CPUCLOCK_PERTHREAD_MASK|CPUCLOCK_CLOCK_MASK) - static inline clockid_t make_process_cpuclock(const unsigned int pid, const clockid_t clock) { @@ -109,44 +85,6 @@ static inline void cpu_timer_setexpires(struct cpu_timer *ctmr, u64 exp) ctmr->node.expires = exp; } -/** - * posix_cputimer_base - Container per posix CPU clock - * @nextevt: Earliest-expiration cache - * @tqhead: timerqueue head for cpu_timers - */ -struct posix_cputimer_base { - u64 nextevt; - struct timerqueue_head tqhead; -}; - -/** - * posix_cputimers - Container for posix CPU timer related data - * @bases: Base container for posix CPU clocks - * @timers_active: Timers are queued. - * @expiry_active: Timer expiry is active. Used for - * process wide timers to avoid multiple - * task trying to handle expiry concurrently - * - * Used in task_struct and signal_struct - */ -struct posix_cputimers { - struct posix_cputimer_base bases[CPUCLOCK_MAX]; - unsigned int timers_active; - unsigned int expiry_active; -}; - -/** - * posix_cputimers_work - Container for task work based posix CPU timer expiry - * @work: The task work to be scheduled - * @mutex: Mutex held around expiry in context of this task work - * @scheduled: @work has been scheduled already, no further processing - */ -struct posix_cputimers_work { - struct callback_head work; - struct mutex mutex; - unsigned int scheduled; -}; - static inline void posix_cputimers_init(struct posix_cputimers *pct) { memset(pct, 0, sizeof(*pct)); diff --git a/include/linux/posix-timers_types.h b/include/linux/posix-timers_types.h new file mode 100644 index 000000000000..57fec639a9bb --- /dev/null +++ b/include/linux/posix-timers_types.h @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _linux_POSIX_TIMERS_TYPES_H +#define _linux_POSIX_TIMERS_TYPES_H + +#include +#include +#include + +/* + * Bit fields within a clockid: + * + * The most significant 29 bits hold either a pid or a file descriptor. + * + * Bit 2 indicates whether a cpu clock refers to a thread or a process. + * + * Bits 1 and 0 give the type: PROF=0, VIRT=1, SCHED=2, or FD=3. + * + * A clockid is invalid if bits 2, 1, and 0 are all set. + */ +#define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3)) +#define CPUCLOCK_PERTHREAD(clock) \ + (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0) + +#define CPUCLOCK_PERTHREAD_MASK 4 +#define CPUCLOCK_WHICH(clock) ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK) +#define CPUCLOCK_CLOCK_MASK 3 +#define CPUCLOCK_PROF 0 +#define CPUCLOCK_VIRT 1 +#define CPUCLOCK_SCHED 2 +#define CPUCLOCK_MAX 3 +#define CLOCKFD CPUCLOCK_MAX +#define CLOCKFD_MASK (CPUCLOCK_PERTHREAD_MASK|CPUCLOCK_CLOCK_MASK) + +/** + * posix_cputimer_base - Container per posix CPU clock + * @nextevt: Earliest-expiration cache + * @tqhead: timerqueue head for cpu_timers + */ +struct posix_cputimer_base { + u64 nextevt; + struct timerqueue_head tqhead; +}; + +/** + * posix_cputimers - Container for posix CPU timer related data + * @bases: Base container for posix CPU clocks + * @timers_active: Timers are queued. + * @expiry_active: Timer expiry is active. Used for + * process wide timers to avoid multiple + * task trying to handle expiry concurrently + * + * Used in task_struct and signal_struct + */ +struct posix_cputimers { + struct posix_cputimer_base bases[CPUCLOCK_MAX]; + unsigned int timers_active; + unsigned int expiry_active; +}; + +/** + * posix_cputimers_work - Container for task work based posix CPU timer expiry + * @work: The task work to be scheduled + * @mutex: Mutex held around expiry in context of this task work + * @scheduled: @work has been scheduled already, no further processing + */ +struct posix_cputimers_work { + struct callback_head work; + struct mutex mutex; + unsigned int scheduled; +}; + +#endif /* _linux_POSIX_TIMERS_TYPES_H */ diff --git a/include/linux/sched.h b/include/linux/sched.h index e8892789969b..6d803d0904d9 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include