From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: akpm@linux-foundation.org,
"Benjamin Herrenschmidt" <benh@kernel.crashing.org>,
"Robert Jennings" <rcj@linux.vnet.ibm.com>
Subject: [34/94] powerpc: Bring all threads online prior to migration/hibernation
Date: Tue, 28 May 2013 04:49:53 +0100 [thread overview]
Message-ID: <lsq.1369712993.409253031@decadent.org.uk> (raw)
In-Reply-To: <lsq.1369712992.755341692@decadent.org.uk>
3.2.46-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Robert Jennings <rcj@linux.vnet.ibm.com>
commit 120496ac2d2d60aee68d3123a68169502a85f4b5 upstream.
This patch brings online all threads which are present but not online
prior to migration/hibernation. After migration/hibernation those
threads are taken back offline.
During migration/hibernation all online CPUs must call H_JOIN, this is
required by the hypervisor. Without this patch, threads that are offline
(H_CEDE'd) will not be woken to make the H_JOIN call and the OS will be
deadlocked (all threads either JOIN'd or CEDE'd).
Signed-off-by: Robert Jennings <rcj@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
arch/powerpc/include/asm/rtas.h | 2 +
arch/powerpc/kernel/rtas.c | 113 ++++++++++++++++++++++++++++++
arch/powerpc/platforms/pseries/suspend.c | 22 ++++++
3 files changed, 137 insertions(+)
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -230,6 +230,8 @@ extern void rtas_progress(char *s, unsig
extern void rtas_initialize(void);
extern int rtas_suspend_cpu(struct rtas_suspend_me_data *data);
extern int rtas_suspend_last_cpu(struct rtas_suspend_me_data *data);
+extern int rtas_online_cpus_mask(cpumask_var_t cpus);
+extern int rtas_offline_cpus_mask(cpumask_var_t cpus);
extern int rtas_ibm_suspend_me(struct rtas_args *);
struct rtc_time;
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -19,6 +19,7 @@
#include <linux/init.h>
#include <linux/capability.h>
#include <linux/delay.h>
+#include <linux/cpu.h>
#include <linux/smp.h>
#include <linux/completion.h>
#include <linux/cpumask.h>
@@ -809,6 +810,95 @@ static void rtas_percpu_suspend_me(void
__rtas_suspend_cpu((struct rtas_suspend_me_data *)info, 1);
}
+enum rtas_cpu_state {
+ DOWN,
+ UP,
+};
+
+#ifndef CONFIG_SMP
+static int rtas_cpu_state_change_mask(enum rtas_cpu_state state,
+ cpumask_var_t cpus)
+{
+ if (!cpumask_empty(cpus)) {
+ cpumask_clear(cpus);
+ return -EINVAL;
+ } else
+ return 0;
+}
+#else
+/* On return cpumask will be altered to indicate CPUs changed.
+ * CPUs with states changed will be set in the mask,
+ * CPUs with status unchanged will be unset in the mask. */
+static int rtas_cpu_state_change_mask(enum rtas_cpu_state state,
+ cpumask_var_t cpus)
+{
+ int cpu;
+ int cpuret = 0;
+ int ret = 0;
+
+ if (cpumask_empty(cpus))
+ return 0;
+
+ for_each_cpu(cpu, cpus) {
+ switch (state) {
+ case DOWN:
+ cpuret = cpu_down(cpu);
+ break;
+ case UP:
+ cpuret = cpu_up(cpu);
+ break;
+ }
+ if (cpuret) {
+ pr_debug("%s: cpu_%s for cpu#%d returned %d.\n",
+ __func__,
+ ((state == UP) ? "up" : "down"),
+ cpu, cpuret);
+ if (!ret)
+ ret = cpuret;
+ if (state == UP) {
+ /* clear bits for unchanged cpus, return */
+ cpumask_shift_right(cpus, cpus, cpu);
+ cpumask_shift_left(cpus, cpus, cpu);
+ break;
+ } else {
+ /* clear bit for unchanged cpu, continue */
+ cpumask_clear_cpu(cpu, cpus);
+ }
+ }
+ }
+
+ return ret;
+}
+#endif
+
+int rtas_online_cpus_mask(cpumask_var_t cpus)
+{
+ int ret;
+
+ ret = rtas_cpu_state_change_mask(UP, cpus);
+
+ if (ret) {
+ cpumask_var_t tmp_mask;
+
+ if (!alloc_cpumask_var(&tmp_mask, GFP_TEMPORARY))
+ return ret;
+
+ /* Use tmp_mask to preserve cpus mask from first failure */
+ cpumask_copy(tmp_mask, cpus);
+ rtas_offline_cpus_mask(tmp_mask);
+ free_cpumask_var(tmp_mask);
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(rtas_online_cpus_mask);
+
+int rtas_offline_cpus_mask(cpumask_var_t cpus)
+{
+ return rtas_cpu_state_change_mask(DOWN, cpus);
+}
+EXPORT_SYMBOL(rtas_offline_cpus_mask);
+
int rtas_ibm_suspend_me(struct rtas_args *args)
{
long state;
@@ -816,6 +906,8 @@ int rtas_ibm_suspend_me(struct rtas_args
unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
struct rtas_suspend_me_data data;
DECLARE_COMPLETION_ONSTACK(done);
+ cpumask_var_t offline_mask;
+ int cpuret;
if (!rtas_service_present("ibm,suspend-me"))
return -ENOSYS;
@@ -839,11 +931,24 @@ int rtas_ibm_suspend_me(struct rtas_args
return 0;
}
+ if (!alloc_cpumask_var(&offline_mask, GFP_TEMPORARY))
+ return -ENOMEM;
+
atomic_set(&data.working, 0);
atomic_set(&data.done, 0);
atomic_set(&data.error, 0);
data.token = rtas_token("ibm,suspend-me");
data.complete = &done;
+
+ /* All present CPUs must be online */
+ cpumask_andnot(offline_mask, cpu_present_mask, cpu_online_mask);
+ cpuret = rtas_online_cpus_mask(offline_mask);
+ if (cpuret) {
+ pr_err("%s: Could not bring present CPUs online.\n", __func__);
+ atomic_set(&data.error, cpuret);
+ goto out;
+ }
+
stop_topology_update();
/* Call function on all CPUs. One of us will make the
@@ -859,6 +964,14 @@ int rtas_ibm_suspend_me(struct rtas_args
start_topology_update();
+ /* Take down CPUs not online prior to suspend */
+ cpuret = rtas_offline_cpus_mask(offline_mask);
+ if (cpuret)
+ pr_warn("%s: Could not restore CPUs to offline state.\n",
+ __func__);
+
+out:
+ free_cpumask_var(offline_mask);
return atomic_read(&data.error);
}
#else /* CONFIG_PPC_PSERIES */
--- a/arch/powerpc/platforms/pseries/suspend.c
+++ b/arch/powerpc/platforms/pseries/suspend.c
@@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <linux/cpu.h>
#include <linux/delay.h>
#include <linux/suspend.h>
#include <linux/stat.h>
@@ -126,11 +127,15 @@ static ssize_t store_hibernate(struct sy
struct sysdev_class_attribute *attr,
const char *buf, size_t count)
{
+ cpumask_var_t offline_mask;
int rc;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
+ if (!alloc_cpumask_var(&offline_mask, GFP_TEMPORARY))
+ return -ENOMEM;
+
stream_id = simple_strtoul(buf, NULL, 16);
do {
@@ -140,15 +145,32 @@ static ssize_t store_hibernate(struct sy
} while (rc == -EAGAIN);
if (!rc) {
+ /* All present CPUs must be online */
+ cpumask_andnot(offline_mask, cpu_present_mask,
+ cpu_online_mask);
+ rc = rtas_online_cpus_mask(offline_mask);
+ if (rc) {
+ pr_err("%s: Could not bring present CPUs online.\n",
+ __func__);
+ goto out;
+ }
+
stop_topology_update();
rc = pm_suspend(PM_SUSPEND_MEM);
start_topology_update();
+
+ /* Take down CPUs not online prior to suspend */
+ if (!rtas_offline_cpus_mask(offline_mask))
+ pr_warn("%s: Could not restore CPUs to offline "
+ "state.\n", __func__);
}
stream_id = 0;
if (!rc)
rc = count;
+out:
+ free_cpumask_var(offline_mask);
return rc;
}
next prev parent reply other threads:[~2013-05-28 3:56 UTC|newest]
Thread overview: 99+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-28 3:49 [00/94] 3.2.46-rc1 review Ben Hutchings
2013-05-28 3:49 ` [30/94] hwmon: fix error return code in abituguru_probe() Ben Hutchings
2013-05-28 3:49 ` [64/94] mm/THP: use pmd_populate() to update the pmd with pgtable_t pointer Ben Hutchings
2013-05-28 3:49 ` [56/94] perf: net_dropmonitor: Fix trace parameter order Ben Hutchings
2013-05-28 3:49 ` [81/94] 3c509.c: call SET_NETDEV_DEV for all device types (ISA/ISAPnP/EISA) Ben Hutchings
2013-05-28 3:49 ` [39/94] tracing: Fix leaks of filter preds Ben Hutchings
2013-05-28 3:49 ` [33/94] powerpc/pseries: Fix partition migration hang in stop_topology_update Ben Hutchings
2013-05-28 3:49 ` [90/94] xfrm6: release dev before returning error Ben Hutchings
2013-05-28 3:49 ` [84/94] packet: tpacket_v3: do not trigger bug() on wrong header status Ben Hutchings
2013-05-28 3:49 ` [32/94] avr32: fix relocation check for signed 18-bit offset Ben Hutchings
2013-05-28 3:49 ` [87/94] if_cablemodem.h: Add parenthesis around ioctl macros Ben Hutchings
2013-05-28 3:49 ` [29/94] staging: vt6656: use free_netdev instead of kfree Ben Hutchings
2013-05-28 3:49 ` [72/94] sched/debug: Fix sd->*_idx limit range avoiding overflow Ben Hutchings
2013-05-28 3:49 ` [43/94] USB: reset resume quirk needed by a hub Ben Hutchings
2013-05-28 3:49 ` [24/94] dm snapshot: fix error return code in snapshot_ctr Ben Hutchings
2013-05-28 3:49 ` [47/94] i2c: designware: always clear interrupts before enabling them Ben Hutchings
2013-05-28 3:49 ` [26/94] tick: Cleanup NOHZ per cpu data on cpu down Ben Hutchings
2013-05-28 3:49 ` [01/94] Revert "drm/i915: Fix detection of base of stolen memory" Ben Hutchings
2013-05-28 3:49 ` [05/94] mmc: atmel-mci: pio hang on block errors Ben Hutchings
2013-05-28 3:49 ` [54/94] sunrpc: clarify comments on rpc_make_runnable Ben Hutchings
2013-05-28 10:14 ` Jeff Layton
2013-05-28 10:41 ` Luis Henriques
2013-05-28 10:48 ` Jeff Layton
2013-05-28 3:49 ` [14/94] ALSA: HDA: Fix Oops caused by dereference NULL pointer Ben Hutchings
2013-05-28 3:49 ` [52/94] USB: cxacru: potential underflow in cxacru_cm_get_array() Ben Hutchings
2013-05-28 3:49 ` [36/94] tg3: Skip powering down function 0 on certain serdes devices Ben Hutchings
2013-05-28 3:49 ` [82/94] net_sched: act_ipt forward compat with xtables Ben Hutchings
2013-05-28 3:49 ` [63/94] mm compaction: fix of improper cache flush in migration code Ben Hutchings
2013-05-28 3:49 ` [59/94] fat: fix possible overflow for fat_clusters Ben Hutchings
2013-05-28 3:49 ` [08/94] ath9k: fix key allocation error handling for powersave keys Ben Hutchings
2013-05-28 3:49 ` [03/94] mmc: core: Fix bit width test failing on old eMMC cards Ben Hutchings
2013-05-28 3:49 ` [76/94] x86, efivars: firmware bug workarounds should be in platform code Ben Hutchings
2013-05-28 3:49 ` [02/94] mmc: at91/avr32/atmel-mci: fix DMA-channel leak on module unload Ben Hutchings
2013-05-28 3:49 ` [89/94] ipv6: do not clear pinet6 field Ben Hutchings
2013-05-28 3:49 ` [28/94] drm/radeon: check incoming cliprects pointer Ben Hutchings
2013-05-28 3:49 ` [73/94] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Ben Hutchings
2013-05-28 3:49 ` [62/94] rapidio/tsi721: fix bug in MSI interrupt handling Ben Hutchings
2013-05-28 3:49 ` [69/94] mm/pagewalk.c: walk_page_range should avoid VM_PFNMAP areas Ben Hutchings
2013-05-28 3:49 ` [83/94] bridge: fix race with topology change timer Ben Hutchings
2013-05-28 3:49 ` [79/94] x86,efi: Implement efi_no_storage_paranoia parameter Ben Hutchings
2013-05-28 3:49 ` [18/94] mwifiex: clear is_suspended flag when interrupt is received early Ben Hutchings
2013-05-28 3:49 ` [12/94] xen/vcpu/pvhvm: Fix vcpu hotplugging hanging Ben Hutchings
2013-05-28 3:49 ` [13/94] autofs - remove autofs dentry mount check Ben Hutchings
2013-05-28 3:49 ` [07/94] ASoC: wm8994: missing break in wm8994_aif3_hw_params() Ben Hutchings
2013-05-28 3:49 ` [74/94] pch_dma: Use GFP_ATOMIC because called from interrupt context Ben Hutchings
2013-05-28 3:49 ` [67/94] random: fix accounting race condition with lockless irq entropy_count update Ben Hutchings
2013-05-28 3:49 ` [80/94] tcp: force a dst refcount when prequeue packet Ben Hutchings
2013-05-28 3:49 ` [58/94] ACPI / video: Add "Asus UL30A" to ACPI video detect blacklist Ben Hutchings
2013-05-28 3:49 ` [49/94] btrfs: don't stop searching after encountering the wrong item Ben Hutchings
2013-05-28 3:49 ` [68/94] ocfs2: goto out_unlock if ocfs2_get_clusters_nocache() failed in ocfs2_fiemap() Ben Hutchings
2013-05-28 3:49 ` [51/94] ARM: plat-orion: Fix num_resources and id for ge10 and ge11 Ben Hutchings
2013-05-28 3:49 ` Ben Hutchings [this message]
2013-05-28 3:49 ` [66/94] nilfs2: fix issue of nilfs_set_page_dirty() for page at EOF boundary Ben Hutchings
2013-05-28 3:49 ` [93/94] staging: comedi: prevent auto-unconfig of manually configured devices Ben Hutchings
2013-05-28 3:49 ` [22/94] hp_accel: Ignore the error from lis3lv02d_poweron() at resume Ben Hutchings
2013-05-28 3:49 ` [86/94] 3c59x: fix PCI resource management Ben Hutchings
2013-05-28 3:49 ` [04/94] mfd: adp5520: Restore mode bits on resume Ben Hutchings
2013-05-28 3:49 ` [57/94] perf: net_dropmonitor: Fix symbol-relative addresses Ben Hutchings
2013-05-28 3:49 ` [60/94] wait: fix false timeouts when using wait_event_timeout() Ben Hutchings
2013-05-28 3:49 ` [09/94] nfsd4: don't allow owner override on 4.1 CLAIM_FH opens Ben Hutchings
2013-05-28 3:49 ` [46/94] USB: option: add device IDs for Dell 5804 (Novatel E371) WWAN card Ben Hutchings
2013-05-28 3:49 ` [31/94] Kirkwood: Enable PCIe port 1 on QNAP TS-11x/TS-21x Ben Hutchings
2013-05-28 3:49 ` [94/94] um: Serve io_remap_pfn_range() Ben Hutchings
2013-05-28 3:49 ` [88/94] macvlan: fix passthru mode race between dev removal and rx path Ben Hutchings
2013-05-28 3:49 ` [55/94] SUNRPC: Prevent an rpc_task wakeup race Ben Hutchings
2013-05-28 3:49 ` [44/94] usb: option: Add Telewell TW-LTE 4G Ben Hutchings
2013-05-28 3:49 ` [75/94] drbd: fix for deadlock when using automatic split-brain-recovery Ben Hutchings
2013-05-28 3:49 ` [35/94] timer: Don't reinitialize the cpu base lock during CPU_UP_PREPARE Ben Hutchings
2013-05-28 3:49 ` [85/94] 3c59x: fix freeing nonexistent resource on driver unload Ben Hutchings
2013-05-28 3:49 ` [71/94] sched/debug: Limit sd->*_idx range on sysctl Ben Hutchings
2013-05-28 3:49 ` [41/94] drivers/char/ipmi: memcpy, need additional 2 bytes to avoid memory overflow Ben Hutchings
2013-05-28 3:49 ` [37/94] USB: xHCI: override bogus bulk wMaxPacketSize values Ben Hutchings
2013-05-28 3:49 ` [61/94] mm: mmu_notifier: re-fix freed page still mapped in secondary MMU Ben Hutchings
2013-05-28 3:49 ` [40/94] usermodehelper: check subprocess_info->path != NULL Ben Hutchings
2013-05-28 3:49 ` [23/94] KVM: VMX: fix halt emulation while emulating invalid guest sate Ben Hutchings
2013-05-28 3:49 ` [91/94] drivers/rtc/rtc-pcf2123.c: fix error return code in pcf2123_probe() Ben Hutchings
2013-05-28 3:49 ` [17/94] B43: Handle DMA RX descriptor underrun Ben Hutchings
2013-05-28 3:49 ` [77/94] efi: Export efi_query_variable_store() for efivars.ko Ben Hutchings
2013-05-28 3:49 ` [16/94] ACPICA: Fix possible buffer overflow during a field unit read operation Ben Hutchings
2013-05-28 3:49 ` [20/94] mwifiex: fix setting of multicast filter Ben Hutchings
2013-05-28 3:49 ` [38/94] USB: UHCI: fix for suspend of virtual HP controller Ben Hutchings
2013-05-28 3:49 ` [15/94] iscsi-target: Fix processing of OOO commands Ben Hutchings
2013-05-28 3:49 ` [92/94] [media] mantis: fix silly crash case Ben Hutchings
2013-05-28 3:49 ` [70/94] xhci: Don't warn on empty ring for suspended devices Ben Hutchings
2013-05-28 3:49 ` [27/94] ACPI / EC: Restart transaction even when the IBF flag set Ben Hutchings
2013-05-28 3:49 ` [21/94] cifs: only set ops for inodes in I_NEW state Ben Hutchings
2013-05-28 3:49 ` [19/94] mwifiex: fix memory leak issue when driver unload Ben Hutchings
2013-05-28 3:49 ` [06/94] x86: Eliminate irq_mis_count counted in arch_irq_stat Ben Hutchings
2013-05-28 3:49 ` [48/94] USB: ftdi_sio: Add support for Newport CONEX motor drivers Ben Hutchings
2013-05-28 3:49 ` [42/94] ipmi: ipmi_devintf: compat_ioctl method fails to take ipmi_mutex Ben Hutchings
2013-05-28 3:49 ` [25/94] dm bufio: avoid a possible __vmalloc deadlock Ben Hutchings
2013-05-28 3:49 ` [11/94] ext4: limit group search loop for non-extent files Ben Hutchings
2013-05-28 3:49 ` [50/94] virtio_console: fix uapi header Ben Hutchings
2013-05-28 3:49 ` [53/94] TTY: Fix tty miss restart after we turn off flow-control Ben Hutchings
2013-05-28 3:49 ` [78/94] x86,efi: Check max_size only if it is non-zero Ben Hutchings
2013-05-28 3:49 ` [65/94] drivers/block/brd.c: fix brd_lookup_page() race Ben Hutchings
2013-05-28 3:49 ` [10/94] net/eth/ibmveth: Fixup retrieval of MAC address Ben Hutchings
2013-05-28 3:49 ` [45/94] USB: Blacklisted Cinterion's PLxx WWAN Interface Ben Hutchings
2013-05-28 4:25 ` [00/94] 3.2.46-rc1 review Ben Hutchings
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=lsq.1369712993.409253031@decadent.org.uk \
--to=ben@decadent.org.uk \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rcj@linux.vnet.ibm.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome