1
0
Fork 0
Fork of alistair23 Linux kernel for reMarkable from https://github.com/alistair23/linux
 
 
 
 
 
 
Go to file
Rafael J. Wysocki 1e03824c0f LF-226 cpufreq: Avoid leaving stale IRQ work items during CPU offline
The scheduler code calling cpufreq_update_util() may run during CPU
offline on the target CPU after the IRQ work lists have been flushed
for it, so the target CPU should be prevented from running code that
may queue up an IRQ work item on it at that point.

Unfortunately, that may not be the case if dvfs_possible_from_any_cpu
is set for at least one cpufreq policy in the system, because that
allows the CPU going offline to run the utilization update callback
of the cpufreq governor on behalf of another (online) CPU in some cases.

If that happens, the cpufreq governor callback may queue up an IRQ work
on the CPU running it, which is going offline, and the IRQ work will
not be flushed after that point.  Moreover, that IRQ work cannot be
flushed until the "offlining" CPU goes back online, so if any other
CPU calls irq_work_sync() to wait for the completion of that IRQ work,
it will have to wait until the "offlining" CPU is back online and that
may not happen forever. In particular, a system-wide deadlock may
occur during CPU online as a result of that.

The failing scenario is as follows. CPU0 is the boot CPU, so it creates
a cpufreq policy and becomes the "leader" of it (policy->cpu).  It
cannot go offline, because it is the boot CPU.
Next, other CPUs join the cpufreq policy as they go online and they
leave it when they go offline.  The last CPU to go offline, say CPU3,
may queue up an IRQ work while running the governor callback on behalf
of CPU0 after leaving the cpufreq policy because of the
dvfs_possible_from_any_cpu effect described above.  Then, CPU0 is the
only online CPU in the system and the stale IRQ work is still queued on
CPU3.  When, say, CPU1 goes back online, it will run
irq_work_sync() to wait for that IRQ work to complete and so it will
wait for CPU3 to go back online (which may never happen even in
principle), but (worse yet) CPU0 is waiting for CPU1 at that point too
and a system-wide deadlock occurs.

To address this problem notice that CPUs which cannot run cpufreq
utilization update code for themselves (for example, because they have
left the cpufreq policies that they belonged to), should also be
prevented from running that code on behalf of the other CPUs that
belong to a cpufreq policy with dvfs_possible_from_any_cpu set and so
in that case the cpufreq_update_util_data pointer of the CPU running
the code must not be NULL as well as for the CPU which is the target
of the cpufreq utilization update in progress.

Accordingly, change cpufreq_this_cpu_can_update() into a regular
function in kernel/sched/cpufreq.c (instead of a static inline in a
header file) and make it check the cpufreq_update_util_data pointer
of the local CPU if dvfs_possible_from_any_cpu is set for the target
cpufreq policy.

Also update the schedutil governor to do the
cpufreq_this_cpu_can_update() check in the non-fast-switch case too
to avoid the stale IRQ work issues.

Fixes: 99d14d0e16 ("cpufreq: Process remote callbacks from any CPU if the platform permits")
Reported-by: Anson Huang <anson.huang@nxp.com>
Cc: 4.14+ <stable@vger.kernel.org> # 4.14+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>
2019-12-12 09:33:40 +08:00
Documentation Documentation: dt: binding: fsl: Add 'fsl,ippdexpcr1-alt-addr' property 2019-12-05 12:06:23 +08:00
LICENSES LICENSES: Rename other to deprecated 2019-05-03 06:34:32 -06:00
arch LF-425-1 arm64: dts: imx8mm-evk: add 'attach-bridge' to dsi port@1 2019-12-12 09:20:10 +08:00
block MLK-11444 ata: imx: cmd buf corruption errata bug fix 2019-11-25 15:45:46 +08:00
certs PKCS#7: Refactor verify_pkcs7_signature() 2019-08-05 18:40:18 -04:00
crypto crypto: tcrypt - include rsa test 2019-12-02 18:02:09 +08:00
drivers LF-425-2 drm/bridge: sec-dsim: use 'attach-bridge' for bridge attach 2019-12-12 09:20:10 +08:00
fs Revert "jffs2: Fix possible null-pointer dereferences in jffs2_add_frag_to_fragtree()" 2019-11-25 15:47:00 +08:00
include LF-226 cpufreq: Avoid leaving stale IRQ work items during CPU offline 2019-12-12 09:33:40 +08:00
init Merge branch 'next-lockdown' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security 2019-09-28 08:14:15 -07:00
ipc ipc/sem.c: convert to use built-in RCU list checking 2019-09-25 17:51:41 -07:00
kernel LF-226 cpufreq: Avoid leaving stale IRQ work items during CPU offline 2019-12-12 09:33:40 +08:00
lib mm: Re-export ioremap_page_range 2019-11-25 15:46:59 +08:00
mm mm/ksm.c: don't WARN if page is still mapped in remove_stable_node() 2019-11-22 09:11:18 -08:00
net Merge branch 'wifi/next' into next 2019-12-02 18:05:33 +08:00
samples samples/bpf: fix build by setting HAVE_ATTR_TEST to zero 2019-10-31 21:39:15 +01:00
scripts arm64 fix for -rc8 / final 2019-11-15 09:14:23 -08:00
security encrypted_keys: Adds support for secure key-type as master key. 2019-11-25 15:43:21 +08:00
sound LF-406: ASoC: fsl_audmix: add missing spin lock init 2019-12-10 13:28:31 +02:00
tools perf vendor events: add JSON metrics for imx8 DDR Perf 2019-11-28 12:11:37 +08:00
usr kbuild: update compile-test header list for v5.4-rc2 2019-10-05 15:29:49 +09:00
virt virt/vgic: Increase number of DeviceIDs to 17 2019-11-25 15:43:45 +08:00
.clang-format clang-format: Update with the latest for_each macro list 2019-08-31 10:00:51 +02:00
.cocciconfig
.get_maintainer.ignore Opt out of scripts/get_maintainer.pl 2019-05-16 10:53:40 -07:00
.gitattributes .gitattributes: set git diff driver for C source code files 2016-10-07 18:46:30 -07:00
.gitignore Modules updates for v5.4 2019-09-22 10:34:46 -07:00
.mailmap ARM: SoC fixes 2019-11-10 13:41:59 -08:00
COPYING COPYING: use the new text with points to the license files 2018-03-23 12:41:45 -06:00
CREDITS MAINTAINERS: Remove Simon as Renesas SoC Co-Maintainer 2019-10-10 08:12:51 -07:00
Kbuild kbuild: do not descend to ./Kbuild when cleaning 2019-08-21 21:03:58 +09:00
Kconfig docs: kbuild: convert docs to ReST and rename to *.rst 2019-06-14 14:21:21 -06:00
MAINTAINERS Merge branch 'qe/next' into next 2019-12-02 18:05:23 +08:00
Makefile Linux 5.4 2019-11-24 16:32:01 -08:00
README Drop all 00-INDEX files from Documentation/ 2018-09-09 15:08:58 -06:00

README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.