Files
kernel/kernel-std/centos/patches/affine-compute-kernel-threads.patch
Dongqi Chen d27f1ee36e Linux std kernel upgrade to align with CentOS 8
(cherry picked from commit 9111cf409030d92d1ed0d48b00d6ad64f4399bc4)
(re-submit of patch: https://review.opendev.org/#/c/710919/
 starlingx/integ into starlingx/kernel)

The std kernel is upgraded from centos7.6 to centos8
and is divided into two parts:

1.kernel patches
After analysis of the code and patch,
there are nine patches on centos7.6 to update to centos8.
Detailed patch analysis can be found at
https://github.com/StarlingX-Neusoft/Centos8/blob/master/
Kernel_Upgrade_to_4.18-CentOS8_Analysis.xlsx documentation
[STX Kernel-std Patches Details] sheet.

The remaining patches are as follows:
Patch40002: Notification-of-death-of-arbitrary-processes.patch
Patch40004: PCI-Add-ACS-quirk-for-Intel-Fortville-NICs.patch
Patch40005: affine-compute-kernel-threads.patch
Patch40006: Affine-irqs-and-workqueues-with-kthread_cpus.patch
Patch40007: Make-kernel-start-eth-devices-at-offset.patch
Patch40008: intel-iommu-allow-ignoring-Ethernet-device-RMRR-with.patch
Patch40022: US101216-IMA-support-in-Titanium-kernel.patch
Patch40023: US103091-IMA-System-Configuration.patch
Patch40026: turn-off-write-same-in-smartqpi-driver.patch

2.kernel config
Currently, We use the STX version of the kernel config
unmodified from what we used for CentOS 7.6.

3. The -j "% (nproc)" parameter was not added to
lines 1496 and 1499 of the original spec file,
because this parameter causes compilation errors.
pushd tools/iio/
%{make}
popd
pushd tools/gpio/
%{make}
popd

The above patches and config can be successfully built
in the build container centos8.

Change-Id: Ic75feda21eee0530a430658b3368fbdf47767e36
Story: 2006728
Task: 37150
Depends-On: https://review.opendev.org/710907
Signed-off-by: Zhang Zhiguo <zhangzhg@neusoft.com>
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
Signed-off-by: Dongqi Chen <chen.dq@neusoft.com>
2020-05-01 12:40:10 +00:00

172 lines
6.8 KiB
Diff

