tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Small bug with offline cpus
In article <55E027CD.4010705%m00nbsd.net@localhost>,
Maxime Villard <max%m00nbsd.net@localhost> wrote:
>Hi,
>a bug I must have spotted some weeks ago: the kernel decrements the
>number of offline cpus even when trying to shutting down one fails.
>How to reproduce:
>
> # schedctl -p SOME_RANDOM_PROC_PID -A 0
> # sysctl hw.ncpuonline
> # cpuctl offline 0 (it fails)
> # sysctl hw.ncpuonline (one cpu missing)
>
>If you cpuctl too much, the value goes negative. This is not a harmful
>bug.
>
>Index: kern_cpu.c
>===================================================================
>RCS file: /cvsroot/src/sys/kern/kern_cpu.c,v
>retrieving revision 1.70
>diff -u -r1.70 kern_cpu.c
>--- kern_cpu.c 20 Aug 2015 09:45:45 -0000 1.70
>+++ kern_cpu.c 28 Aug 2015 08:51:36 -0000
>@@ -444,7 +444,6 @@
> if ((spc->spc_flags & SPCF_OFFLINE) == 0)
> return 0;
> func = (xcfunc_t)cpu_xc_online;
>- ncpuonline++;
> } else {
> if ((spc->spc_flags & SPCF_OFFLINE) != 0)
> return 0;
>@@ -463,16 +462,19 @@
> if (nonline == 1)
> return EBUSY;
> func = (xcfunc_t)cpu_xc_offline;
>- ncpuonline--;
> }
>
> where = xc_unicast(0, func, ci, NULL, ci);
> xc_wait(where);
> if (online) {
> KASSERT((spc->spc_flags & SPCF_OFFLINE) == 0);
>- } else if ((spc->spc_flags & SPCF_OFFLINE) == 0) {
>- /* If was not set offline, then it is busy */
>- return EBUSY;
>+ ncpuonline++;
>+ } else {
>+ if ((spc->spc_flags & SPCF_OFFLINE) == 0) {
>+ /* If was not set offline, then it is busy */
>+ return EBUSY;
>+ }
>+ ncpuonline--;
> }
>
> spc->spc_lastmod = time_second;
>
>
>Ok?
Ok with me.
christos
Home |
Main Index |
Thread Index |
Old Index