From 6b6edb5a389c03e208e6a123a7807af66283237d Mon Sep 17 00:00:00 2001
Message-Id: <6b6edb5a389c03e208e6a123a7807af66283237d.1527544850.git.Jim.Somerville@windriver.com>
In-Reply-To: <b6ceef1c915827b50ce3f76da4dc47f3eb768b44.1527544850.git.Jim.Somerville@windriver.com>
References: <b6ceef1c915827b50ce3f76da4dc47f3eb768b44.1527544850.git.Jim.Somerville@windriver.com>
From: Chris Friesen <chris.friesen@windriver.com>
Date: Tue, 24 Nov 2015 16:27:28 -0500
Subject: [PATCH 05/26] affine compute kernel threads
This is a kernel enhancement to configure the cpu affinity of kernel
threads via kernel boot option kthread_cpus=<cpulist>. The compute
kickstart file and compute-huge.sh scripts will update grub with the
new option.
With kthread_cpus specified, the cpumask is immediately applied upon
thread launch. This does not affect kernel threads that specify cpu
and node.
Note: this is based off of Christoph Lameter's patch at
https://lwn.net/Articles/565932/ with the only difference being
the kernel parameter changed from kthread to kthread_cpus.
Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Chris Friesen <chris.friesen@windriver.com>
[VT: The existing "isolcpus"
kernel bootarg, cgroup/cpuset, and taskset might provide the some
way to have cpu isolation. However none of them satisfies the requirements.
Replacing spaces with tabs. Combine two calls of set_cpus_allowed_ptr()
in kernel_init_freeable() in init/main.c into one. Performed tests]
Signed-off-by: Vu Tran <vu.tran@windriver.com>
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Zhang Zhiguo <zhangzhg@neusoft.com>
---
Documentation/admin-guide/kernel-parameters.txt | 9 +++++++++
include/linux/cpumask.h | 3 +++
init/main.c | 2 ++
kernel/cpu.c | 14 ++++++++++++++
kernel/kthread.c | 4 ++--
kernel/umh.c | 3 +++
6 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 3ff6f8d..2f4a7ad 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1944,6 +1944,15 @@
Default: on
Built with CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=y,
the default is off.
+ kthread_cpus= [KNL, SMP] Only run kernel threads on the specified
+ list of processors. The kernel will start threads
+ on the indicated processors only (unless there
+ are specific reasons to run a thread with
+ different affinities). This can be used to make
+ init start on certain processors and also to
+ control where kmod and other user space threads
+ are being spawned. Allows to keep kernel threads
+ away from certain cores unless absoluteluy necessary.
kpti= [ARM64] Control page table isolation of user
and kernel address spaces.
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 57f20a0..4526034 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -54,6 +54,7 @@ extern unsigned int nr_cpu_ids;
* cpu_present_mask - has bit 'cpu' set iff cpu is populated
* cpu_online_mask - has bit 'cpu' set iff cpu available to scheduler
* cpu_active_mask - has bit 'cpu' set iff cpu available to migration
+ * cpu_kthread_mask - has bit 'cpu' set iff general kernel threads allowed
*
* If !CONFIG_HOTPLUG_CPU, present == possible, and active == online.
*
@@ -90,10 +91,12 @@ extern struct cpumask __cpu_possible_mask;
extern struct cpumask __cpu_online_mask;
extern struct cpumask __cpu_present_mask;
extern struct cpumask __cpu_active_mask;
+extern struct cpumask __cpu_kthread_mask;
#define cpu_possible_mask ((const struct cpumask *)&__cpu_possible_mask)
#define cpu_online_mask ((const struct cpumask *)&__cpu_online_mask)
#define cpu_present_mask ((const struct cpumask *)&__cpu_present_mask)
#define cpu_active_mask ((const struct cpumask *)&__cpu_active_mask)
+#define cpu_kthread_mask ((const struct cpumask *)&__cpu_kthread_mask)
#if NR_CPUS > 1
#define num_online_cpus() cpumask_weight(cpu_online_mask)
diff --git a/init/main.c b/init/main.c
index 8cce5b1..0c5457a 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1135,6 +1135,8 @@ static noinline void __init kernel_init_freeable(void)
do_basic_setup();
+ set_cpus_allowed_ptr(current, cpu_kthread_mask);
+
/* Open the /dev/console on the rootfs, this should never fail */
if (ksys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
pr_err("Warning: unable to open an initial console.\n");
diff --git a/kernel/cpu.c b/kernel/cpu.c
index fb61ee6..4c7b343 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -2218,6 +2218,9 @@ EXPORT_SYMBOL_GPL(cpu_bit_bitmap);
const DECLARE_BITMAP(cpu_all_bits, NR_CPUS) = CPU_BITS_ALL;
EXPORT_SYMBOL(cpu_all_bits);
+const DECLARE_BITMAP(cpu_kthread_bits, NR_CPUS) = CPU_BITS_ALL;
+EXPORT_SYMBOL(cpu_kthread_bits);
+
#ifdef CONFIG_INIT_ALL_POSSIBLE
struct cpumask __cpu_possible_mask __read_mostly
= {CPU_BITS_ALL};
@@ -2235,6 +2238,17 @@ EXPORT_SYMBOL(__cpu_present_mask);
struct cpumask __cpu_active_mask __read_mostly;
EXPORT_SYMBOL(__cpu_active_mask);
+struct cpumask __cpu_kthread_mask __read_mostly;
+EXPORT_SYMBOL(__cpu_kthread_mask);
+
+static int __init kthread_setup(char *str)
+{
+ cpulist_parse(str, (struct cpumask *)&cpu_kthread_bits);
+ return 1;
+}
+__setup("kthread_cpus=", kthread_setup);
+
+
void init_cpu_present(const struct cpumask *src)
{
cpumask_copy(&__cpu_present_mask, src);
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 486dedb..697ec70 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -338,7 +338,7 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
* The kernel thread should not inherit these properties.
*/
sched_setscheduler_nocheck(task, SCHED_NORMAL, &param);
- set_cpus_allowed_ptr(task, cpu_all_mask);
+ set_cpus_allowed_ptr(task, cpu_kthread_mask);
}
kfree(create);
return task;
@@ -561,7 +561,7 @@ int kthreadd(void *unused)
/* Setup a clean context for our children to inherit. */
set_task_comm(tsk, "kthreadd");
ignore_signals(tsk);
- set_cpus_allowed_ptr(tsk, cpu_all_mask);
+ set_cpus_allowed_ptr(tsk, cpu_kthread_mask);
set_mems_allowed(node_states[N_MEMORY]);
current->flags |= PF_NOFREEZE;
diff --git a/kernel/umh.c b/kernel/umh.c
index c449858..90c3a60 100644
--- a/kernel/umh.c
+++ b/kernel/umh.c
@@ -72,6 +72,9 @@ static int call_usermodehelper_exec_async(void *data)
flush_signal_handlers(current, 1);
spin_unlock_irq(&current->sighand->siglock);
+ /* We can run only where init is allowed to run. */
+ set_cpus_allowed_ptr(current, cpu_kthread_mask);
+
/*
* Our parent (unbound workqueue) runs with elevated scheduling
* priority. Avoid propagating that into the userspace child.
--
2.18.1