Re: [PATCH v2 2/2] ACPI, APEI, ERST: Fixed leaked resources in erst_init

2016-03-08 Thread Chen, Gong
On Tue, Mar 08, 2016 at 10:52:12AM -0500, Joshua Hunt wrote:
> Date: Tue,  8 Mar 2016 10:52:12 -0500
> From: Joshua Hunt 
> To: gong.c...@intel.com, linux-a...@vger.kernel.org, r...@rjwysocki.net,
>  l...@kernel.org, ying.hu...@intel.com
> Cc: tony.l...@intel.com, linux-kernel@vger.kernel.org, Joshua Hunt
>  
> Subject: [PATCH v2 2/2] ACPI, APEI, ERST: Fixed leaked resources in
>  erst_init
> X-Mailer: git-send-email 1.7.9.5
> 
> erst_init currently leaks resources allocated from its call to
> apei_resources_init(). The data allocated there gets copied
> into apei_resources_all and can be freed when we're done with it.
> 
> Signed-off-by: Josh Hunt 

Reviewed-by: Chen, Gong 



signature.asc
Description: Digital signature


Re: [PATCH v2 1/2] ACPI, APEI: Fix leaked resources

2016-03-08 Thread Chen, Gong
On Tue, Mar 08, 2016 at 10:52:11AM -0500, Joshua Hunt wrote:
> Date: Tue,  8 Mar 2016 10:52:11 -0500
> From: Joshua Hunt 
> To: gong.c...@intel.com, linux-a...@vger.kernel.org, r...@rjwysocki.net,
>  l...@kernel.org, ying.hu...@intel.com
> Cc: tony.l...@intel.com, linux-kernel@vger.kernel.org, Joshua Hunt
>  
> Subject: [PATCH v2 1/2] ACPI, APEI: Fix leaked resources
> X-Mailer: git-send-email 1.7.9.5
> 
> We leak the NVS and arch resources (if used), in apei_resources_request.
> They are allocated to make sure we exclude them from the APEI resources,
> but they are never freed at the end of the function. Free them now.
> 
> Signed-off-by: Josh Hunt 
>
Reviewed-by: Chen, Gong 


signature.asc
Description: Digital signature


RE: [Patch V2 2/2] x86, mce: Need to translate GPA to HPA to inject error in guest.

2015-12-11 Thread Chen, Gong
Hi, Ashok

Please add " original author by Huang Ying " at some 
place.
Thanks.

> -Original Message-
> From: Raj, Ashok
> Sent: Friday, December 11, 2015 3:41 AM
> To: k...@vger.kernel.org
> Cc: Chen, Gong; Gleb Natapov; Paolo Bonzini; qemu-de...@nongnu.org;
> linux-kernel@vger.kernel.org; Boris Petkov; Luck, Tony; Raj, Ashok; Kleen,
> Andi
> Subject: [Patch V2 2/2] x86, mce: Need to translate GPA to HPA to inject
> error in guest.
> 
> From: Gong Chen 
> 
> When we need to test error injection to a specific address using EINJ,
> there needs to be a way to translate GPA to HPA. This will allow host EINJ
> to inject error to test how guest behavior is when a bad address is consumed.
> This permits guest OS to perform its own recovery.
> 
> Signed-off-by: Gong Chen 
> ---
> Sorry about the spam :-(.
> Resending with proper Commit Message. Previous had a bogus From. Fixed
> that.
> before sending.
> 
>  hmp-commands.hx   | 14 ++
>  include/exec/memory.h |  2 ++
>  kvm-all.c | 24 
>  memory.c  | 13 +
>  monitor.c | 16 
>  5 files changed, 69 insertions(+)
>  mode change 100644 => 100755 include/exec/memory.h
>  mode change 100644 => 100755 kvm-all.c
>  mode change 100644 => 100755 memory.c
>  mode change 100644 => 100755 monitor.c
> 
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index bb52e4d..673c00e 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -444,6 +444,20 @@ Start gdbserver session (default @var{port}=1234)
>  ETEXI
> 
>  {
> +  .name = "x-gpa2hva",
> +  .args_type= "fmt:/,addr:l",
> +  .params   = "/fmt addr",
> +  .help = "translate guest physical 'addr' to host virtual 
> address,
> only for debugging",
> +  .mhandler.cmd = do_gpa2hva,
> +},
> +
> +STEXI
> +@item x-gpa2hva @var{addr}
> +@findex x-gpa2hva
> +Translate guest physical @var{addr} to host virtual address, only for
> debugging.
> +ETEXI
> +
> +{
>  .name   = "x",
>  .args_type  = "fmt:/,addr:l",
>  .params = "/fmt addr",
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> old mode 100644
> new mode 100755
> index 0f07159..57d7bf8
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -222,6 +222,7 @@ struct MemoryListener {
> hwaddr addr, hwaddr len);
>  void (*coalesced_mmio_del)(MemoryListener *listener,
> MemoryRegionSection *section,
> hwaddr addr, hwaddr len);
> +int  (*translate_gpa2hva)(MemoryListener *listener, uint64_t paddr,
> uint64_t *vaddr);
>  /* Lower = earlier (during add), later (during del) */
>  unsigned priority;
>  AddressSpace *address_space_filter;
> @@ -1123,6 +1124,7 @@ void memory_global_dirty_log_start(void);
>  void memory_global_dirty_log_stop(void);
> 
>  void mtree_info(fprintf_function mon_printf, void *f);
> +int  memory_translate_gpa2hva(hwaddr paddr, uint64_t *vaddr);
> 
>  /**
>   * memory_region_dispatch_read: perform a read directly to the specified
> diff --git a/kvm-all.c b/kvm-all.c
> old mode 100644
> new mode 100755
> index c648b81..cb029be
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -197,6 +197,29 @@ static KVMSlot
> *kvm_lookup_overlapping_slot(KVMMemoryListener *kml,
>  return found;
>  }
> 
> +
> +static int kvm_translate_gpa2hva(MemoryListener *listener, uint64_t paddr,
> uint64_t *vaddr)
> +{
> +KVMState *s = kvm_state;
> +KVMMemoryListener *kml = container_of(listener, KVMMemoryListener,
> listener);
> +KVMSlot *mem = NULL;
> +int i;
> +
> +for (i = 0; i < s->nr_slots; i++) {
> +mem = &kml->slots[i];
> +if (paddr >= mem->start_addr && paddr < mem->start_addr + mem-
> >memory_size) {
> +*vaddr = (uint64_t)mem->ram + paddr - mem->start_addr;
> +break;
> + }
> +}
> +
> +if (i == s->nr_slots) {
> +fprintf(stderr, "fail to find target physical addr(%ld) in KVM memory
> range\n", paddr);
> + return 1;
> +}
> +return 0;
> +}
> +
>  int kvm_physical_memory_addr_from_host(KVMState *s, void *ram,
> hwaddr *phys_addr)
>  {
> @@ -902,6 +925,7 @@ void kvm_memory_listener_register(KVMState *s,
> KVMMemoryListener *kml,
>  kml->listener.log_start = kvm_log_start;
>  kml->listener.log_stop = kvm_log_

Re: [UNTESTED PATCH] x86, mce: Avoid double entry of deferred errors into the genpool.

2015-11-11 Thread Chen, Gong
On Wed, Nov 11, 2015 at 02:01:51PM -0800, Luck, Tony wrote:
> Date: Wed, 11 Nov 2015 14:01:51 -0800
> From: Tony Luck 
> To: "Chen, Gong" 
> Cc: b...@alien8.de, linux-e...@vger.kernel.org, linux-kernel@vger.kernel.org
> Subject: [UNTESTED PATCH] x86, mce: Avoid double entry of deferred errors
>  into the genpool.
> 
> We used to have a special ring buffer for deferred errors that
> was used to mark problem pages. We replaced that with a genpool.
> Then later converted mce_log() to also use the same genpool. As
> a result we end up adding all deferred errors to the genpool twice.
> 
> Rearrange this code. Make sure to set the m.severity and m.usable_addr
> fields for deferred errors. Then if flags and mca_cfg.dont_log_ce mean
> we call mce_log() we are done, because that will add this entry to the
> genpool.
> 
> If we skipped mce_log(), then we still want to take action for the
> deferred error, so add to the genpool.
> 
> Changed the name of the boolean "error_logged" to "error_seen", we
> should set it whether of not we logged an error because the return
> value from machine_check_poll() is used to decide whether storms
> have subsided or not.
> 
> Reported-by: Chen, Gong 
> Signed-off-by: Tony Luck 
> ---

It's much better than my original version.


signature.asc
Description: PGP signature


[PATCH] Cleanup useless codes in CMCI handler

2015-11-10 Thread Chen, Gong
UCNA errors share the same handler with CMCI. But it doesn't
need extra operation to save error record in genpool. Remove
these uselss codes.

Signed-off-by: Chen, Gong 
---
 arch/x86/kernel/cpu/mcheck/mce.c | 14 --
 1 file changed, 14 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index c5b0d562dbf5..1ad3fb4f99b7 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -609,20 +609,6 @@ bool machine_check_poll(enum mcp_flags flags, mce_banks_t 
*b)
severity = mce_severity(&m, mca_cfg.tolerant, NULL, false);
 
/*
-* In the cases where we don't have a valid address after all,
-* do not add it into the ring buffer.
-*/
-   if (severity == MCE_DEFERRED_SEVERITY && memory_error(&m)) {
-   if (m.status & MCI_STATUS_ADDRV) {
-   m.severity = severity;
-   m.usable_addr = mce_usable_address(&m);
-
-   if (!mce_gen_pool_add(&m))
-   mce_schedule_work();
-   }
-   }
-
-   /*
 * Don't get the IP here because it's unlikely to
 * have anything to do with the actual error location.
 */
-- 
2.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:ras/core] x86/mce: Avoid potential deadlock due to printk() in MCE context

2015-08-13 Thread tip-bot for Chen, Gong
Commit-ID:  f29a7aff4bd60ebc3da4982f80144a4158c4c74a
Gitweb: http://git.kernel.org/tip/f29a7aff4bd60ebc3da4982f80144a4158c4c74a
Author: Chen, Gong 
AuthorDate: Wed, 12 Aug 2015 18:29:37 +0200
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Aug 2015 10:12:51 +0200

x86/mce: Avoid potential deadlock due to printk() in MCE context

Printing in MCE context is a no-no, currently, as printk() is
not NMI-safe. If some of the notifiers on the MCE chain call do
so, we may deadlock. In order to avoid that, delay printk() to
process context where it is safe.

Reported-by: Xie XiuQi 
Signed-off-by: Chen, Gong 
[ Fold in subsequent patch from Boris for early boot logging. ]
Signed-off-by: Tony Luck 
[ Kick irq_work in mce_log() directly. ]
Signed-off-by: Borislav Petkov 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/1439396985-12812-6-git-send-email...@alien8.de
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/cpu/mcheck/mce-apei.c  | 1 -
 arch/x86/kernel/cpu/mcheck/mce.c   | 4 ++--
 arch/x86/kernel/cpu/mcheck/mce_intel.c | 1 -
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce-apei.c 
b/arch/x86/kernel/cpu/mcheck/mce-apei.c
index a1aef95..34c89a3 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-apei.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-apei.c
@@ -57,7 +57,6 @@ void apei_mce_report_mem_error(int severity, struct 
cper_sec_mem_err *mem_err)
 
m.addr = mem_err->physical_addr;
mce_log(&m);
-   mce_notify_irq();
 }
 EXPORT_SYMBOL_GPL(apei_mce_report_mem_error);
 
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 8260369..9568bb5 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -159,7 +159,8 @@ void mce_log(struct mce *mce)
/* Emit the trace record: */
trace_mce_record(mce);
 
-   atomic_notifier_call_chain(&x86_mce_decoder_chain, 0, mce);
+   if (!mce_gen_pool_add(mce))
+   irq_work_queue(&mce_irq_work);
 
mce->finished = 0;
wmb();
@@ -1122,7 +1123,6 @@ void do_machine_check(struct pt_regs *regs, long 
error_code)
/* assuming valid severity level != 0 */
m.severity = severity;
m.usable_addr = mce_usable_address(&m);
-   mce_gen_pool_add(&m);
 
mce_log(&m);
 
diff --git a/arch/x86/kernel/cpu/mcheck/mce_intel.c 
b/arch/x86/kernel/cpu/mcheck/mce_intel.c
index 844f56c..70f567f 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_intel.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_intel.c
@@ -246,7 +246,6 @@ static void intel_threshold_interrupt(void)
return;
 
machine_check_poll(MCP_TIMESTAMP, this_cpu_ptr(&mce_banks_owned));
-   mce_notify_irq();
 }
 
 /*
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:ras/core] x86/mce: Remove the MCE ring for Action Optional errors

2015-08-13 Thread tip-bot for Chen, Gong
Commit-ID:  fd4cf79fcc4b5130ced8fd8c40378d3cec2e5fa8
Gitweb: http://git.kernel.org/tip/fd4cf79fcc4b5130ced8fd8c40378d3cec2e5fa8
Author: Chen, Gong 
AuthorDate: Wed, 12 Aug 2015 18:29:36 +0200
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Aug 2015 10:12:51 +0200

x86/mce: Remove the MCE ring for Action Optional errors

Use unified genpool to save Action Optional error events and put
Action Optional error handling in the same notification chain as
MCE error decoding.

Signed-off-by: Chen, Gong 
[ Fold in subsequent patch from Boris for early boot logging. ]
Signed-off-by: Tony Luck 
[ Correct a lot. ]
Signed-off-by: Borislav Petkov 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/1439396985-12812-5-git-send-email...@alien8.de
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/mce.h   |   2 +-
 arch/x86/kernel/cpu/mcheck/mce.c | 135 +--
 drivers/acpi/acpi_extlog.c   |   2 +-
 drivers/edac/i7core_edac.c   |   2 +-
 drivers/edac/mce_amd.c   |   2 +-
 drivers/edac/sb_edac.c   |   2 +-
 6 files changed, 65 insertions(+), 80 deletions(-)

diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index 982dfc3..dfaa4de 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -140,7 +140,7 @@ struct mce_vendor_flags {
 extern struct mce_vendor_flags mce_flags;
 
 extern struct mca_config mca_cfg;
-extern void mce_register_decode_chain(struct notifier_block *nb);
+extern void mce_register_decode_chain(struct notifier_block *nb, bool drain);
 extern void mce_unregister_decode_chain(struct notifier_block *nb);
 
 #include 
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 456f8d7..8260369 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -114,6 +114,7 @@ static struct work_struct mce_work;
 static struct irq_work mce_irq_work;
 
 static void (*quirk_no_way_out)(int bank, struct mce *m, struct pt_regs *regs);
+static int mce_usable_address(struct mce *m);
 
 /*
  * CPU/chipset specific EDAC code can register a notifier call here to print
@@ -234,11 +235,18 @@ static void drain_mcelog_buffer(void)
} while (next != prev);
 }
 
+static struct notifier_block mce_srao_nb;
 
-void mce_register_decode_chain(struct notifier_block *nb)
+void mce_register_decode_chain(struct notifier_block *nb, bool drain)
 {
+   /* Ensure SRAO notifier has the highest priority in the decode chain. */
+   if (nb != &mce_srao_nb && nb->priority == INT_MAX)
+   nb->priority -= 1;
+
atomic_notifier_chain_register(&x86_mce_decoder_chain, nb);
-   drain_mcelog_buffer();
+
+   if (drain)
+   drain_mcelog_buffer();
 }
 EXPORT_SYMBOL_GPL(mce_register_decode_chain);
 
@@ -462,61 +470,6 @@ static inline void mce_gather_info(struct mce *m, struct 
pt_regs *regs)
}
 }
 
-/*
- * Simple lockless ring to communicate PFNs from the exception handler with the
- * process context work function. This is vastly simplified because there's
- * only a single reader and a single writer.
- */
-#define MCE_RING_SIZE 16   /* we use one entry less */
-
-struct mce_ring {
-   unsigned short start;
-   unsigned short end;
-   unsigned long ring[MCE_RING_SIZE];
-};
-static DEFINE_PER_CPU(struct mce_ring, mce_ring);
-
-/* Runs with CPU affinity in workqueue */
-static int mce_ring_empty(void)
-{
-   struct mce_ring *r = this_cpu_ptr(&mce_ring);
-
-   return r->start == r->end;
-}
-
-static int mce_ring_get(unsigned long *pfn)
-{
-   struct mce_ring *r;
-   int ret = 0;
-
-   *pfn = 0;
-   get_cpu();
-   r = this_cpu_ptr(&mce_ring);
-   if (r->start == r->end)
-   goto out;
-   *pfn = r->ring[r->start];
-   r->start = (r->start + 1) % MCE_RING_SIZE;
-   ret = 1;
-out:
-   put_cpu();
-   return ret;
-}
-
-/* Always runs in MCE context with preempt off */
-static int mce_ring_add(unsigned long pfn)
-{
-   struct mce_ring *r = this_cpu_ptr(&mce_ring);
-   unsigned next;
-
-   next = (r->end + 1) % MCE_RING_SIZE;
-   if (next == r->start)
-   return -1;
-   r->ring[r->end] = pfn;
-   wmb();
-   r->end = next;
-   return 0;
-}
-
 int mce_available(struct cpuinfo_x86 *c)
 {
if (mca_cfg.disabled)
@@ -526,7 +479,7 @@ int mce_available(struct cpuinfo_x86 *c)
 
 static void mce_schedule_work(void)
 {
-   if (!mce_ring_empty())
+   if (!mce_gen_pool_empty() && keventd_up())
schedule_work(&mce_work);
 }
 
@@ -553,6 +506,27 @@ static void mce_report_event(struct pt_regs *regs)
irq_work_queue(&mce_irq_work);
 }
 
+static int srao_decode_notifier(struct notifier_block *nb, unsigned long val,
+   void *data)
+{
+   struct mce *m

[tip:ras/core] x86/mce: Provide a lockless memory pool to save error records

2015-08-13 Thread tip-bot for Chen, Gong
Commit-ID:  648ed94038c030245a06e4be59744fd5cdc18c40
Gitweb: http://git.kernel.org/tip/648ed94038c030245a06e4be59744fd5cdc18c40
Author: Chen, Gong 
AuthorDate: Wed, 12 Aug 2015 18:29:34 +0200
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Aug 2015 10:12:50 +0200

x86/mce: Provide a lockless memory pool to save error records

printk() is not safe to use in MCE context. Add a lockless
memory allocator pool to save error records in MCE context.
Those records will be issued later, in a printk-safe context.
The idea is inspired by the APEI/GHES driver.

We're very conservative and allocate only two pages for it but
since we're going to use those pages throughout the system's
lifetime, we allocate them statically to avoid early boot time
allocation woes.

Signed-off-by: Chen, Gong 
[ Rewrite. ]
Signed-off-by: Borislav Petkov 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Tony Luck 
Link: http://lkml.kernel.org/r/1439396985-12812-3-git-send-email...@alien8.de
Signed-off-by: Ingo Molnar 
---
 arch/x86/Kconfig  |  1 +
 arch/x86/kernel/cpu/mcheck/Makefile   |  2 +-
 arch/x86/kernel/cpu/mcheck/mce-genpool.c  | 99 +++
 arch/x86/kernel/cpu/mcheck/mce-internal.h | 12 
 arch/x86/kernel/cpu/mcheck/mce.c  |  8 ++-
 5 files changed, 120 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index b3a1a5d..06dbb5d 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -955,6 +955,7 @@ config X86_REROUTE_FOR_BROKEN_BOOT_IRQS
 
 config X86_MCE
bool "Machine Check / overheating reporting"
+   select GENERIC_ALLOCATOR
default y
---help---
  Machine Check support allows the processor to notify the
diff --git a/arch/x86/kernel/cpu/mcheck/Makefile 
b/arch/x86/kernel/cpu/mcheck/Makefile
index bb34b03..a3311c8 100644
--- a/arch/x86/kernel/cpu/mcheck/Makefile
+++ b/arch/x86/kernel/cpu/mcheck/Makefile
@@ -1,4 +1,4 @@
-obj-y  =  mce.o mce-severity.o
+obj-y  =  mce.o mce-severity.o mce-genpool.o
 
 obj-$(CONFIG_X86_ANCIENT_MCE)  += winchip.o p5.o
 obj-$(CONFIG_X86_MCE_INTEL)+= mce_intel.o
diff --git a/arch/x86/kernel/cpu/mcheck/mce-genpool.c 
b/arch/x86/kernel/cpu/mcheck/mce-genpool.c
new file mode 100644
index 000..0a85010
--- /dev/null
+++ b/arch/x86/kernel/cpu/mcheck/mce-genpool.c
@@ -0,0 +1,99 @@
+/*
+ * MCE event pool management in MCE context
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * Author: Chen, Gong 
+ *
+ * This file is licensed under GPLv2.
+ */
+#include 
+#include 
+#include 
+#include 
+#include "mce-internal.h"
+
+/*
+ * printk() is not safe in MCE context. This is a lock-less memory allocator
+ * used to save error information organized in a lock-less list.
+ *
+ * This memory pool is only to be used to save MCE records in MCE context.
+ * MCE events are rare, so a fixed size memory pool should be enough. Use
+ * 2 pages to save MCE events for now (~80 MCE records at most).
+ */
+#define MCE_POOLSZ (2 * PAGE_SIZE)
+
+static struct gen_pool *mce_evt_pool;
+static LLIST_HEAD(mce_event_llist);
+static char gen_pool_buf[MCE_POOLSZ];
+
+void mce_gen_pool_process(void)
+{
+   struct llist_node *head;
+   struct mce_evt_llist *node;
+   struct mce *mce;
+
+   head = llist_del_all(&mce_event_llist);
+   if (!head)
+   return;
+
+   head = llist_reverse_order(head);
+   llist_for_each_entry(node, head, llnode) {
+   mce = &node->mce;
+   atomic_notifier_call_chain(&x86_mce_decoder_chain, 0, mce);
+   gen_pool_free(mce_evt_pool, (unsigned long)node, sizeof(*node));
+   }
+}
+
+bool mce_gen_pool_empty(void)
+{
+   return llist_empty(&mce_event_llist);
+}
+
+int mce_gen_pool_add(struct mce *mce)
+{
+   struct mce_evt_llist *node;
+
+   if (!mce_evt_pool)
+   return -EINVAL;
+
+   node = (void *)gen_pool_alloc(mce_evt_pool, sizeof(*node));
+   if (!node) {
+   pr_warn_ratelimited("MCE records pool full!\n");
+   return -ENOMEM;
+   }
+
+   memcpy(&node->mce, mce, sizeof(*mce));
+   llist_add(&node->llnode, &mce_event_llist);
+
+   return 0;
+}
+
+static int mce_gen_pool_create(void)
+{
+   struct gen_pool *tmpp;
+   int ret = -ENOMEM;
+
+   tmpp = gen_pool_create(ilog2(sizeof(struct mce_evt_llist)), -1);
+   if (!tmpp)
+   goto out;
+
+   ret = gen_pool_add(tmpp, (unsigned long)gen_pool_buf, MCE_POOLSZ, -1);
+   if (ret) {
+   gen_pool_destroy(tmpp);
+   goto out;
+   }
+
+   mce_evt_pool = tmpp;
+
+out:
+   return ret;
+}
+
+int mce_gen_pool_init(void)
+{
+   /* Just init mce_gen_pool once. */
+   if (mce_evt_pool)
+   return 0;
+
+   return mce_gen_pool_create();
+}
diff --git a/arch/x86/k

[tip:ras/core] x86/mce: Don't use percpu workqueues

2015-08-13 Thread tip-bot for Chen, Gong
Commit-ID:  061120aed7081b9a4393fbe07b558192f40ad911
Gitweb: http://git.kernel.org/tip/061120aed7081b9a4393fbe07b558192f40ad911
Author: Chen, Gong 
AuthorDate: Wed, 12 Aug 2015 18:29:35 +0200
Committer:  Ingo Molnar 
CommitDate: Thu, 13 Aug 2015 10:12:51 +0200

x86/mce: Don't use percpu workqueues

An MCE is a rare event. Therefore, there's no need to have
per-CPU instances of both normal and IRQ workqueues. Make them
both global.

Signed-off-by: Chen, Gong 
[ Fold in subsequent patch from Rui/Boris/Tony for early boot logging. ]
Signed-off-by: Tony Luck 
[ Massage commit message. ]
Signed-off-by: Borislav Petkov 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/1439396985-12812-4-git-send-email...@alien8.de
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/cpu/mcheck/mce.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index a41c014..456f8d7 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -110,7 +110,8 @@ DEFINE_PER_CPU(mce_banks_t, mce_poll_banks) = {
  */
 mce_banks_t mce_banks_ce_disabled;
 
-static DEFINE_PER_CPU(struct work_struct, mce_work);
+static struct work_struct mce_work;
+static struct irq_work mce_irq_work;
 
 static void (*quirk_no_way_out)(int bank, struct mce *m, struct pt_regs *regs);
 
@@ -526,11 +527,9 @@ int mce_available(struct cpuinfo_x86 *c)
 static void mce_schedule_work(void)
 {
if (!mce_ring_empty())
-   schedule_work(this_cpu_ptr(&mce_work));
+   schedule_work(&mce_work);
 }
 
-static DEFINE_PER_CPU(struct irq_work, mce_irq_work);
-
 static void mce_irq_work_cb(struct irq_work *entry)
 {
mce_notify_irq();
@@ -551,7 +550,7 @@ static void mce_report_event(struct pt_regs *regs)
return;
}
 
-   irq_work_queue(this_cpu_ptr(&mce_irq_work));
+   irq_work_queue(&mce_irq_work);
 }
 
 /*
@@ -1742,8 +1741,6 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
__mcheck_cpu_init_generic();
__mcheck_cpu_init_vendor(c);
__mcheck_cpu_init_timer();
-   INIT_WORK(this_cpu_ptr(&mce_work), mce_process_work);
-   init_irq_work(this_cpu_ptr(&mce_irq_work), &mce_irq_work_cb);
 }
 
 /*
@@ -2064,6 +2061,9 @@ int __init mcheck_init(void)
mcheck_intel_therm_init();
mcheck_vendor_init_severity();
 
+   INIT_WORK(&mce_work, mce_process_work);
+   init_irq_work(&mce_irq_work, mce_irq_work_cb);
+
return 0;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 4/4 Rebase] x86, MCE: Avoid potential deadlock in MCE context

2015-05-22 Thread Chen, Gong
On Wed, May 20, 2015 at 11:28:00AM +0200, Borislav Petkov wrote:
> Date: Wed, 20 May 2015 11:28:00 +0200
> From: Borislav Petkov 
> To: "Chen, Gong" , tony.l...@intel.com
> Cc: linux-kernel@vger.kernel.org
> Subject: Re: [PATCH 4/4 Rebase] x86, MCE: Avoid potential deadlock in MCE
>  context
> User-Agent: Mutt/1.5.23 (2014-03-12)
> 
> On Wed, May 20, 2015 at 03:35:38PM -0400, Chen, Gong wrote:
> > Printing in MCE context is a no-no, currently, as printk is not
> > NMI-safe. If some of the notifiers on the MCE chain call *printk*, we
> > may deadlock. In order to avoid that, delay printk into process context
> > to fix it.
> > 
> > Background info at: https://lkml.org/lkml/2014/6/27/26
> > 
> > Reported-by: Xie XiuQi 
> > Signed-off-by: Chen, Gong 
> > Link: 
> > http://lkml.kernel.org/r/1406797523-28710-6-git-send-email-gong.c...@linux.intel.com
> > [ Boris: rewrite a bit. ]
> > Signed-off-by: Borislav Petkov 
> > ---
> >  arch/x86/include/asm/mce.h   | 1 +
> >  arch/x86/kernel/cpu/mcheck/mce-apei.c| 2 +-
> >  arch/x86/kernel/cpu/mcheck/mce.c | 8 ++--
> >  arch/x86/kernel/cpu/mcheck/mce_intel.c   | 1 -
> >  arch/x86/kernel/cpu/mcheck/therm_throt.c | 1 +
> >  arch/x86/kernel/cpu/mcheck/threshold.c   | 1 +
> >  6 files changed, 10 insertions(+), 4 deletions(-)
> 
> 
> 
> > diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c 
> > b/arch/x86/kernel/cpu/mcheck/therm_throt.c
> > index 1af51b1586d7..2733f275237d 100644
> > --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
> > +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
> > @@ -427,6 +427,7 @@ static inline void __smp_thermal_interrupt(void)
> >  {
> > inc_irq_stat(irq_thermal_count);
> > smp_thermal_vector();
> > +   mce_queue_irq_work();
> 
> Hmm, at a second glance, this looks wrong. I think we should do that
> call in intel_thermal_interrupt().
> 
> >  asmlinkage __visible void smp_thermal_interrupt(struct pt_regs *regs)
> > diff --git a/arch/x86/kernel/cpu/mcheck/threshold.c 
> > b/arch/x86/kernel/cpu/mcheck/threshold.c
> > index 7245980186ee..d695faa234eb 100644
> > --- a/arch/x86/kernel/cpu/mcheck/threshold.c
> > +++ b/arch/x86/kernel/cpu/mcheck/threshold.c
> > @@ -22,6 +22,7 @@ static inline void __smp_threshold_interrupt(void)
> >  {
> > inc_irq_stat(irq_threshold_count);
> > mce_threshold_vector();
> > +   mce_queue_irq_work();
> 
> Same here.
> 
> mce_queue_irq_work() call should be issued in both AMD and Intel
> threshold handlers but not in the generic one which is unlikely to queue
> any MCE...
> 
> Right?
> 
Since AMD doesn't queue any MCE, it should definitely only cover Intel.
Please check out following patch:

8<
From: "Chen, Gong" 
Date: Fri, 22 May 2015 17:02:50 -0400
Subject: [PATCH 4/4 rebase v2] x86, MCE: Avoid potential deadlock in MCE context

Printing in MCE context is a no-no, currently, as printk is not
NMI-safe. If some of the notifiers on the MCE chain call *printk*, we
may deadlock. In order to avoid that, delay printk into process context
to fix it.

Background info at: https://lkml.org/lkml/2014/6/27/26

v2 -> v1: move mce_queue_irq_work call into Intel specific logic

Reported-by: Xie XiuQi 
Signed-off-by: Chen, Gong 
Link: 
http://lkml.kernel.org/r/1406797523-28710-6-git-send-email-gong.c...@linux.intel.com
[ Boris: rewrite a bit. ]
Signed-off-by: Borislav Petkov 
---
 arch/x86/include/asm/mce.h   | 1 +
 arch/x86/kernel/cpu/mcheck/mce-apei.c| 2 +-
 arch/x86/kernel/cpu/mcheck/mce.c | 8 ++--
 arch/x86/kernel/cpu/mcheck/mce_intel.c   | 2 +-
 arch/x86/kernel/cpu/mcheck/therm_throt.c | 2 ++
 5 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index d16f983f46f5..781432dd8123 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -198,6 +198,7 @@ enum mcp_flags {
 bool machine_check_poll(enum mcp_flags flags, mce_banks_t *b);
 
 int mce_notify_irq(void);
+void mce_queue_irq_work(void);
 
 DECLARE_PER_CPU(struct mce, injectm);
 
diff --git a/arch/x86/kernel/cpu/mcheck/mce-apei.c 
b/arch/x86/kernel/cpu/mcheck/mce-apei.c
index a1aef9533154..380e3ac8fb62 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-apei.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-apei.c
@@ -57,7 +57,7 @@ void apei_mce_report_mem_error(int severity, struct 
cper_sec_mem_err *mem_err)
 
m.addr = mem_err->physical_addr;
mce_log(&m);
-   mce_notify_irq();
+   mce_queue_irq_work();
 }
 EXPORT_SYMBOL_GPL(apei_mce_report_mem_error);
 
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index b369b

Re: [PATCH 1/4 Rebase] x86, MCE: Provide a lock-less memory pool to save error record

2015-05-22 Thread Chen, Gong
On Wed, May 20, 2015 at 12:36:10PM +0200, Borislav Petkov wrote:
> Date: Wed, 20 May 2015 12:36:10 +0200
> From: Borislav Petkov 
> To: "Chen, Gong" 
> Cc: linux-kernel@vger.kernel.org, tony.l...@intel.com
> Subject: Re: [PATCH 1/4 Rebase] x86, MCE: Provide a lock-less memory pool
>  to save error record
> User-Agent: Mutt/1.5.23 (2014-03-12)
> 
> On Wed, May 20, 2015 at 03:35:35PM -0400, Chen, Gong wrote:
> > printk is not safe to use in MCE context. Add a lockless memory
> > allocator pool to save error records in MCE context. Issual of those
> > records will be delayed to a context safe to do printk. This idea is
> > inspired by APEI/GHES driver.
> > 
> > We're very conservative and allocate only two pages for it but since
> > we're going to use those pages throughout the system's lifetime, we
> > allocate them statically to avoid early boot time allocation woes.
> > 
> > Signed-off-by: Chen, Gong 
> > Link: 
> > http://lkml.kernel.org/r/1407830375-11087-1-git-send-email-gong.c...@linux.intel.com
> > [Boris: rewrite. ]
> > Signed-off-by: Borislav Petkov 
> > ---
> >  arch/x86/Kconfig  |   1 +
> >  arch/x86/include/uapi/asm/mce.h   |   3 +-
> >  arch/x86/kernel/cpu/mcheck/Makefile   |   2 +-
> >  arch/x86/kernel/cpu/mcheck/mce-genpool.c  | 102 
> > ++
> >  arch/x86/kernel/cpu/mcheck/mce-internal.h |  12 
> >  arch/x86/kernel/cpu/mcheck/mce.c  |   8 ++-
> >  6 files changed, 125 insertions(+), 3 deletions(-)
> >  create mode 100644 arch/x86/kernel/cpu/mcheck/mce-genpool.c
> 
> Applied, thanks...
> 
> > diff --git a/arch/x86/kernel/cpu/mcheck/mce.c 
> > b/arch/x86/kernel/cpu/mcheck/mce.c
> > index e535533d5ab8..ba91777a7ad8 100644
> > --- a/arch/x86/kernel/cpu/mcheck/mce.c
> > +++ b/arch/x86/kernel/cpu/mcheck/mce.c
> > @@ -115,7 +115,7 @@ static void (*quirk_no_way_out)(int bank, struct mce 
> > *m, struct pt_regs *regs);
> >   * CPU/chipset specific EDAC code can register a notifier call here to 
> > print
> >   * MCE errors in a human-readable form.
> >   */
> > -static ATOMIC_NOTIFIER_HEAD(x86_mce_decoder_chain);
> > +ATOMIC_NOTIFIER_HEAD(x86_mce_decoder_chain);
> >  
> >  /* Do initial initialization of a struct mce */
> >  void mce_setup(struct mce *m)
> > @@ -1688,6 +1688,12 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
> > if (mca_cfg.disabled)
> > return;
> >  
> > +   if (mce_genpool_init()) {
> > +   mca_cfg.disabled = true;
> > +   pr_emerg("Couldn't allocate MCE records pool!\n");
> > +   return;
> > +   }
> > +
> > if (__mcheck_cpu_ancient_init(c))
> > return;
> 
> ... and moved this pool initialization right before we assign
> machine_check_vector so that we don't do it unnecessarily if we return
> earlier due to missing MCA features/MCA not enabled.
> 
IIRC, I don't need to post a new patch again, right?


signature.asc
Description: Digital signature


[PATCH 3/4 Rebase] x86, MCE: Remove mce_ring for SRAO error

2015-05-19 Thread Chen, Gong
Use unified genpool to save SRAO error events and put AO error
handling in the same notification chain with mce error decoding.

Signed-off-by: Chen, Gong 
Link: 
http://lkml.kernel.org/r/1406797523-28710-4-git-send-email-gong.c...@linux.intel.com
[ Boris: correct a lot. ]
Signed-off-by: Borislav Petkov 
---
 arch/x86/include/asm/mce.h   |   2 +-
 arch/x86/kernel/cpu/mcheck/mce.c | 115 ++-
 drivers/acpi/acpi_extlog.c   |   2 +-
 drivers/edac/i7core_edac.c   |   2 +-
 drivers/edac/mce_amd.c   |   2 +-
 drivers/edac/sb_edac.c   |   2 +-
 6 files changed, 47 insertions(+), 78 deletions(-)

diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index 1f5a86d518db..d16f983f46f5 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -123,7 +123,7 @@ struct mce_vendor_flags {
 extern struct mce_vendor_flags mce_flags;
 
 extern struct mca_config mca_cfg;
-extern void mce_register_decode_chain(struct notifier_block *nb);
+extern void mce_register_decode_chain(struct notifier_block *nb, bool drain);
 extern void mce_unregister_decode_chain(struct notifier_block *nb);
 
 #include 
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 6c064245f802..b369b5fcda1d 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -111,6 +111,7 @@ static struct work_struct mce_work;
 static struct irq_work mce_irq_work;
 
 static void (*quirk_no_way_out)(int bank, struct mce *m, struct pt_regs *regs);
+static int mce_usable_address(struct mce *m);
 
 /*
  * CPU/chipset specific EDAC code can register a notifier call here to print
@@ -231,11 +232,18 @@ static void drain_mcelog_buffer(void)
} while (next != prev);
 }
 
+static struct notifier_block mce_srao_nb;
 
-void mce_register_decode_chain(struct notifier_block *nb)
+void mce_register_decode_chain(struct notifier_block *nb, bool drain)
 {
+   /* Ensure SRAO notifier has the highest priority in the decode chain. */
+   if (nb != &mce_srao_nb && nb->priority == INT_MAX)
+   nb->priority -= 1;
+
atomic_notifier_chain_register(&x86_mce_decoder_chain, nb);
-   drain_mcelog_buffer();
+
+   if (drain)
+   drain_mcelog_buffer();
 }
 EXPORT_SYMBOL_GPL(mce_register_decode_chain);
 
@@ -459,61 +467,6 @@ static inline void mce_gather_info(struct mce *m, struct 
pt_regs *regs)
}
 }
 
-/*
- * Simple lockless ring to communicate PFNs from the exception handler with the
- * process context work function. This is vastly simplified because there's
- * only a single reader and a single writer.
- */
-#define MCE_RING_SIZE 16   /* we use one entry less */
-
-struct mce_ring {
-   unsigned short start;
-   unsigned short end;
-   unsigned long ring[MCE_RING_SIZE];
-};
-static DEFINE_PER_CPU(struct mce_ring, mce_ring);
-
-/* Runs with CPU affinity in workqueue */
-static int mce_ring_empty(void)
-{
-   struct mce_ring *r = this_cpu_ptr(&mce_ring);
-
-   return r->start == r->end;
-}
-
-static int mce_ring_get(unsigned long *pfn)
-{
-   struct mce_ring *r;
-   int ret = 0;
-
-   *pfn = 0;
-   get_cpu();
-   r = this_cpu_ptr(&mce_ring);
-   if (r->start == r->end)
-   goto out;
-   *pfn = r->ring[r->start];
-   r->start = (r->start + 1) % MCE_RING_SIZE;
-   ret = 1;
-out:
-   put_cpu();
-   return ret;
-}
-
-/* Always runs in MCE context with preempt off */
-static int mce_ring_add(unsigned long pfn)
-{
-   struct mce_ring *r = this_cpu_ptr(&mce_ring);
-   unsigned next;
-
-   next = (r->end + 1) % MCE_RING_SIZE;
-   if (next == r->start)
-   return -1;
-   r->ring[r->end] = pfn;
-   wmb();
-   r->end = next;
-   return 0;
-}
-
 int mce_available(struct cpuinfo_x86 *c)
 {
if (mca_cfg.disabled)
@@ -523,7 +476,7 @@ int mce_available(struct cpuinfo_x86 *c)
 
 static void mce_schedule_work(void)
 {
-   if (!mce_ring_empty())
+   if (!mce_genpool_empty())
schedule_work(&mce_work);
 }
 
@@ -550,6 +503,27 @@ static void mce_report_event(struct pt_regs *regs)
irq_work_queue(&mce_irq_work);
 }
 
+static int srao_decode_notifier(struct notifier_block *nb, unsigned long val,
+   void *data)
+{
+   struct mce *mce = (struct mce *)data;
+   unsigned long pfn;
+
+   if (!mce)
+   return NOTIFY_DONE;
+
+   if (mce->usable_addr && (mce->severity == MCE_AO_SEVERITY)) {
+   pfn = mce->addr >> PAGE_SHIFT;
+   memory_failure(pfn, MCE_VECTOR, 0);
+   }
+
+   return NOTIFY_OK;
+}
+static struct notifier_block mce_srao_nb = {
+   .notifier_call  = srao_decode_notifier,
+   .priority = INT_MAX,
+};
+
 /*
  * Read AD

[PATCH 1/4 Rebase] x86, MCE: Provide a lock-less memory pool to save error record

2015-05-19 Thread Chen, Gong
printk is not safe to use in MCE context. Add a lockless memory
allocator pool to save error records in MCE context. Issual of those
records will be delayed to a context safe to do printk. This idea is
inspired by APEI/GHES driver.

We're very conservative and allocate only two pages for it but since
we're going to use those pages throughout the system's lifetime, we
allocate them statically to avoid early boot time allocation woes.

Signed-off-by: Chen, Gong 
Link: 
http://lkml.kernel.org/r/1407830375-11087-1-git-send-email-gong.c...@linux.intel.com
[Boris: rewrite. ]
Signed-off-by: Borislav Petkov 
---
 arch/x86/Kconfig  |   1 +
 arch/x86/include/uapi/asm/mce.h   |   3 +-
 arch/x86/kernel/cpu/mcheck/Makefile   |   2 +-
 arch/x86/kernel/cpu/mcheck/mce-genpool.c  | 102 ++
 arch/x86/kernel/cpu/mcheck/mce-internal.h |  12 
 arch/x86/kernel/cpu/mcheck/mce.c  |   8 ++-
 6 files changed, 125 insertions(+), 3 deletions(-)
 create mode 100644 arch/x86/kernel/cpu/mcheck/mce-genpool.c

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index d43e7e1c784b..00c3395ed1c6 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -945,6 +945,7 @@ config X86_REROUTE_FOR_BROKEN_BOOT_IRQS
 
 config X86_MCE
bool "Machine Check / overheating reporting"
+   select GENERIC_ALLOCATOR
default y
---help---
  Machine Check support allows the processor to notify the
diff --git a/arch/x86/include/uapi/asm/mce.h b/arch/x86/include/uapi/asm/mce.h
index a0eab85ce7b8..577acacaf515 100644
--- a/arch/x86/include/uapi/asm/mce.h
+++ b/arch/x86/include/uapi/asm/mce.h
@@ -15,7 +15,8 @@ struct mce {
__u64 time; /* wall time_t when error was detected */
__u8  cpuvendor;/* cpu vendor as encoded in system.h */
__u8  inject_flags; /* software inject flags */
-   __u16  pad;
+   __u8  severity;
+   __u8  usable_addr;  /* addr is usable */
__u32 cpuid;/* CPUID 1 EAX */
__u8  cs;   /* code segment */
__u8  bank; /* machine check bank */
diff --git a/arch/x86/kernel/cpu/mcheck/Makefile 
b/arch/x86/kernel/cpu/mcheck/Makefile
index bb34b03af252..a3311c886194 100644
--- a/arch/x86/kernel/cpu/mcheck/Makefile
+++ b/arch/x86/kernel/cpu/mcheck/Makefile
@@ -1,4 +1,4 @@
-obj-y  =  mce.o mce-severity.o
+obj-y  =  mce.o mce-severity.o mce-genpool.o
 
 obj-$(CONFIG_X86_ANCIENT_MCE)  += winchip.o p5.o
 obj-$(CONFIG_X86_MCE_INTEL)+= mce_intel.o
diff --git a/arch/x86/kernel/cpu/mcheck/mce-genpool.c 
b/arch/x86/kernel/cpu/mcheck/mce-genpool.c
new file mode 100644
index ..742e187ace30
--- /dev/null
+++ b/arch/x86/kernel/cpu/mcheck/mce-genpool.c
@@ -0,0 +1,102 @@
+/*
+ * MCE event pool management in MCE context
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * Author: Chen, Gong 
+ *
+ * This file is licensed under GPLv2.
+ */
+#include 
+#include 
+#include 
+#include 
+#include "mce-internal.h"
+
+/*
+ * printk is not safe in MCE context thus a lock-less memory allocator
+ * (genpool) is used to save error information organized in a lock-less
+ * list.
+ */
+
+#define GENPOOL_BUFSZ  (2 * PAGE_SIZE)
+
+static struct gen_pool *mce_evt_pool;
+static LLIST_HEAD(mce_event_llist);
+static char genpool_buf[GENPOOL_BUFSZ];
+
+/*
+ * This memory pool is only to be used to save MCE records in MCE context.
+ * Since MCE events are rare so a fixed size memory pool should be enough.
+ * Keep 2 pages to save MCE events for now (~80 MCE records at most).
+ */
+static int mce_genpool_create(void)
+{
+   struct gen_pool *tmpp;
+   int ret = -ENOMEM;
+
+   tmpp = gen_pool_create(ilog2(sizeof(struct mce_evt_llist)), -1);
+   if (!tmpp)
+   goto out;
+
+   ret = gen_pool_add(tmpp, (unsigned long)genpool_buf, GENPOOL_BUFSZ, -1);
+   if (ret) {
+   gen_pool_destroy(tmpp);
+   goto out;
+   }
+
+   mce_evt_pool = tmpp;
+
+out:
+   return ret;
+}
+
+void mce_genpool_process(void)
+{
+   struct llist_node *head;
+   struct mce_evt_llist *node;
+   struct mce *mce;
+
+   head = llist_del_all(&mce_event_llist);
+   if (!head)
+   return;
+
+   head = llist_reverse_order(head);
+   llist_for_each_entry(node, head, llnode) {
+   mce = &node->mce;
+   atomic_notifier_call_chain(&x86_mce_decoder_chain, 0, mce);
+   gen_pool_free(mce_evt_pool, (unsigned long)node, sizeof(*node));
+   }
+}
+
+bool mce_genpool_empty(void)
+{
+   return llist_empty(&mce_event_llist);
+}
+
+bool mce_genpool_add(struct mce *mce)
+{
+   struct mce_evt_llist *node;
+
+   if (!mce_evt_pool)
+   return false;
+
+   node = (void *)gen_pool_alloc(mce_evt_pool, sizeof(*node));
+   if (!node) {
+   

[PATCH 4/4 Rebase] x86, MCE: Avoid potential deadlock in MCE context

2015-05-19 Thread Chen, Gong
Printing in MCE context is a no-no, currently, as printk is not
NMI-safe. If some of the notifiers on the MCE chain call *printk*, we
may deadlock. In order to avoid that, delay printk into process context
to fix it.

Background info at: https://lkml.org/lkml/2014/6/27/26

Reported-by: Xie XiuQi 
Signed-off-by: Chen, Gong 
Link: 
http://lkml.kernel.org/r/1406797523-28710-6-git-send-email-gong.c...@linux.intel.com
[ Boris: rewrite a bit. ]
Signed-off-by: Borislav Petkov 
---
 arch/x86/include/asm/mce.h   | 1 +
 arch/x86/kernel/cpu/mcheck/mce-apei.c| 2 +-
 arch/x86/kernel/cpu/mcheck/mce.c | 8 ++--
 arch/x86/kernel/cpu/mcheck/mce_intel.c   | 1 -
 arch/x86/kernel/cpu/mcheck/therm_throt.c | 1 +
 arch/x86/kernel/cpu/mcheck/threshold.c   | 1 +
 6 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index d16f983f46f5..781432dd8123 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -198,6 +198,7 @@ enum mcp_flags {
 bool machine_check_poll(enum mcp_flags flags, mce_banks_t *b);
 
 int mce_notify_irq(void);
+void mce_queue_irq_work(void);
 
 DECLARE_PER_CPU(struct mce, injectm);
 
diff --git a/arch/x86/kernel/cpu/mcheck/mce-apei.c 
b/arch/x86/kernel/cpu/mcheck/mce-apei.c
index a1aef9533154..380e3ac8fb62 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-apei.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-apei.c
@@ -57,7 +57,7 @@ void apei_mce_report_mem_error(int severity, struct 
cper_sec_mem_err *mem_err)
 
m.addr = mem_err->physical_addr;
mce_log(&m);
-   mce_notify_irq();
+   mce_queue_irq_work();
 }
 EXPORT_SYMBOL_GPL(apei_mce_report_mem_error);
 
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index b369b5fcda1d..a3be97961e22 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -156,7 +156,7 @@ void mce_log(struct mce *mce)
/* Emit the trace record: */
trace_mce_record(mce);
 
-   atomic_notifier_call_chain(&x86_mce_decoder_chain, 0, mce);
+   mce_genpool_add(mce);
 
mce->finished = 0;
wmb();
@@ -486,6 +486,11 @@ static void mce_irq_work_cb(struct irq_work *entry)
mce_schedule_work();
 }
 
+void mce_queue_irq_work(void)
+{
+   irq_work_queue(&mce_irq_work);
+}
+
 static void mce_report_event(struct pt_regs *regs)
 {
if (regs->flags & (X86_VM_MASK|X86_EFLAGS_IF)) {
@@ -1105,7 +1110,6 @@ void do_machine_check(struct pt_regs *regs, long 
error_code)
/* assuming valid severity level != 0 */
m.severity = severity;
m.usable_addr = mce_usable_address(&m);
-   mce_genpool_add(&m);
 
mce_log(&m);
 
diff --git a/arch/x86/kernel/cpu/mcheck/mce_intel.c 
b/arch/x86/kernel/cpu/mcheck/mce_intel.c
index b4a41cf030ed..caf6b7e25768 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_intel.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_intel.c
@@ -216,7 +216,6 @@ static void intel_threshold_interrupt(void)
return;
 
machine_check_poll(MCP_TIMESTAMP, this_cpu_ptr(&mce_banks_owned));
-   mce_notify_irq();
 }
 
 /*
diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c 
b/arch/x86/kernel/cpu/mcheck/therm_throt.c
index 1af51b1586d7..2733f275237d 100644
--- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
@@ -427,6 +427,7 @@ static inline void __smp_thermal_interrupt(void)
 {
inc_irq_stat(irq_thermal_count);
smp_thermal_vector();
+   mce_queue_irq_work();
 }
 
 asmlinkage __visible void smp_thermal_interrupt(struct pt_regs *regs)
diff --git a/arch/x86/kernel/cpu/mcheck/threshold.c 
b/arch/x86/kernel/cpu/mcheck/threshold.c
index 7245980186ee..d695faa234eb 100644
--- a/arch/x86/kernel/cpu/mcheck/threshold.c
+++ b/arch/x86/kernel/cpu/mcheck/threshold.c
@@ -22,6 +22,7 @@ static inline void __smp_threshold_interrupt(void)
 {
inc_irq_stat(irq_threshold_count);
mce_threshold_vector();
+   mce_queue_irq_work();
 }
 
 asmlinkage __visible void smp_threshold_interrupt(void)
-- 
2.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4 Rebase] x86, MCE: Don't use percpu for MCE workqueue/irq_work

2015-05-19 Thread Chen, Gong
An MCE is considered a rare event. Therefore, there's no need to have
per-CPU instances of both normal and IRQ workqueues. Make them both
global.

Signed-off-by: Chen, Gong 
Link: 
http://lkml.kernel.org/r/1406797523-28710-3-git-send-email-gong.c...@linux.intel.com
[Boris: massage commit message]
Signed-off-by: Borislav Petkov 
---
 arch/x86/kernel/cpu/mcheck/mce.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index ba91777a7ad8..6c064245f802 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -107,7 +107,8 @@ DEFINE_PER_CPU(mce_banks_t, mce_poll_banks) = {
  */
 mce_banks_t mce_banks_ce_disabled;
 
-static DEFINE_PER_CPU(struct work_struct, mce_work);
+static struct work_struct mce_work;
+static struct irq_work mce_irq_work;
 
 static void (*quirk_no_way_out)(int bank, struct mce *m, struct pt_regs *regs);
 
@@ -523,11 +524,9 @@ int mce_available(struct cpuinfo_x86 *c)
 static void mce_schedule_work(void)
 {
if (!mce_ring_empty())
-   schedule_work(this_cpu_ptr(&mce_work));
+   schedule_work(&mce_work);
 }
 
-static DEFINE_PER_CPU(struct irq_work, mce_irq_work);
-
 static void mce_irq_work_cb(struct irq_work *entry)
 {
mce_notify_irq();
@@ -548,7 +547,7 @@ static void mce_report_event(struct pt_regs *regs)
return;
}
 
-   irq_work_queue(this_cpu_ptr(&mce_irq_work));
+   irq_work_queue(&mce_irq_work);
 }
 
 /*
@@ -1710,8 +1709,8 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
__mcheck_cpu_init_generic();
__mcheck_cpu_init_vendor(c);
__mcheck_cpu_init_timer();
-   INIT_WORK(this_cpu_ptr(&mce_work), mce_process_work);
-   init_irq_work(this_cpu_ptr(&mce_irq_work), &mce_irq_work_cb);
+   INIT_WORK(&mce_work, mce_process_work);
+   init_irq_work(&mce_irq_work, mce_irq_work_cb);
 }
 
 /*
-- 
2.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


MCE ring buffer management (Rebase)

2015-05-19 Thread Chen, Gong
[PATCH 1/4 Rebase] x86, MCE: Provide a lock-less memory pool to save error
[PATCH 2/4 Rebase] x86, MCE: Don't use percpu for MCE workqueue/irq_work
[PATCH 3/4 Rebase] x86, MCE: Remove mce_ring for SRAO error
[PATCH 4/4 Rebase] x86, MCE: Avoid potential deadlock in MCE context

We have too many rings for different H/W error events management.
All of them can be merged into one kind of unified mechanism.
Furthermore, this management mechanism should be reliable enough
even in MCE context to avoid deadlock like calling printk in MCE
context. This patch series is used for this purpose.

P.S. One of patch has been removed since last commit because it
has been merged already.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RESEND RFC 5/5] PCIe, AER: Update initial value of UC error mask

2014-09-09 Thread Chen, Gong
On Fri, Sep 05, 2014 at 05:34:21PM -0600, Bjorn Helgaas wrote:
> Date: Fri, 5 Sep 2014 17:34:21 -0600
> From: Bjorn Helgaas 
> To: "Chen, Gong" 
> Cc: rdun...@infradead.org, b...@alien8.de, tony.l...@intel.com,
>  linux-...@vger.kernel.org, linux-kernel@vger.kernel.org
> Subject: Re: [RESEND RFC 5/5] PCIe, AER: Update initial value of UC error
>  mask
> User-Agent: Mutt/1.5.21 (2010-09-15)
> 
> On Wed, Aug 13, 2014 at 02:22:41AM -0400, Chen, Gong wrote:
> > In PCI-e SPEC r3.0, BIT 0 of Uncorrectable Error Status Register
> > is redefined and it has an explicit requirement that when writing
> > this field, a value of 1b is the only choice. So change previous
> > initial maks from 0 to 1.
> > 
> > Signed-off-by: Chen, Gong 
> > ---
> > NOTE: After scratching all use cases, this is the most obvious use
> > case to violate the SPEC. Most of use cases just read first and
> > then overwrite for clear purpose. Even so, such fix is obvious to
> > not compatiable with previous SPEC definition. Do we need a dirty
> > hack?
> > 
> >  arch/mips/pci/pci-octeon.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/mips/pci/pci-octeon.c b/arch/mips/pci/pci-octeon.c
> > index 59cccd95688b..f1bfdc201297 100644
> > --- a/arch/mips/pci/pci-octeon.c
> > +++ b/arch/mips/pci/pci-octeon.c
> > @@ -134,7 +134,7 @@ int pcibios_plat_dev_init(struct pci_dev *dev)
> >dconfig);
> > /* Enable reporting of all uncorrectable errors */
> > /* Uncorrectable Error Mask - turned on bits disable errors */
> > -   pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, 0);
> > +   pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, 1);
> 
> I see the text in the spec that says we should only write 1 to bit 0 (sec
> 7.10.3, for anybody following along).  It looks like that change was made
> between PCIe r1.0 and r1.1.  It would really be nice to have more context
> about why the change was made, because if there's hardware in the field
> that implements r1.0 behavior, this patch will change the way it works, and
> I don't know how to verify that is safe.
> 
> Does this actually change fix a problem?  If it fixes a problem that
> happens on real hardware, that's a much better reason to make a change than
> just to comply with the spec.
> 
> Sec 7.10.2 also says we should ignore the value of bit 0 in the
> Uncorrectable Error Status register, and I don't see any place where we
> follow that advice.
> 
That's why I mark this patch as RFC. As you mentioned above, these are my
concerns, too. I submit such a patch not for merging but throwing a potential
issue. As I noted above, I don't know if it is deserved to fix all affected
placed to comply with spec change. After all, no one reports such an
issue (or maybe have happened :-))


signature.asc
Description: Digital signature


Re: [RESEND 2/5] PCIe, AER: Replenish missed AER status bits for AER driver

2014-09-09 Thread Chen, Gong
On Fri, Sep 05, 2014 at 05:15:43PM -0600, Bjorn Helgaas wrote:
> Date: Fri, 5 Sep 2014 17:15:43 -0600
> From: Bjorn Helgaas 
> To: "Chen, Gong" 
> Cc: rdun...@infradead.org, b...@alien8.de, tony.l...@intel.com,
>  linux-...@vger.kernel.org, linux-kernel@vger.kernel.org
> Subject: Re: [RESEND 2/5] PCIe, AER: Replenish missed AER status bits for
>  AER driver
> User-Agent: Mutt/1.5.21 (2010-09-15)
> 
> On Wed, Aug 13, 2014 at 02:22:38AM -0400, Chen, Gong wrote:
> > Since commit 6c2b374d is commited, the capability of PCI-e AER
> > has changed a lot. This patch adds all missed CE/UC error bits
> > existed in PCI-e SPEC r3.0. Meanwhile, adjust the code format
> > to make it simpler to read/maintain.
> > 
> > Signed-off-by: Chen, Gong 
> > ---
> >  drivers/pci/pcie/aer/aerdrv_errprint.c | 60 
> > ++
> >  1 file changed, 25 insertions(+), 35 deletions(-)
> > 
> > diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c 
> > b/drivers/pci/pcie/aer/aerdrv_errprint.c
> > index 35d06e177917..5c4f7e252e5e 100644
> > --- a/drivers/pci/pcie/aer/aerdrv_errprint.c
> > +++ b/drivers/pci/pcie/aer/aerdrv_errprint.c
> > @@ -75,44 +75,34 @@ static const char *aer_error_layer[] = {
> >  };
> >  
> >  static const char *aer_correctable_error_string[] = {
> > -   "Receiver Error",   /* Bit Position 0   */
> > -   NULL,
> > -   NULL,
> > -   NULL,
> > -   NULL,
> > -   NULL,
> > -   "Bad TLP",  /* Bit Position 6   */
> > -   "Bad DLLP", /* Bit Position 7   */
> > -   "RELAY_NUM Rollover",   /* Bit Position 8   */
> > -   NULL,
> > -   NULL,
> > -   NULL,
> > -   "Replay Timer Timeout", /* Bit Position 12  */
> > -   "Advisory Non-Fatal",   /* Bit Position 13  */
> > +   [0] = "Receiver Error",
> > +   [6] = "Bad TLP",
> > +   [7] = "Bad DLLP",
> > +   [8] = "RELAY_NUM Rollover",
> > +   [12] = "Replay Timer Timeout",
> > +   [13] = "Advisory Non-Fatal Error",
> > +   [14] = "Corrected Internal Error",
> > +   [15] = "Header Log Overflow",
> 
> You replaced bare numbers with the existing #defines in the previous patch
> (thank you), but now we're adding them here.  I'm pretty sure you can use
> the #defines here, e.g.,
> 
> [PCI_ERR_COR_RCVR] = "Receiver Error",
Considering PCI_ERR_COR_* stuff are not BIT offset, I need a conversion like
[ilog2(PCI_ERR_COR_RCVR)] = "xxx". But in ras_event.h I need the same
conversion like aer_correctable_error_string[ilog2(PCI_ERR_COR_RCVR)]. It looks
like a little bit clumsy and suboptimal. I can add extra BIT definition in
include/uapi/linux/pci_regs.h like below:

#define  PCI_ERR_COR_RCVR   0x0001  /* Receiver Error Status */
+#define  PCI_ERR_COR_RCVR_BIT   ilog2(PCI_ERR_COR_RCVR)

or more direct way:
#define  PCI_ERR_COR_RCVR   0x0001  /* Receiver Error Status */
+#define  PCI_ERR_COR_RCVR_BIT   0

I can't find better method by now.
> 
> In fact, it would be really nice if you could figure out a way to have only
> one set of these strings.  Right now, we have the set in
As above implied, I can export aer_correctable_error_string etc.


signature.asc
Description: Digital signature


Re: [RESEND 0/5] PCIe, AER: Misc cleanup

2014-09-01 Thread Chen, Gong
On Wed, Aug 13, 2014 at 09:52:36PM -0400, Chen, Gong wrote:
> Date: Wed, 13 Aug 2014 21:52:36 -0400
> From: "Chen, Gong" 
> To: Bjorn Helgaas 
> Cc: Randy Dunlap , Borislav Petkov ,
>  Tony Luck , "linux-...@vger.kernel.org"
>  , "linux-kernel@vger.kernel.org"
>  
> Subject: Re: [RESEND 0/5] PCIe, AER: Misc cleanup
> User-Agent: Mutt/1.5.23 (2014-03-12)
> 
> On Wed, Aug 13, 2014 at 07:52:45AM -0600, Bjorn Helgaas wrote:
> > I haven't responded because I've been on vacation for the past three
> > weeks.  If there's no change in the patches themselves, and if they
> > are still in http://patchwork.ozlabs.org/project/linux-pci/list, the
> > only thing reposting them does is make more work for me.
> > 
> There is one difference existed in Patch 1. I add more explanation in
> the comments as Boris suggested.

Hi, Bjorn

Any comments?


signature.asc
Description: Digital signature


[PATCH v2 4/5] x86/mce: Simplify flow when handling recoverable memory errors

2014-08-14 Thread Chen, Gong
From: Tony Luck 

Handling of uncorrected, but s/w recoverable, errors is a two phase process:

1) In the machine check handler we identify the signature of a recoverable
   error and use TIF_MCE_NOTIFY to mark the process so that we will not
   return to ring3 and re-execute the instruction that accessed the failed
   memory location.
2) In process context we see TIF_MCE_NOTIFY set and call mce_notify_process()
   to do all the recovery work that we could not do in machine check context.

We need to pass the memory address and a flag to say whether the faulting
instruction can be continued from stage "1" to stage "2".  The existing
code to do this is baroque.  We hunt through a fixed sized array of
"mce_info" structures and use atomic_cmpxchg to claim a free one (we
panic if all are busy). Then in phase 2 we scan back through the mce_info
array looking for the one that matches the current process.

We can do much better by admitting that the failing address found in
phase 1 is a property of the current task. We can only recover from
errors detected while trying to retire an instruction in ring3 (s/w
limitation). So we know that MCE_AR_SEVERITY means that we are running
on the cpu that was executing user code and hit an error that triggered
this machine check.  This is the reason why TIF_MCE_NOTIFY has been set,
and the memory error must be dealt with before we can either allow this
process to continue (if we can replace the page) or not (signalling the
process if the memory has been lost).

So we add two fields to the task structure to be saved in phase 1 and
retrieved in phase 2.  The mce_info[] array and routines to add/find/clear
entried from it can all be deleted.

Gong: Add missed CONFIG_MEMORY_FAILURE & '\n' to the end of printk
message, while at it.

Signed-off-by: Tony Luck 
Signed-off-by: Chen, Gong 
Acked-by: Borislav Petkov 
---
 arch/x86/include/asm/mce.h   |  2 ++
 arch/x86/kernel/cpu/mcheck/mce.c | 67 +++-
 arch/x86/kernel/signal.c |  2 +-
 include/linux/sched.h|  4 +++
 4 files changed, 19 insertions(+), 56 deletions(-)

diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index a713dabd000b..76e706767655 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -187,7 +187,9 @@ enum mcp_flags {
 void machine_check_poll(enum mcp_flags flags, mce_banks_t *b);
 
 int mce_notify_irq(void);
+#ifdef CONFIG_MEMORY_FAILURE
 void mce_notify_process(void);
+#endif
 
 DECLARE_PER_CPU(struct mce, injectm);
 
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 0e64a3c69b2b..b0a25d5f7185 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -928,51 +928,6 @@ static void mce_clear_state(unsigned long *toclear)
 }
 
 /*
- * Need to save faulting physical address associated with a process
- * in the machine check handler some place where we can grab it back
- * later in mce_notify_process()
- */
-#defineMCE_INFO_MAX16
-
-struct mce_info {
-   atomic_tinuse;
-   struct task_struct  *t;
-   __u64   paddr;
-   int restartable;
-} mce_info[MCE_INFO_MAX];
-
-static void mce_save_info(__u64 addr, int c)
-{
-   struct mce_info *mi;
-
-   for (mi = mce_info; mi < &mce_info[MCE_INFO_MAX]; mi++) {
-   if (atomic_cmpxchg(&mi->inuse, 0, 1) == 0) {
-   mi->t = current;
-   mi->paddr = addr;
-   mi->restartable = c;
-   return;
-   }
-   }
-
-   mce_panic("Too many concurrent recoverable errors", NULL, NULL);
-}
-
-static struct mce_info *mce_find_info(void)
-{
-   struct mce_info *mi;
-
-   for (mi = mce_info; mi < &mce_info[MCE_INFO_MAX]; mi++)
-   if (atomic_read(&mi->inuse) && mi->t == current)
-   return mi;
-   return NULL;
-}
-
-static void mce_clear_info(struct mce_info *mi)
-{
-   atomic_set(&mi->inuse, 0);
-}
-
-/*
  * The actual machine check handler. This only handles real
  * exceptions when something got corrupted coming in through int 18.
  *
@@ -1121,11 +1076,15 @@ void do_machine_check(struct pt_regs *regs, long 
error_code)
if (cfg->tolerant < 3) {
if (no_way_out)
mce_panic("Fatal machine check on current CPU", &m, 
msg);
+#ifdef CONFIG_MEMORY_FAILURE
if (worst == MCE_AR_SEVERITY) {
/* schedule action before return to userland */
-   mce_save_info(m.addr, m.mcgstatus & MCG_STATUS_RIPV);
+   current->paddr = m.addr;
+   current->restartable = !!(m.mcgstatus & 
MCG_STATUS_RIPV);
  

[PATCH v2 3/5] x86, MCE: Remove mce_ring for SRAO error

2014-08-14 Thread Chen, Gong
Use unified genpool to save SRAO error events and put AO error
handling in the same notification chain with mce error decoding.

Signed-off-by: Chen, Gong 
Link: 
http://lkml.kernel.org/r/1406797523-28710-4-git-send-email-gong.c...@linux.intel.com
[ Boris: correct a lot. ]
Signed-off-by: Borislav Petkov 
---
 arch/x86/include/asm/mce.h   |   2 +-
 arch/x86/kernel/cpu/mcheck/mce.c | 110 ++-
 drivers/acpi/acpi_extlog.c   |   2 +-
 drivers/edac/i7core_edac.c   |   2 +-
 drivers/edac/mce_amd.c   |   2 +-
 drivers/edac/sb_edac.c   |   2 +-
 6 files changed, 43 insertions(+), 77 deletions(-)

diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index 958b90f761e5..a713dabd000b 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -114,7 +114,7 @@ struct mca_config {
 };
 
 extern struct mca_config mca_cfg;
-extern void mce_register_decode_chain(struct notifier_block *nb);
+extern void mce_register_decode_chain(struct notifier_block *nb, bool drain);
 extern void mce_unregister_decode_chain(struct notifier_block *nb);
 
 #include 
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 7534cfce43e9..0e64a3c69b2b 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -234,11 +234,18 @@ static void drain_mcelog_buffer(void)
} while (next != prev);
 }
 
+static struct notifier_block mce_srao_nb;
 
-void mce_register_decode_chain(struct notifier_block *nb)
+void mce_register_decode_chain(struct notifier_block *nb, bool drain)
 {
+   /* Ensure SRAO notifier has the highest priority in the decode chain. */
+   if (nb != &mce_srao_nb && nb->priority == INT_MAX)
+   nb->priority -= 1;
+
atomic_notifier_chain_register(&x86_mce_decoder_chain, nb);
-   drain_mcelog_buffer();
+
+   if (drain)
+   drain_mcelog_buffer();
 }
 EXPORT_SYMBOL_GPL(mce_register_decode_chain);
 
@@ -462,61 +469,6 @@ static inline void mce_gather_info(struct mce *m, struct 
pt_regs *regs)
}
 }
 
-/*
- * Simple lockless ring to communicate PFNs from the exception handler with the
- * process context work function. This is vastly simplified because there's
- * only a single reader and a single writer.
- */
-#define MCE_RING_SIZE 16   /* we use one entry less */
-
-struct mce_ring {
-   unsigned short start;
-   unsigned short end;
-   unsigned long ring[MCE_RING_SIZE];
-};
-static DEFINE_PER_CPU(struct mce_ring, mce_ring);
-
-/* Runs with CPU affinity in workqueue */
-static int mce_ring_empty(void)
-{
-   struct mce_ring *r = &__get_cpu_var(mce_ring);
-
-   return r->start == r->end;
-}
-
-static int mce_ring_get(unsigned long *pfn)
-{
-   struct mce_ring *r;
-   int ret = 0;
-
-   *pfn = 0;
-   get_cpu();
-   r = &__get_cpu_var(mce_ring);
-   if (r->start == r->end)
-   goto out;
-   *pfn = r->ring[r->start];
-   r->start = (r->start + 1) % MCE_RING_SIZE;
-   ret = 1;
-out:
-   put_cpu();
-   return ret;
-}
-
-/* Always runs in MCE context with preempt off */
-static int mce_ring_add(unsigned long pfn)
-{
-   struct mce_ring *r = &__get_cpu_var(mce_ring);
-   unsigned next;
-
-   next = (r->end + 1) % MCE_RING_SIZE;
-   if (next == r->start)
-   return -1;
-   r->ring[r->end] = pfn;
-   wmb();
-   r->end = next;
-   return 0;
-}
-
 int mce_available(struct cpuinfo_x86 *c)
 {
if (mca_cfg.disabled)
@@ -526,7 +478,7 @@ int mce_available(struct cpuinfo_x86 *c)
 
 static void mce_schedule_work(void)
 {
-   if (!mce_ring_empty())
+   if (!mce_genpool_empty())
schedule_work(&mce_work);
 }
 
@@ -553,6 +505,27 @@ static void mce_report_event(struct pt_regs *regs)
irq_work_queue(&mce_irq_work);
 }
 
+static int srao_decode_notifier(struct notifier_block *nb, unsigned long val,
+   void *data)
+{
+   struct mce *mce = (struct mce *)data;
+   unsigned long pfn;
+
+   if (!mce)
+   return NOTIFY_DONE;
+
+   if (mce->usable_addr && (mce->severity == MCE_AO_SEVERITY)) {
+   pfn = mce->addr >> PAGE_SHIFT;
+   memory_failure(pfn, MCE_VECTOR, 0);
+   }
+
+   return NOTIFY_OK;
+}
+static struct notifier_block mce_srao_nb = {
+   .notifier_call  = srao_decode_notifier,
+   .priority = INT_MAX,
+};
+
 /*
  * Read ADDR and MISC registers.
  */
@@ -1113,15 +1086,10 @@ void do_machine_check(struct pt_regs *regs, long 
error_code)
 
mce_read_aux(&m, i);
 
-   /*
-* Action optional error. Queue address for later processing.
-* When the ring overflows we just ignore the AO error.
-* RED-PEN add some loggin

[PATCH v2 2/5] x86, MCE: Don't use percpu for MCE workqueue/irq_work

2014-08-14 Thread Chen, Gong
An MCE is considered a rare event. Therefore, there's no need to have
per-CPU instances of both normal and IRQ workqueues. Make them both
global.

Signed-off-by: Chen, Gong 
Link: 
http://lkml.kernel.org/r/1406797523-28710-3-git-send-email-gong.c...@linux.intel.com
[Boris: massage commit message]
Signed-off-by: Borislav Petkov 
---
 arch/x86/kernel/cpu/mcheck/mce.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index b2c8bb83672a..7534cfce43e9 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -107,7 +107,8 @@ DEFINE_PER_CPU(mce_banks_t, mce_poll_banks) = {
  */
 mce_banks_t mce_banks_ce_disabled;
 
-static DEFINE_PER_CPU(struct work_struct, mce_work);
+static struct work_struct mce_work;
+static struct irq_work mce_irq_work;
 
 static void (*quirk_no_way_out)(int bank, struct mce *m, struct pt_regs *regs);
 
@@ -526,11 +527,9 @@ int mce_available(struct cpuinfo_x86 *c)
 static void mce_schedule_work(void)
 {
if (!mce_ring_empty())
-   schedule_work(&__get_cpu_var(mce_work));
+   schedule_work(&mce_work);
 }
 
-DEFINE_PER_CPU(struct irq_work, mce_irq_work);
-
 static void mce_irq_work_cb(struct irq_work *entry)
 {
mce_notify_irq();
@@ -551,7 +550,7 @@ static void mce_report_event(struct pt_regs *regs)
return;
}
 
-   irq_work_queue(&__get_cpu_var(mce_irq_work));
+   irq_work_queue(&mce_irq_work);
 }
 
 /*
@@ -1708,8 +1707,8 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
__mcheck_cpu_init_generic();
__mcheck_cpu_init_vendor(c);
__mcheck_cpu_init_timer();
-   INIT_WORK(&__get_cpu_var(mce_work), mce_process_work);
-   init_irq_work(&__get_cpu_var(mce_irq_work), &mce_irq_work_cb);
+   INIT_WORK(&mce_work, mce_process_work);
+   init_irq_work(&mce_irq_work, mce_irq_work_cb);
 }
 
 /*
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 5/5] x86, MCE: Avoid potential deadlock in MCE context

2014-08-14 Thread Chen, Gong
Printing in MCE context is a no-no, currently, as printk is not
NMI-safe. If some of the notifiers on the MCE chain call *printk*, we
may deadlock. In order to avoid that, delay printk into process context
to fix it.

Background info at: https://lkml.org/lkml/2014/6/27/26

Reported-by: Xie XiuQi 
Signed-off-by: Chen, Gong 
Link: 
http://lkml.kernel.org/r/1406797523-28710-6-git-send-email-gong.c...@linux.intel.com
[ Boris: rewrite a bit. ]
Signed-off-by: Borislav Petkov 
---
 arch/x86/include/asm/mce.h   |  1 +
 arch/x86/kernel/cpu/mcheck/mce-apei.c|  2 +-
 arch/x86/kernel/cpu/mcheck/mce.c | 11 ++-
 arch/x86/kernel/cpu/mcheck/mce_intel.c   |  2 +-
 arch/x86/kernel/cpu/mcheck/therm_throt.c |  1 +
 arch/x86/kernel/cpu/mcheck/threshold.c   |  1 +
 6 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index 76e706767655..be2ec2902830 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -187,6 +187,7 @@ enum mcp_flags {
 void machine_check_poll(enum mcp_flags flags, mce_banks_t *b);
 
 int mce_notify_irq(void);
+void mce_queue_irq_work(void);
 #ifdef CONFIG_MEMORY_FAILURE
 void mce_notify_process(void);
 #endif
diff --git a/arch/x86/kernel/cpu/mcheck/mce-apei.c 
b/arch/x86/kernel/cpu/mcheck/mce-apei.c
index a1aef9533154..380e3ac8fb62 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-apei.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-apei.c
@@ -57,7 +57,7 @@ void apei_mce_report_mem_error(int severity, struct 
cper_sec_mem_err *mem_err)
 
m.addr = mem_err->physical_addr;
mce_log(&m);
-   mce_notify_irq();
+   mce_queue_irq_work();
 }
 EXPORT_SYMBOL_GPL(apei_mce_report_mem_error);
 
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index b0a25d5f7185..c7ac50d8c4b5 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -151,14 +151,11 @@ static struct mce_log mcelog = {
 void mce_log(struct mce *mce)
 {
unsigned next, entry;
-   int ret = 0;
 
/* Emit the trace record: */
trace_mce_record(mce);
 
-   ret = atomic_notifier_call_chain(&x86_mce_decoder_chain, 0, mce);
-   if (ret == NOTIFY_STOP)
-   return;
+   mce_genpool_add(mce);
 
mce->finished = 0;
wmb();
@@ -488,6 +485,11 @@ static void mce_irq_work_cb(struct irq_work *entry)
mce_schedule_work();
 }
 
+void mce_queue_irq_work(void)
+{
+   irq_work_queue(&mce_irq_work);
+}
+
 static void mce_report_event(struct pt_regs *regs)
 {
if (regs->flags & (X86_VM_MASK|X86_EFLAGS_IF)) {
@@ -1044,7 +1046,6 @@ void do_machine_check(struct pt_regs *regs, long 
error_code)
/* assuming valid severity level != 0 */
m.severity = severity;
m.usable_addr = mce_usable_address(&m);
-   mce_genpool_add(&m);
 
mce_log(&m);
 
diff --git a/arch/x86/kernel/cpu/mcheck/mce_intel.c 
b/arch/x86/kernel/cpu/mcheck/mce_intel.c
index 3bdb95ae8c43..ec2cf614152e 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_intel.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_intel.c
@@ -195,8 +195,8 @@ static void intel_threshold_interrupt(void)
 {
if (cmci_storm_detect())
return;
+
machine_check_poll(MCP_TIMESTAMP, &__get_cpu_var(mce_banks_owned));
-   mce_notify_irq();
 }
 
 /*
diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c 
b/arch/x86/kernel/cpu/mcheck/therm_throt.c
index 36a1bb6d1ee0..d100e2bb8ed7 100644
--- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
@@ -427,6 +427,7 @@ static inline void __smp_thermal_interrupt(void)
 {
inc_irq_stat(irq_thermal_count);
smp_thermal_vector();
+   mce_queue_irq_work();
 }
 
 asmlinkage __visible void smp_thermal_interrupt(struct pt_regs *regs)
diff --git a/arch/x86/kernel/cpu/mcheck/threshold.c 
b/arch/x86/kernel/cpu/mcheck/threshold.c
index 7245980186ee..d695faa234eb 100644
--- a/arch/x86/kernel/cpu/mcheck/threshold.c
+++ b/arch/x86/kernel/cpu/mcheck/threshold.c
@@ -22,6 +22,7 @@ static inline void __smp_threshold_interrupt(void)
 {
inc_irq_stat(irq_threshold_count);
mce_threshold_vector();
+   mce_queue_irq_work();
 }
 
 asmlinkage __visible void smp_threshold_interrupt(void)
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 1/5] x86, MCE: Provide a lock-less memory pool to save error record

2014-08-14 Thread Chen, Gong
printk is not safe to use in MCE context. Add a lockless memory
allocator pool to save error records in MCE context. Issuing those
records will be delayed to a context safe to do printk. This idea is
inspired by APEI/GHES driver.

We're very conservative and allocate only two pages for it but since
we're going to use those pages throughout the system's lifetime, we
allocate them statically to avoid early boot time allocation woes.

Signed-off-by: Chen, Gong 
Link: 
http://lkml.kernel.org/r/1407830375-11087-1-git-send-email-gong.c...@linux.intel.com
[Boris: rewrite. ]
Signed-off-by: Borislav Petkov 
---
 arch/x86/Kconfig  |   1 +
 arch/x86/include/uapi/asm/mce.h   |   3 +-
 arch/x86/kernel/cpu/mcheck/Makefile   |   2 +-
 arch/x86/kernel/cpu/mcheck/mce-genpool.c  | 102 ++
 arch/x86/kernel/cpu/mcheck/mce-internal.h |  11 
 arch/x86/kernel/cpu/mcheck/mce.c  |   6 ++
 6 files changed, 123 insertions(+), 2 deletions(-)
 create mode 100644 arch/x86/kernel/cpu/mcheck/mce-genpool.c

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 4aafd322e21e..706dc3c8f6d6 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -866,6 +866,7 @@ config X86_REROUTE_FOR_BROKEN_BOOT_IRQS
 
 config X86_MCE
bool "Machine Check / overheating reporting"
+   select GENERIC_ALLOCATOR
default y
---help---
  Machine Check support allows the processor to notify the
diff --git a/arch/x86/include/uapi/asm/mce.h b/arch/x86/include/uapi/asm/mce.h
index a0eab85ce7b8..577acacaf515 100644
--- a/arch/x86/include/uapi/asm/mce.h
+++ b/arch/x86/include/uapi/asm/mce.h
@@ -15,7 +15,8 @@ struct mce {
__u64 time; /* wall time_t when error was detected */
__u8  cpuvendor;/* cpu vendor as encoded in system.h */
__u8  inject_flags; /* software inject flags */
-   __u16  pad;
+   __u8  severity;
+   __u8  usable_addr;  /* addr is usable */
__u32 cpuid;/* CPUID 1 EAX */
__u8  cs;   /* code segment */
__u8  bank; /* machine check bank */
diff --git a/arch/x86/kernel/cpu/mcheck/Makefile 
b/arch/x86/kernel/cpu/mcheck/Makefile
index bb34b03af252..a3311c886194 100644
--- a/arch/x86/kernel/cpu/mcheck/Makefile
+++ b/arch/x86/kernel/cpu/mcheck/Makefile
@@ -1,4 +1,4 @@
-obj-y  =  mce.o mce-severity.o
+obj-y  =  mce.o mce-severity.o mce-genpool.o
 
 obj-$(CONFIG_X86_ANCIENT_MCE)  += winchip.o p5.o
 obj-$(CONFIG_X86_MCE_INTEL)+= mce_intel.o
diff --git a/arch/x86/kernel/cpu/mcheck/mce-genpool.c 
b/arch/x86/kernel/cpu/mcheck/mce-genpool.c
new file mode 100644
index ..a0a0ad4b8778
--- /dev/null
+++ b/arch/x86/kernel/cpu/mcheck/mce-genpool.c
@@ -0,0 +1,102 @@
+/*
+ * MCE event pool management in MCE context
+ *
+ * Copyright (C) 2014 Intel Corp.
+ * Author: Chen, Gong 
+ *
+ * This file is licensed under GPLv2.
+ */
+#include 
+#include 
+#include 
+#include 
+#include "mce-internal.h"
+
+/*
+ * printk is not safe in MCE context thus a lock-less memory allocator
+ * (genpool) is used to save error information organized in a lock-less
+ * list.
+ */
+
+#define GENPOOL_BUFSZ  (2 * PAGE_SIZE)
+
+static struct gen_pool *mce_evt_pool;
+static LLIST_HEAD(mce_event_llist);
+static char genpool_buf[GENPOOL_BUFSZ];
+
+/*
+ * This memory pool is only to be used to save MCE records in MCE context.
+ * Since MCE events are rare so a fixed size memory pool should be enough.
+ * Keep 2 pages to save MCE events for now (~80 MCE records at most).
+ */
+static int mce_genpool_create(void)
+{
+   struct gen_pool *tmpp;
+   int ret = -ENOMEM;
+
+   tmpp = gen_pool_create(ilog2(sizeof(struct mce_evt_llist)), -1);
+   if (!tmpp)
+   goto out;
+
+   ret = gen_pool_add(tmpp, (unsigned long)genpool_buf, GENPOOL_BUFSZ, -1);
+   if (ret) {
+   gen_pool_destroy(tmpp);
+   goto out;
+   }
+
+   mce_evt_pool = tmpp;
+
+out:
+   return ret;
+}
+
+void mce_genpool_process(void)
+{
+   struct llist_node *head;
+   struct mce_evt_llist *node;
+   struct mce *mce;
+
+   head = llist_del_all(&mce_event_llist);
+   if (!head)
+   return;
+
+   head = llist_reverse_order(head);
+   llist_for_each_entry(node, head, llnode) {
+   mce = &node->mce;
+   atomic_notifier_call_chain(&x86_mce_decoder_chain, 0, mce);
+   gen_pool_free(mce_evt_pool, (unsigned long)node, sizeof(*node));
+   }
+}
+
+bool mce_genpool_empty(void)
+{
+   return llist_empty(&mce_event_llist);
+}
+
+bool mce_genpool_add(struct mce *mce)
+{
+   struct mce_evt_llist *node;
+
+   if (!mce_evt_pool)
+   return false;
+
+   node = (void *)gen_pool_alloc(mce_evt_pool, sizeof(*node));
+   if (!node) {
+   pr_warn_ratelimited(&

x86, MCE: MCE event ring management

2014-08-14 Thread Chen, Gong
We have too many rings for different H/W error events management.
All of them can be merged into one kind of unified mechanism.
Furthermore, this management mechanism should be reliable enough
even in MCE context to avoid deadlock like calling printk in MCE
context. This patch series is used for this purpose.

[PATCH v2 1/5] x86, MCE: Provide a lock-less memory pool to save
[PATCH v2 2/5] x86, MCE: Don't use percpu for MCE workqueue/irq_work
[PATCH v2 3/5] x86, MCE: Remove mce_ring for SRAO error
[PATCH v2 4/5] x86/mce: Simplify flow when handling recoverable
[PATCH v2 5/5] x86, MCE: Avoid potential deadlock in MCE context

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RESEND 0/5] PCIe, AER: Misc cleanup

2014-08-13 Thread Chen, Gong
On Wed, Aug 13, 2014 at 07:52:45AM -0600, Bjorn Helgaas wrote:
> I haven't responded because I've been on vacation for the past three
> weeks.  If there's no change in the patches themselves, and if they
> are still in http://patchwork.ozlabs.org/project/linux-pci/list, the
> only thing reposting them does is make more work for me.
> 
There is one difference existed in Patch 1. I add more explanation in
the comments as Boris suggested.


signature.asc
Description: Digital signature


[RESEND 3/5] PCIe, trace: Replenish missed AER status bits for PCIE trace I/F

2014-08-12 Thread Chen, Gong
This patch adds all missed AER error bits(CE & UC) existed in PCI-e
SPEC r3.0 for trace interface.

Signed-off-by: Chen, Gong 
---
 include/ras/ras_event.h | 35 ++-
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h
index 0f2cca4ccbf0..0f04a9755d1e 100644
--- a/include/ras/ras_event.h
+++ b/include/ras/ras_event.h
@@ -174,25 +174,34 @@ TRACE_EVENT(mc_event,
  * u8 severity -   error severity 0:NONFATAL 1:FATAL 2:CORRECTED
  */
 
-#define aer_correctable_errors \
-   {PCI_ERR_COR_RCVR,  "Receiver Error"},  \
-   {PCI_ERR_COR_BAD_TLP,   "Bad TLP"}, \
-   {PCI_ERR_COR_BAD_DLLP,  "Bad DLLP"},\
-   {PCI_ERR_COR_REP_ROLL,  "RELAY_NUM Rollover"},  \
-   {PCI_ERR_COR_REP_TIMER, "Replay Timer Timeout"},\
-   {PCI_ERR_COR_ADV_NFAT,  "Advisory Non-Fatal"}
-
-#define aer_uncorrectable_errors   \
-   {PCI_ERR_UNC_DLP,   "Data Link Protocol"},  \
+#define aer_correctable_errors \
+   {PCI_ERR_COR_RCVR,  "Receiver Error"},  \
+   {PCI_ERR_COR_BAD_TLP,   "Bad TLP"}, \
+   {PCI_ERR_COR_BAD_DLLP,  "Bad DLLP"},\
+   {PCI_ERR_COR_REP_ROLL,  "RELAY_NUM Rollover"},  \
+   {PCI_ERR_COR_REP_TIMER, "Replay Timer Timeout"},\
+   {PCI_ERR_COR_ADV_NFAT,  "Advisory Non-Fatal Error"},\
+   {PCI_ERR_COR_INTERNAL,  "Corrected Internal Error"},\
+   {PCI_ERR_COR_LOG_OVER,  "Header Log Overflow"}
+
+#define aer_uncorrectable_errors   \
+   {PCI_ERR_UNC_TRAIN, "Undefined"},   \
+   {PCI_ERR_UNC_DLP,   "Data Link Protocol Error"},\
+   {PCI_ERR_UNC_SURPDN,"Surprise Down Error"}, \
{PCI_ERR_UNC_POISON_TLP,"Poisoned TLP"},\
-   {PCI_ERR_UNC_FCP,   "Flow Control Protocol"},   \
+   {PCI_ERR_UNC_FCP,   "Flow Control Protocol Error"}, \
{PCI_ERR_UNC_COMP_TIME, "Completion Timeout"},  \
{PCI_ERR_UNC_COMP_ABORT,"Completer Abort"}, \
{PCI_ERR_UNC_UNX_COMP,  "Unexpected Completion"},   \
{PCI_ERR_UNC_RX_OVER,   "Receiver Overflow"},   \
{PCI_ERR_UNC_MALF_TLP,  "Malformed TLP"},   \
-   {PCI_ERR_UNC_ECRC,  "ECRC"},\
-   {PCI_ERR_UNC_UNSUP, "Unsupported Request"}
+   {PCI_ERR_UNC_ECRC,  "ECRC Error"},  \
+   {PCI_ERR_UNC_UNSUP, "Unsupported Request Error"},   \
+   {PCI_ERR_UNC_ACSV,  "ACS Violation"},   \
+   {PCI_ERR_UNC_INTN,  "Uncorrectable Internal Error"},\
+   {PCI_ERR_UNC_MCBTLP,"MC Blocked TLP"},  \
+   {PCI_ERR_UNC_ATOMEG,"AtomicOp Egress Blocked"}, \
+   {PCI_ERR_UNC_TLPPRE,"TLP Prefix Blocked Error"}
 
 TRACE_EVENT(aer_event,
TP_PROTO(const char *dev_name,
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND RFC 5/5] PCIe, AER: Update initial value of UC error mask

2014-08-12 Thread Chen, Gong
In PCI-e SPEC r3.0, BIT 0 of Uncorrectable Error Status Register
is redefined and it has an explicit requirement that when writing
this field, a value of 1b is the only choice. So change previous
initial maks from 0 to 1.

Signed-off-by: Chen, Gong 
---
NOTE: After scratching all use cases, this is the most obvious use
case to violate the SPEC. Most of use cases just read first and
then overwrite for clear purpose. Even so, such fix is obvious to
not compatiable with previous SPEC definition. Do we need a dirty
hack?

 arch/mips/pci/pci-octeon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/pci/pci-octeon.c b/arch/mips/pci/pci-octeon.c
index 59cccd95688b..f1bfdc201297 100644
--- a/arch/mips/pci/pci-octeon.c
+++ b/arch/mips/pci/pci-octeon.c
@@ -134,7 +134,7 @@ int pcibios_plat_dev_init(struct pci_dev *dev)
   dconfig);
/* Enable reporting of all uncorrectable errors */
/* Uncorrectable Error Mask - turned on bits disable errors */
-   pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, 0);
+   pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, 1);
/*
 * Leave severity at HW default. This only controls if
 * errors are reported as uncorrectable or
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND 4/5] PCIe, AER: Make AER UC status naming clearer

2014-08-12 Thread Chen, Gong
In PCI-e SPEC r3.0, BIT 0 of Uncorrectable Error Status Register
has been redefined for a different purpose.

BIT 0:
Undefined ??? The value read from this bit is undefined. In
previous versions of this specification, this
bit was used to mask a Link Training Error.
System software must ignore the value read from
this bit. System software must only write a value
of 1b to this bit.

Update related MACRO definition to reflect this change.

Signed-off-by: Chen, Gong 
---
 drivers/vfio/pci/vfio_pci_config.c | 2 +-
 include/ras/ras_event.h| 2 +-
 include/uapi/linux/pci_regs.h  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/vfio/pci/vfio_pci_config.c 
b/drivers/vfio/pci/vfio_pci_config.c
index e50790e91f76..1de3f94aa7de 100644
--- a/drivers/vfio/pci/vfio_pci_config.c
+++ b/drivers/vfio/pci/vfio_pci_config.c
@@ -727,7 +727,7 @@ static int __init init_pci_ext_cap_err_perm(struct 
perm_bits *perm)
p_setd(perm, 0, ALL_VIRT, NO_WRITE);
 
/* Writable bits mask */
-   mask =  PCI_ERR_UNC_TRAIN | /* Training */
+   mask =  PCI_ERR_UNC_UND |   /* Undefined */
PCI_ERR_UNC_DLP |   /* Data Link Protocol */
PCI_ERR_UNC_SURPDN |/* Surprise Down */
PCI_ERR_UNC_POISON_TLP |/* Poisoned TLP */
diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h
index 0f04a9755d1e..79abb9c71772 100644
--- a/include/ras/ras_event.h
+++ b/include/ras/ras_event.h
@@ -185,7 +185,7 @@ TRACE_EVENT(mc_event,
{PCI_ERR_COR_LOG_OVER,  "Header Log Overflow"}
 
 #define aer_uncorrectable_errors   \
-   {PCI_ERR_UNC_TRAIN, "Undefined"},   \
+   {PCI_ERR_UNC_UND,   "Undefined"},   \
{PCI_ERR_UNC_DLP,   "Data Link Protocol Error"},\
{PCI_ERR_UNC_SURPDN,"Surprise Down Error"}, \
{PCI_ERR_UNC_POISON_TLP,"Poisoned TLP"},\
diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h
index 30db069bce62..99e3182f2c96 100644
--- a/include/uapi/linux/pci_regs.h
+++ b/include/uapi/linux/pci_regs.h
@@ -630,7 +630,7 @@
 
 /* Advanced Error Reporting */
 #define PCI_ERR_UNCOR_STATUS   4   /* Uncorrectable Error Status */
-#define  PCI_ERR_UNC_TRAIN 0x0001  /* Training */
+#define  PCI_ERR_UNC_UND   0x0001  /* Undefined */
 #define  PCI_ERR_UNC_DLP   0x0010  /* Data Link Protocol */
 #define  PCI_ERR_UNC_SURPDN0x0020  /* Surprise Down */
 #define  PCI_ERR_UNC_POISON_TLP0x1000  /* Poisoned TLP */
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND 2/5] PCIe, AER: Replenish missed AER status bits for AER driver

2014-08-12 Thread Chen, Gong
Since commit 6c2b374d is commited, the capability of PCI-e AER
has changed a lot. This patch adds all missed CE/UC error bits
existed in PCI-e SPEC r3.0. Meanwhile, adjust the code format
to make it simpler to read/maintain.

Signed-off-by: Chen, Gong 
---
 drivers/pci/pcie/aer/aerdrv_errprint.c | 60 ++
 1 file changed, 25 insertions(+), 35 deletions(-)

diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c 
b/drivers/pci/pcie/aer/aerdrv_errprint.c
index 35d06e177917..5c4f7e252e5e 100644
--- a/drivers/pci/pcie/aer/aerdrv_errprint.c
+++ b/drivers/pci/pcie/aer/aerdrv_errprint.c
@@ -75,44 +75,34 @@ static const char *aer_error_layer[] = {
 };
 
 static const char *aer_correctable_error_string[] = {
-   "Receiver Error",   /* Bit Position 0   */
-   NULL,
-   NULL,
-   NULL,
-   NULL,
-   NULL,
-   "Bad TLP",  /* Bit Position 6   */
-   "Bad DLLP", /* Bit Position 7   */
-   "RELAY_NUM Rollover",   /* Bit Position 8   */
-   NULL,
-   NULL,
-   NULL,
-   "Replay Timer Timeout", /* Bit Position 12  */
-   "Advisory Non-Fatal",   /* Bit Position 13  */
+   [0] = "Receiver Error",
+   [6] = "Bad TLP",
+   [7] = "Bad DLLP",
+   [8] = "RELAY_NUM Rollover",
+   [12] = "Replay Timer Timeout",
+   [13] = "Advisory Non-Fatal Error",
+   [14] = "Corrected Internal Error",
+   [15] = "Header Log Overflow",
 };
 
 static const char *aer_uncorrectable_error_string[] = {
-   NULL,
-   NULL,
-   NULL,
-   NULL,
-   "Data Link Protocol",   /* Bit Position 4   */
-   NULL,
-   NULL,
-   NULL,
-   NULL,
-   NULL,
-   NULL,
-   NULL,
-   "Poisoned TLP", /* Bit Position 12  */
-   "Flow Control Protocol",/* Bit Position 13  */
-   "Completion Timeout",   /* Bit Position 14  */
-   "Completer Abort",  /* Bit Position 15  */
-   "Unexpected Completion",/* Bit Position 16  */
-   "Receiver Overflow",/* Bit Position 17  */
-   "Malformed TLP",/* Bit Position 18  */
-   "ECRC", /* Bit Position 19  */
-   "Unsupported Request",  /* Bit Position 20  */
+   [0] = "Undefined",
+   [4] = "Data Link Protocol Error",
+   [5] = "Surprise Down Error",
+   [12] = "Poisoned TLP",
+   [13] = "Flow Control Protocol Error",
+   [14] = "Completion Timeout",
+   [15] = "Completer Abort",
+   [16] = "Unexpected Completion",
+   [17] = "Receiver Overflow",
+   [18] = "Malformed TLP",
+   [19] = "ECRC Error",
+   [20] = "Unsupported Request Error",
+   [21] = "ACS Violation",
+   [22] = "Uncorrectable Internal Error",
+   [23] = "MC Blocked TLP",
+   [24] = "AtomicOp Egress Blocked",
+   [25] = "TLP Prefix Blocked Error",
 };
 
 static const char *aer_agent_string[] = {
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND 0/5] PCIe, AER: Misc cleanup

2014-08-12 Thread Chen, Gong

No response since last commit so spread it to a bigger range.

This patch series is for AER related cleanup & update based on PCIe
SPEC r3.0.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND 1/5] RAS, trace: Update error definition format

2014-08-12 Thread Chen, Gong
Previous format definition uses MACRO BIT(...), which is not very
maintainable as Bjorn mentioned before:
"I'd like to see all those "BIT(...)" things changed to use the #defines
that already exist in include/uapi/linux/pci_regs.h, e.g.,
PCI_ERR_COR_RCVR.  That way grep will find these uses, which will make
maintenance easier."

Now here it is.

Signed-off-by: Chen, Gong 
---
 include/ras/ras_event.h | 33 +
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h
index 47da53c27ffa..0f2cca4ccbf0 100644
--- a/include/ras/ras_event.h
+++ b/include/ras/ras_event.h
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -174,24 +175,24 @@ TRACE_EVENT(mc_event,
  */
 
 #define aer_correctable_errors \
-   {BIT(0),"Receiver Error"},  \
-   {BIT(6),"Bad TLP"}, \
-   {BIT(7),"Bad DLLP"},\
-   {BIT(8),"RELAY_NUM Rollover"},  \
-   {BIT(12),   "Replay Timer Timeout"},\
-   {BIT(13),   "Advisory Non-Fatal"}
+   {PCI_ERR_COR_RCVR,  "Receiver Error"},  \
+   {PCI_ERR_COR_BAD_TLP,   "Bad TLP"}, \
+   {PCI_ERR_COR_BAD_DLLP,  "Bad DLLP"},\
+   {PCI_ERR_COR_REP_ROLL,  "RELAY_NUM Rollover"},  \
+   {PCI_ERR_COR_REP_TIMER, "Replay Timer Timeout"},\
+   {PCI_ERR_COR_ADV_NFAT,  "Advisory Non-Fatal"}
 
 #define aer_uncorrectable_errors   \
-   {BIT(4),"Data Link Protocol"},  \
-   {BIT(12),   "Poisoned TLP"},\
-   {BIT(13),   "Flow Control Protocol"},   \
-   {BIT(14),   "Completion Timeout"},  \
-   {BIT(15),   "Completer Abort"}, \
-   {BIT(16),   "Unexpected Completion"},   \
-   {BIT(17),   "Receiver Overflow"},   \
-   {BIT(18),   "Malformed TLP"},   \
-   {BIT(19),   "ECRC"},\
-   {BIT(20),   "Unsupported Request"}
+   {PCI_ERR_UNC_DLP,   "Data Link Protocol"},  \
+   {PCI_ERR_UNC_POISON_TLP,"Poisoned TLP"},\
+   {PCI_ERR_UNC_FCP,   "Flow Control Protocol"},   \
+   {PCI_ERR_UNC_COMP_TIME, "Completion Timeout"},  \
+   {PCI_ERR_UNC_COMP_ABORT,"Completer Abort"}, \
+   {PCI_ERR_UNC_UNX_COMP,  "Unexpected Completion"},   \
+   {PCI_ERR_UNC_RX_OVER,   "Receiver Overflow"},   \
+   {PCI_ERR_UNC_MALF_TLP,  "Malformed TLP"},   \
+   {PCI_ERR_UNC_ECRC,  "ECRC"},\
+   {PCI_ERR_UNC_UNSUP, "Unsupported Request"}
 
 TRACE_EVENT(aer_event,
TP_PROTO(const char *dev_name,
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC PATCH v1 13/70] x86, x2apic_cluster: _FROZEN Cleanup

2014-07-31 Thread Chen, Gong
On Wed, Jul 30, 2014 at 10:48:52AM +0200, Borislav Petkov wrote:
> Date: Wed, 30 Jul 2014 10:48:52 +0200
> From: Borislav Petkov 
> To: "Chen, Gong" 
> Cc: linux-kernel@vger.kernel.org, mi...@kernel.org, t...@linutronix.de,
>  pau...@samba.org, b...@kernel.crashing.org, tony.l...@intel.com,
>  h...@zytor.com, jkos...@suse.cz, rafael.j.wyso...@intel.com,
>  li...@arm.linux.org.uk, r...@linux-mips.org, schwidef...@de.ibm.com,
>  da...@davemloft.net, v...@zeniv.linux.org.uk, fweis...@gmail.com,
>  c...@linux.com, a...@linux-foundation.org, ax...@kernel.dk,
>  jbottom...@parallels.com, ne...@suse.de, christoffer.d...@linaro.org,
>  rost...@goodmis.org, r...@kernel.org, gre...@linuxfoundation.org,
>  mho...@suse.cz, da...@fromorbit.com
> Subject: Re: [RFC PATCH v1 13/70] x86, x2apic_cluster: _FROZEN Cleanup
> User-Agent: Mutt/1.5.23 (2014-03-12)
> Well, look at the original code. What do you think happens if another
> _FROZEN action comes in which we don't handle in the switch-case?
> 
> Take a piece of paper and play it through slowly if you don't see it.
> Hint: err = 0.
> 
> > It looks like not quite comply with original logic. Once
> > new FROZEN logic is added, we have to update this code again. How
> > about using following code snippet:
> > 
> > +   if ((action & CPU_TASKS_FROZEN) &&
> > +   ((action & ~CPU_TASKS_FROZEN) == CPU_UP_CANCELED)) {
> > +   __update_clusterinfo(this_cpu);
> > +   return NOTIFY_OK;
> 
> No, this is different now from the original logic.
> 
I'm silly. You are right. I will use your patch directly(I should do
it at the beginning :-)).


signature.asc
Description: Digital signature


Re: [RFC PATCH v1 13/70] x86, x2apic_cluster: _FROZEN Cleanup

2014-07-29 Thread Chen, Gong
On Wed, Jul 23, 2014 at 10:36:28PM +0200, Borislav Petkov wrote:
>   /*
>* At CPU state changes, update the x2apic cluster sibling info.
>*/
> @@ -151,9 +166,14 @@ static int
>  update_clusterinfo(struct notifier_block *nfb, unsigned long action, void 
> *hcpu)
>  {
>   unsigned int this_cpu = (unsigned long)hcpu;
> - unsigned int cpu;
>   int err = 0;
>  
> + if (action & CPU_TASKS_FROZEN) {
> + if ((action & ~CPU_TASKS_FROZEN) == CPU_UP_CANCELED)
> + __update_clusterinfo(this_cpu);
> + return NOTIFY_OK;
> + }
> +
Hi, Boris

Here you assume once the action contains FROZEN flag, it will return
NOTIFY_OK. It looks like not quite comply with original logic. Once
new FROZEN logic is added, we have to update this code again. How
about using following code snippet:

+   if ((action & CPU_TASKS_FROZEN) &&
+   ((action & ~CPU_TASKS_FROZEN) == CPU_UP_CANCELED)) {
+   __update_clusterinfo(this_cpu);
+   return NOTIFY_OK;
+   }
+



signature.asc
Description: Digital signature


Re: [RFC PATCH v1 13/70] x86, x2apic_cluster: _FROZEN Cleanup

2014-07-29 Thread Chen, Gong
On Tue, Jul 29, 2014 at 10:44:33AM +0200, Borislav Petkov wrote:
> > switch (action) {
> > case CPU_UP_PREPARE:
> > if (!zalloc_cpumask_var(&per_cpu(cpus_in_cluster, this_cpu),
> > -   GFP_KERNEL)) {
> > +   GFP_KERNEL))
> > err = -ENOMEM;
> > -   } else if (!zalloc_cpumask_var(&per_cpu(ipi_mask, this_cpu),
> > -  GFP_KERNEL)) {
> > +   else if (!zalloc_cpumask_var(&per_cpu(ipi_mask, this_cpu),
> > +GFP_KERNEL)) {
> > free_cpumask_var(per_cpu(cpus_in_cluster, this_cpu));
> > err = -ENOMEM;
> 
> You need to start restraining yourself and doing clean patches. Those
> changes here are unrelated, please drop them.
> 
> Go and reread Documentation/SubmittingPatches, section 3 in particular.
> 
Copy that.

> > +   if (test_and_clear_bit(CPU_TASKS_FROZEN, &action) &&
> 
> What.. why?
> 
Sorry for that.


signature.asc
Description: Digital signature


Re: [RFC PATCH v1 14/70] x86, microcode, core: _FROZEN Cleanup

2014-07-27 Thread Chen, Gong
On Thu, Jul 24, 2014 at 11:03:03AM +0200, Borislav Petkov wrote:
> 
> Missing "break". We like to add those even if it doesn't matter in this
> case.
> 
> Also, add the boilerplate
> 
> "default:
>   break;"
> 
> while you're at it, please.
> 

8<
Subject: [RFC PATCH v2 14/70] x86, microcode, core: _FROZEN Cleanup

Remove XXX_FROZEN state from x86/microcode/core.

Signed-off-by: Chen, Gong 
Suggested-by: Borislav Petkov 
---
 arch/x86/kernel/cpu/microcode/core.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c 
b/arch/x86/kernel/cpu/microcode/core.c
index dd9d619..da3c2206 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -499,6 +499,11 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long 
action, void *hcpu)
pr_debug("CPU%d removed\n", cpu);
break;
 
+   case CPU_UP_CANCELED:
+   /* The CPU refused to come up during a system resume */
+   if (action & CPU_TASKS_FROZEN)
+   microcode_fini_cpu(cpu);
+   break;
/*
 * case CPU_DEAD:
 *
@@ -507,12 +512,10 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long 
action, void *hcpu)
 * CPU comes back online without unnecessarily requesting the userspace
 * for it again.
 */
+   default:
+   break;
}
 
-   /* The CPU refused to come up during a system resume */
-   if (action == CPU_UP_CANCELED_FROZEN)
-   microcode_fini_cpu(cpu);
-
return NOTIFY_OK;
 }
 
-- 
2.0.0.rc2


signature.asc
Description: Digital signature


Re: [RFC PATCH v1 13/70] x86, x2apic_cluster: _FROZEN Cleanup

2014-07-27 Thread Chen, Gong
On Wed, Jul 23, 2014 at 10:36:28PM +0200, Borislav Petkov wrote:
> Those checks dealing with CPU_TASKS_FROZEN in-between make the whole
> switch statement hard to follow.
> 
> How about we go a step further and deal with CPU_UP_CANCELED_FROZEN
> upfront and even simplify the rest:
> 

8<
Subject: [RFC PATCH v2 13/70] x86, x2apic_cluster: _FROZEN Cleanup

Remove XXX_FROZEN state from x86/x2apic_cluster.

Signed-off-by: Chen, Gong 
Suggested-by: Borislav Petkov 
---
 arch/x86/kernel/apic/x2apic_cluster.c | 37 +++
 1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/apic/x2apic_cluster.c 
b/arch/x86/kernel/apic/x2apic_cluster.c
index e66766b..b8a6ea8 100644
--- a/arch/x86/kernel/apic/x2apic_cluster.c
+++ b/arch/x86/kernel/apic/x2apic_cluster.c
@@ -144,6 +144,20 @@ static void init_x2apic_ldr(void)
}
 }
 
+static void __update_clusterinfo(unsigned int this_cpu)
+{
+   unsigned int cpu;
+
+   for_each_online_cpu(cpu) {
+   if (x2apic_cluster(this_cpu) != x2apic_cluster(cpu))
+   continue;
+   __cpu_clear(this_cpu, per_cpu(cpus_in_cluster, cpu));
+   __cpu_clear(cpu, per_cpu(cpus_in_cluster, this_cpu));
+   }
+   free_cpumask_var(per_cpu(cpus_in_cluster, this_cpu));
+   free_cpumask_var(per_cpu(ipi_mask, this_cpu));
+}
+
  /*
   * At CPU state changes, update the x2apic cluster sibling info.
   */
@@ -151,34 +165,31 @@ static int
 update_clusterinfo(struct notifier_block *nfb, unsigned long action, void 
*hcpu)
 {
unsigned int this_cpu = (unsigned long)hcpu;
-   unsigned int cpu;
int err = 0;
 
switch (action) {
case CPU_UP_PREPARE:
if (!zalloc_cpumask_var(&per_cpu(cpus_in_cluster, this_cpu),
-   GFP_KERNEL)) {
+   GFP_KERNEL))
err = -ENOMEM;
-   } else if (!zalloc_cpumask_var(&per_cpu(ipi_mask, this_cpu),
-  GFP_KERNEL)) {
+   else if (!zalloc_cpumask_var(&per_cpu(ipi_mask, this_cpu),
+GFP_KERNEL)) {
free_cpumask_var(per_cpu(cpus_in_cluster, this_cpu));
err = -ENOMEM;
}
break;
case CPU_UP_CANCELED:
-   case CPU_UP_CANCELED_FROZEN:
case CPU_DEAD:
-   for_each_online_cpu(cpu) {
-   if (x2apic_cluster(this_cpu) != x2apic_cluster(cpu))
-   continue;
-   __cpu_clear(this_cpu, per_cpu(cpus_in_cluster, cpu));
-   __cpu_clear(cpu, per_cpu(cpus_in_cluster, this_cpu));
-   }
-   free_cpumask_var(per_cpu(cpus_in_cluster, this_cpu));
-   free_cpumask_var(per_cpu(ipi_mask, this_cpu));
+   __update_clusterinfo(this_cpu);
+   break;
+   default:
break;
}
 
+   if (test_and_clear_bit(CPU_TASKS_FROZEN, &action) &&
+   (action == CPU_UP_CANCELED))
+   __update_clusterinfo(this_cpu);
+
return notifier_from_errno(err);
 }
 
-- 
2.0.0.rc2


signature.asc
Description: Digital signature


Re: [RFC PATCH v1 12/70] x86, pci, amd_bus: _FROZEN Cleanup

2014-07-27 Thread Chen, Gong
On Thu, Jul 24, 2014 at 10:28:47AM +0200, Borislav Petkov wrote:
> On Wed, Jul 23, 2014 at 09:31:30PM -0400, Chen, Gong wrote:
> > But what if new action is added? We have to change it back. If you
> > prefer to use that style I can update in next version.
> 
> Not likely. This functionality in amd_bus.c is not going to expand
> anyway but rather die with its last user, AFAICR.
> 

8<

Subject: [RFC PATCH v2 12/70] x86, pci, amd_bus: _FROZEN Cleanup

Remove XXX_FROZEN state from x86/pci/amd_bus.

Signed-off-by: Chen, Gong 
Suggested-by: Borislav Petkov 
---
 arch/x86/pci/amd_bus.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
index c20d2cc..2d7c6c6 100644
--- a/arch/x86/pci/amd_bus.c
+++ b/arch/x86/pci/amd_bus.c
@@ -340,15 +340,10 @@ static void enable_pci_io_ecs(void *unused)
 static int amd_cpu_notify(struct notifier_block *self, unsigned long action,
  void *hcpu)
 {
-   int cpu = (long)hcpu;
-   switch (action) {
-   case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
-   smp_call_function_single(cpu, enable_pci_io_ecs, NULL, 0);
-   break;
-   default:
-   break;
-   }
+   if ((action & ~CPU_TASKS_FROZEN) == CPU_ONLINE)
+   smp_call_function_single((long)hcpu, enable_pci_io_ecs,
+NULL, 0);
+
return NOTIFY_OK;
 }
 
-- 
2.0.0.rc2


signature.asc
Description: Digital signature


Re: [RESEND RFC PATCH v1 0/70] Gloabl CPU Hot-plug flag _FROZEN Clean up

2014-07-27 Thread Chen, Gong
On Fri, Jul 25, 2014 at 05:00:02PM +0200, Robert Richter wrote:
> > Back to long time ago (about 1.5 years), Thomas began the work
> > for CPU hot-plug, one first thing is CPU hotplug flag cleanup.
> > Paul hoped all the _FROZEN variants of the notifier actions
> > can be removed at that time. Now here it is.
> > 
> > Patch 1 ~ 69: remove all kinds of XXX_FROZEN usages
> > Patch 70: remove XXX_FROZEN from the kernel thoroughly
> 
> You might want to update Documentation/ as well.
> 
Thanks for your reminder. I don't do that intentionally because
1) This is RFC patch and I'm not sure if maintainers agree
to remove XXX_FROZEN thoroughtly
2) I have a little bit hesitation how to describe XXX_FROZEN
status after they are removed.

Anyway, I will do that in formal patch series. Thanks again!


signature.asc
Description: Digital signature


Re: [RESEND RFC PATCH v1 0/70] Gloabl CPU Hot-plug flag _FROZEN Clean up

2014-07-25 Thread Chen, Gong
On Fri, Jul 25, 2014 at 09:10:25AM +0200, Borislav Petkov wrote:
> On Thu, Jul 24, 2014 at 09:35:12PM -0400, Chen, Gong wrote:
> > Until now only Boris gave me some comments. Isn't interesting enough?
> > Or I head into wrong way? Please let me know. Sincere thanks for
> > everyone.
> 
> You're impatient. Give people some time, at least a week.
> 
> :-)
> 
> -- 
> Regards/Gruss,
> Boris.
> 
Oh, I see. So Sorry for that.


signature.asc
Description: Digital signature


Re: [RESEND RFC PATCH v1 0/70] Gloabl CPU Hot-plug flag _FROZEN Clean up

2014-07-24 Thread Chen, Gong
On Tue, Jul 22, 2014 at 09:58:36PM -0400, Chen, Gong wrote:
> Back to long time ago (about 1.5 years), Thomas began the work
> for CPU hot-plug, one first thing is CPU hotplug flag cleanup.
> Paul hoped all the _FROZEN variants of the notifier actions
> can be removed at that time. Now here it is.
> 
> Patch 1 ~ 69: remove all kinds of XXX_FROZEN usages
> Patch 70: remove XXX_FROZEN from the kernel thoroughly
> 
> Not sure if removing XXX_FROZEN flags thoroughly is overkilled.
> Fix me if I'm wrong.
> 
> P.S. My last post is banned because of the capital Triple-X in subject :-(
> 

Hi, maintainers

Until now only Boris gave me some comments. Isn't interesting enough? Or
I head into wrong way? Please let me know. Sincere thanks for everyone.



signature.asc
Description: Digital signature


Re: [RFC PATCH v1 12/70] x86, pci, amd_bus: _FROZEN Cleanup

2014-07-23 Thread Chen, Gong
On Wed, Jul 23, 2014 at 08:07:18PM +0200, Borislav Petkov wrote:
> Date: Wed, 23 Jul 2014 20:07:18 +0200
> From: Borislav Petkov 
> To: "Chen, Gong" 
> Cc: linux-kernel@vger.kernel.org, mi...@kernel.org, t...@linutronix.de,
>  pau...@samba.org, b...@kernel.crashing.org, tony.l...@intel.com,
>  h...@zytor.com, jkos...@suse.cz, rafael.j.wyso...@intel.com,
>  li...@arm.linux.org.uk, r...@linux-mips.org, schwidef...@de.ibm.com,
>  da...@davemloft.net, v...@zeniv.linux.org.uk, fweis...@gmail.com,
>  c...@linux.com, a...@linux-foundation.org, ax...@kernel.dk,
>  jbottom...@parallels.com, ne...@suse.de, christoffer.d...@linaro.org,
>  rost...@goodmis.org, r...@kernel.org, gre...@linuxfoundation.org,
>  mho...@suse.cz, da...@fromorbit.com
> Subject: Re: [RFC PATCH v1 12/70] x86, pci, amd_bus: _FROZEN Cleanup
> User-Agent: Mutt/1.5.23 (2014-03-12)
> 
> On Tue, Jul 22, 2014 at 09:58:48PM -0400, Chen, Gong wrote:
> > Remove XXX_FROZEN state from x86/pci/amd_bus.
> > 
> > Signed-off-by: Chen, Gong 
> > ---
> >  arch/x86/pci/amd_bus.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
> > index c20d2cc..30f0fca9 100644
> > --- a/arch/x86/pci/amd_bus.c
> > +++ b/arch/x86/pci/amd_bus.c
> > @@ -341,9 +341,8 @@ static int amd_cpu_notify(struct notifier_block *self, 
> > unsigned long action,
> >   void *hcpu)
> >  {
> > int cpu = (long)hcpu;
> > -   switch (action) {
> > +   switch (action & ~CPU_TASKS_FROZEN) {
> > case CPU_ONLINE:
> > -   case CPU_ONLINE_FROZEN:
> > smp_call_function_single(cpu, enable_pci_io_ecs, NULL, 0);
> > break;
> > default:
> 
> Or you can kill all the switch-case gunk and make it even more readable:
> 
But what if new action is added? We have to change it back. If you prefer
to use that style I can update in next version.


signature.asc
Description: Digital signature


[RESEND RFC PATCH v1 0/70] Gloabl CPU Hot-plug flag _FROZEN Clean up

2014-07-22 Thread Chen, Gong
Back to long time ago (about 1.5 years), Thomas began the work
for CPU hot-plug, one first thing is CPU hotplug flag cleanup.
Paul hoped all the _FROZEN variants of the notifier actions
can be removed at that time. Now here it is.

Patch 1 ~ 69: remove all kinds of XXX_FROZEN usages
Patch 70: remove XXX_FROZEN from the kernel thoroughly

Not sure if removing XXX_FROZEN flags thoroughly is overkilled.
Fix me if I'm wrong.

P.S. My last post is banned because of the capital Triple-X in subject :-(


Chen, Gong (69):
  ia64, err_inject: _FROZEN Cleanup
  ia64, mca: _FROZEN Cleanup
  ia64, palinfo: _FROZEN Cleanup
  ia64, salinfo: _FROZEN Cleanup
  ia64, topology: _FROZEN Cleanup
  x86, intel_cacheinfo: _FROZEN Cleanup
  x86, mce, therm_throt: _FROZEN Cleanup
  x86, mce_amd: _FROZEN Cleanup
  x86, kvm: _FROZEN Cleanup
  x86, vsyscall_64: _FROZEN Cleanup
  x86, pci, amd_bus: _FROZEN Cleanup
  x86, x2apic_cluster: _FROZEN Cleanup
  x86, microcode, core: _FROZEN Cleanup
  x86, kernel, cpuid: _FROZEN Cleanup
  x86, kernel, msr: _FROZEN Cleanup
  arm, vfp, vfpmodule: _FROZEN Cleanup
  arm, kvm: _FROZEN Cleanup
  powerpc, sysfs: _FROZEN Cleanup
  powerpc, mm, numa: _FROZEN Cleanup
  powerpc, powermac, smp: _FROZEN Cleanup
  powerpc, mmu_context_nohash: _FROZEN Cleanup
  mips, loongson, smp: _FROZEN Cleanup
  s390, perf_cpum_sf: _FROZEN Cleanup
  sparc, sysfs: _FROZEN Cleanup
  rcu, tree: _FROZEN Cleanup
  kernel, padata: _FROZEN Cleanup
  kernel, profile: _FROZEN Cleanup
  kernel, sched, core: _FROZEN Cleanup
  kernel, hrtimer: _FROZEN Cleanup
  kernel, relay: _FROZEN Cleanup
  kernel, smp: _FROZEN Cleanup
  kernel, timer: _FROZEN Cleanup
  kernel, softirq: _FROZEN Cleanup
  mm, slab: _FROZEN Cleanup
  mm, vmscan: _FROZEN Cleanup
  mm, vmstat: _FROZEN Cleanup
  mm, memcontrol: _FROZEN Cleanup
  mm, page_alloc: _FROZEN Cleanup
  mm, slub: _FROZEN Cleanup
  fs, buffer: _FROZEN Cleanup
  xfs, xfs_mount: _FROZEN Cleanup
  net, iucv: _FROZEN Cleanup
  net, core, flow: _FROZEN Cleanup
  net, core, dev: _FROZEN Cleanup
  block, blk-mq: _FROZEN Cleanup
  block, blk-iopoll: _FROZEN Cleanup
  block, blk-softirq: _FROZEN Cleanup
  driver, base, topology: _FROZEN Cleanup
  clocksource, metag_generic: _FROZEN Cleanup
  powercap, intel_rapl: _FROZEN Cleanup
  cpuidle, cpuidle-powernv: _FROZEN Cleanup
  cpuidle, cpuidle-pseries: _FROZEN Cleanup
  cpufreq, acpi-cpufreq: _FROZEN Cleanup
  irqchip, irq-armada-370-xp: _FROZEN Cleanup
  irqchip, irq-gic: _FROZEN Cleanup
  scsi, bnx2fc, bnx2fc_fcoe: _FROZEN Cleanup
  scsi, bnx2i, bnx2i_init: _FROZEN Cleanup
  scsi, fcoe: _FROZEN Cleanup
  scsi, virtio_scsi: _FROZEN Cleanup
  md, raid5: _FROZEN Cleanup
  virt, kvm, arm, arch_timer: _FROZEN Cleanup
  virt, kvm, arm, vgic: _FROZEN Cleanup
  trace, ring_buffer: _FROZEN Cleanup
  oprofile, timer_int: _FROZEN Cleanup
  lib, cpu-notifier-error-inject: _FROZEN Cleanup
  lib, percpu_counter: _FROZEN Cleanup
  lib, radix-tree: _FROZEN Cleanup
  staging, lustre, linux-cpu: _FROZEN Cleanup
  cpu: Eliminate _FROZEN flags thoroughly

Thomas Gleixner (1):
  cpu: Restructure FROZEN state handling

 arch/arm/kvm/arm.c |  3 +-
 arch/arm/vfp/vfpmodule.c   |  6 +-
 arch/ia64/kernel/err_inject.c  |  4 +-
 arch/ia64/kernel/mca.c |  3 +-
 arch/ia64/kernel/palinfo.c |  4 +-
 arch/ia64/kernel/salinfo.c |  4 +-
 arch/ia64/kernel/topology.c|  4 +-
 arch/mips/loongson/loongson-3/smp.c|  5 +-
 arch/powerpc/kernel/sysfs.c|  4 +-
 arch/powerpc/mm/mmu_context_nohash.c   |  5 +-
 arch/powerpc/mm/numa.c |  5 +-
 arch/powerpc/platforms/powermac/smp.c  | 11 ++--
 arch/s390/kernel/perf_cpum_sf.c|  1 -
 arch/sparc/kernel/sysfs.c  |  4 +-
 arch/x86/kernel/apic/x2apic_cluster.c  | 11 +++-
 arch/x86/kernel/cpu/intel_cacheinfo.c  |  4 +-
 arch/x86/kernel/cpu/mcheck/mce_amd.c   |  4 +-
 arch/x86/kernel/cpu/mcheck/therm_throt.c   |  5 +-
 arch/x86/kernel/cpu/microcode/core.c   |  8 +--
 arch/x86/kernel/cpuid.c|  6 +-
 arch/x86/kernel/kvm.c  |  9 +--
 arch/x86/kernel/msr.c  |  6 +-
 arch/x86/kernel/vsyscall_64.c  |  2 +-
 arch/x86/pci/amd_bus.c |  3 +-
 block/blk-iopoll.c |  2 +-
 block/blk

[RFC PATCH v1 02/70] ia64, err_inject: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from ia64/err_inject.

Signed-off-by: Chen, Gong 
---
 arch/ia64/kernel/err_inject.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
index 0c161ed..a8b70d4 100644
--- a/arch/ia64/kernel/err_inject.c
+++ b/arch/ia64/kernel/err_inject.c
@@ -242,13 +242,11 @@ static int err_inject_cpu_callback(struct notifier_block 
*nfb,
struct device *sys_dev;
 
sys_dev = get_cpu_device(cpu);
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
err_inject_add_dev(sys_dev);
break;
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
err_inject_remove_dev(sys_dev);
break;
}
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 10/70] x86, kvm: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from kvm.

Signed-off-by: Chen, Gong 
---
 arch/x86/kernel/kvm.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 3dd8e2c..22d472b 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -442,19 +442,20 @@ static int kvm_cpu_notify(struct notifier_block *self, 
unsigned long action,
  void *hcpu)
 {
int cpu = (unsigned long)hcpu;
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
-   case CPU_DOWN_FAILED:
-   case CPU_ONLINE_FROZEN:
smp_call_function_single(cpu, kvm_guest_cpu_online, NULL, 0);
break;
case CPU_DOWN_PREPARE:
-   case CPU_DOWN_PREPARE_FROZEN:
smp_call_function_single(cpu, kvm_guest_cpu_offline, NULL, 1);
break;
default:
break;
}
+
+   if (action == CPU_DOWN_FAILED)
+   smp_call_function_single(cpu, kvm_guest_cpu_online, NULL, 0);
+
return NOTIFY_OK;
 }
 
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 08/70] x86, mce, therm_throt: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from mce/therm_throt.

Signed-off-by: Chen, Gong 
---
 arch/x86/kernel/cpu/mcheck/therm_throt.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c 
b/arch/x86/kernel/cpu/mcheck/therm_throt.c
index 36a1bb6..dd13686 100644
--- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
@@ -283,16 +283,13 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
 
dev = get_cpu_device(cpu);
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
err = thermal_throttle_add_dev(dev, cpu);
WARN_ON(err);
break;
case CPU_UP_CANCELED:
-   case CPU_UP_CANCELED_FROZEN:
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
thermal_throttle_remove_dev(dev);
break;
}
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 17/70] arm, vfp, vfpmodule: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from arm/vfp/vfpmodule.

Signed-off-by: Chen, Gong 
---
 arch/arm/vfp/vfpmodule.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index 2f37e1d..a1a6154 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -642,9 +642,11 @@ int vfp_restore_user_hwstate(struct user_vfp __user *ufp,
 static int vfp_hotplug(struct notifier_block *b, unsigned long action,
void *hcpu)
 {
-   if (action == CPU_DYING || action == CPU_DYING_FROZEN)
+   action &= ~CPU_TASKS_FROZEN;
+
+   if (action == CPU_DYING)
vfp_current_hw_state[(long)hcpu] = NULL;
-   else if (action == CPU_STARTING || action == CPU_STARTING_FROZEN)
+   else if (action == CPU_STARTING)
vfp_enable(NULL);
return NOTIFY_OK;
 }
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 19/70] powerpc, sysfs: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from powerpc/sysfs.

Signed-off-by: Chen, Gong 
---
 arch/powerpc/kernel/sysfs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 67fd2fd..8a3739c 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -852,14 +852,12 @@ static int sysfs_cpu_notify(struct notifier_block *self,
 {
unsigned int cpu = (unsigned int)(long)hcpu;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
register_cpu_online(cpu);
break;
 #ifdef CONFIG_HOTPLUG_CPU
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
unregister_cpu_online(cpu);
break;
 #endif
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 20/70] powerpc, mm, numa: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from powerpc/mm/numa.

Signed-off-by: Chen, Gong 
---
 arch/powerpc/mm/numa.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 3b181b2..080ef52 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -598,18 +598,15 @@ static int cpu_numa_callback(struct notifier_block *nfb, 
unsigned long action,
unsigned long lcpu = (unsigned long)hcpu;
int ret = NOTIFY_DONE, nid;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
nid = numa_setup_cpu(lcpu);
verify_cpu_node_mapping((int)lcpu, nid);
ret = NOTIFY_OK;
break;
 #ifdef CONFIG_HOTPLUG_CPU
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
case CPU_UP_CANCELED:
-   case CPU_UP_CANCELED_FROZEN:
unmap_cpu_from_node(lcpu);
break;
ret = NOTIFY_OK;
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 14/70] x86, microcode, core: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from x86/microcode/core.

Signed-off-by: Chen, Gong 
---
 arch/x86/kernel/cpu/microcode/core.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c 
b/arch/x86/kernel/cpu/microcode/core.c
index dd9d619..27e47be 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -499,6 +499,10 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long 
action, void *hcpu)
pr_debug("CPU%d removed\n", cpu);
break;
 
+   case CPU_UP_CANCELED:
+   /* The CPU refused to come up during a system resume */
+   if (action & CPU_TASKS_FROZEN)
+   microcode_fini_cpu(cpu);
/*
 * case CPU_DEAD:
 *
@@ -509,10 +513,6 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long 
action, void *hcpu)
 */
}
 
-   /* The CPU refused to come up during a system resume */
-   if (action == CPU_UP_CANCELED_FROZEN)
-   microcode_fini_cpu(cpu);
-
return NOTIFY_OK;
 }
 
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 21/70] powerpc, powermac, smp: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from powermac/smp.

Signed-off-by: Chen, Gong 
---
 arch/powerpc/platforms/powermac/smp.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/platforms/powermac/smp.c 
b/arch/powerpc/platforms/powermac/smp.c
index 5cbd4d6..980605f 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -861,9 +861,8 @@ static int smp_core99_cpu_notify(struct notifier_block 
*self,
 {
int rc;
 
-   switch(action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
/* Open i2c bus if it was used for tb sync */
if (pmac_tb_clock_chip_host) {
rc = pmac_i2c_open(pmac_tb_clock_chip_host, 1);
@@ -875,9 +874,11 @@ static int smp_core99_cpu_notify(struct notifier_block 
*self,
break;
case CPU_ONLINE:
case CPU_UP_CANCELED:
-   /* Close i2c bus if it was used for tb sync */
-   if (pmac_tb_clock_chip_host)
-   pmac_i2c_close(pmac_tb_clock_chip_host);
+   if (!(action & CPU_TASKS_FROZEN)) {
+   /* Close i2c bus if it was used for tb sync */
+   if (pmac_tb_clock_chip_host)
+   pmac_i2c_close(pmac_tb_clock_chip_host);
+   }
break;
default:
break;
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 29/70] kernel, sched, core: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from sched/core.

Signed-off-by: Chen, Gong 
---
 kernel/sched/core.c | 55 -
 1 file changed, 25 insertions(+), 30 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index bc1638b..f0aff5f 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -459,13 +459,10 @@ hotplug_hrtick(struct notifier_block *nfb, unsigned long 
action, void *hcpu)
 {
int cpu = (int)(long)hcpu;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_CANCELED:
-   case CPU_UP_CANCELED_FROZEN:
case CPU_DOWN_PREPARE:
-   case CPU_DOWN_PREPARE_FROZEN:
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
hrtick_clear(cpu_rq(cpu));
return NOTIFY_OK;
}
@@ -6742,30 +6739,28 @@ static int num_cpus_frozen; /* used to mark 
begin/end of suspend/resume */
 static int cpuset_cpu_active(struct notifier_block *nfb, unsigned long action,
 void *hcpu)
 {
-   switch (action) {
-   case CPU_ONLINE_FROZEN:
-   case CPU_DOWN_FAILED_FROZEN:
-
-   /*
-* num_cpus_frozen tracks how many CPUs are involved in suspend
-* resume sequence. As long as this is not the last online
-* operation in the resume sequence, just build a single sched
-* domain, ignoring cpusets.
-*/
-   num_cpus_frozen--;
-   if (likely(num_cpus_frozen)) {
-   partition_sched_domains(1, NULL, NULL);
-   break;
+   switch (action & ~CPU_TASKS_FROZEN) {
+   case CPU_ONLINE:
+   case CPU_DOWN_FAILED:
+   if (action & CPU_TASKS_FROZEN) {
+   /*
+* num_cpus_frozen tracks how many CPUs are involved
+* in suspend resume sequence. As long as this is not
+* the last online operation in the resume sequence,
+* just build a single sched domain, ignoring cpusets.
+*/
+   num_cpus_frozen--;
+   if (likely(num_cpus_frozen)) {
+   partition_sched_domains(1, NULL, NULL);
+   break;
+   }
}
 
/*
-* This is the last CPU online operation. So fall through and
-* restore the original sched domains by considering the
-* cpuset configurations.
+* This is the last CPU online operation. So restore the
+* original sched domains by considering the cpuset
+* configurations.
 */
-
-   case CPU_ONLINE:
-   case CPU_DOWN_FAILED:
cpuset_update_active_cpus(true);
break;
default:
@@ -6777,13 +6772,13 @@ static int cpuset_cpu_active(struct notifier_block 
*nfb, unsigned long action,
 static int cpuset_cpu_inactive(struct notifier_block *nfb, unsigned long 
action,
   void *hcpu)
 {
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_DOWN_PREPARE:
-   cpuset_update_active_cpus(false);
-   break;
-   case CPU_DOWN_PREPARE_FROZEN:
-   num_cpus_frozen++;
-   partition_sched_domains(1, NULL, NULL);
+   if (action & CPU_TASKS_FROZEN) {
+   num_cpus_frozen++;
+   partition_sched_domains(1, NULL, NULL);
+   } else
+   cpuset_update_active_cpus(false);
break;
default:
return NOTIFY_DONE;
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 28/70] kernel, profile: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from kernel/profile.

Signed-off-by: Chen, Gong 
---
 kernel/profile.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/kernel/profile.c b/kernel/profile.c
index 54bf5ba..22bca4b 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -333,9 +333,8 @@ static int profile_cpu_callback(struct notifier_block *info,
int node, cpu = (unsigned long)__cpu;
struct page *page;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
node = cpu_to_mem(cpu);
per_cpu(cpu_profile_flip, cpu) = 0;
if (!per_cpu(cpu_profile_hits, cpu)[1]) {
@@ -361,14 +360,11 @@ out_free:
__free_page(page);
return notifier_from_errno(-ENOMEM);
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
if (prof_cpu_mask != NULL)
cpumask_set_cpu(cpu, prof_cpu_mask);
break;
case CPU_UP_CANCELED:
-   case CPU_UP_CANCELED_FROZEN:
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
if (prof_cpu_mask != NULL)
cpumask_clear_cpu(cpu, prof_cpu_mask);
if (per_cpu(cpu_profile_hits, cpu)[0]) {
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 30/70] kernel, hrtimer: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from kernel/hrtimer.

Signed-off-by: Chen, Gong 
---
 kernel/hrtimer.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 3ab2899..a37958e 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -1756,27 +1756,19 @@ static int hrtimer_cpu_notify(struct notifier_block 
*self,
 {
int scpu = (long)hcpu;
 
-   switch (action) {
-
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
init_hrtimers_cpu(scpu);
break;
-
 #ifdef CONFIG_HOTPLUG_CPU
case CPU_DYING:
-   case CPU_DYING_FROZEN:
clockevents_notify(CLOCK_EVT_NOTIFY_CPU_DYING, &scpu);
break;
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
-   {
clockevents_notify(CLOCK_EVT_NOTIFY_CPU_DEAD, &scpu);
migrate_hrtimers(scpu);
break;
-   }
 #endif
-
default:
break;
}
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 38/70] mm, memcontrol: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from mm/memcontrol.

Signed-off-by: Chen, Gong 
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index a2c7bcb..871667d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2540,7 +2540,7 @@ static int memcg_cpu_hotplug_callback(struct 
notifier_block *nb,
if (action == CPU_ONLINE)
return NOTIFY_OK;
 
-   if (action != CPU_DEAD && action != CPU_DEAD_FROZEN)
+   if ((action & ~CPU_TASKS_FROZEN) != CPU_DEAD)
return NOTIFY_OK;
 
for_each_mem_cgroup(iter)
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 35/70] mm, slab: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from mm/slab.

Signed-off-by: Chen, Gong 
---
 mm/slab.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index 3070b92..5490528 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1325,20 +1325,17 @@ static int cpuup_callback(struct notifier_block *nfb,
long cpu = (long)hcpu;
int err = 0;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
mutex_lock(&slab_mutex);
err = cpuup_prepare(cpu);
mutex_unlock(&slab_mutex);
break;
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
start_cpu_timer(cpu);
break;
 #ifdef CONFIG_HOTPLUG_CPU
case CPU_DOWN_PREPARE:
-   case CPU_DOWN_PREPARE_FROZEN:
/*
 * Shutdown cache reaper. Note that the slab_mutex is
 * held so that if cache_reap() is invoked it cannot do
@@ -1350,11 +1347,9 @@ static int cpuup_callback(struct notifier_block *nfb,
per_cpu(slab_reap_work, cpu).work.func = NULL;
break;
case CPU_DOWN_FAILED:
-   case CPU_DOWN_FAILED_FROZEN:
start_cpu_timer(cpu);
break;
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
/*
 * Even if all the cpus of a node are down, we don't free the
 * kmem_cache_node of any cache. This to avoid a race between
@@ -1366,7 +1361,6 @@ static int cpuup_callback(struct notifier_block *nfb,
/* fall through */
 #endif
case CPU_UP_CANCELED:
-   case CPU_UP_CANCELED_FROZEN:
mutex_lock(&slab_mutex);
cpuup_canceled(cpu);
mutex_unlock(&slab_mutex);
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 41/70] fs, buffer: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from fs/buffer.

Signed-off-by: Chen, Gong 
---
 fs/buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index eba6e4f..47960b7 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -3373,7 +3373,7 @@ static void buffer_exit_cpu(int cpu)
 static int buffer_cpu_notify(struct notifier_block *self,
  unsigned long action, void *hcpu)
 {
-   if (action == CPU_DEAD || action == CPU_DEAD_FROZEN)
+   if ((action & ~CPU_TASKS_FROZEN) == CPU_DEAD)
buffer_exit_cpu((unsigned long)hcpu);
return NOTIFY_OK;
 }
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 52/70] cpuidle, cpuidle-powernv: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from cpuidle/cpuidle-powernv.

Signed-off-by: Chen, Gong 
---
 drivers/cpuidle/cpuidle-powernv.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/cpuidle/cpuidle-powernv.c 
b/drivers/cpuidle/cpuidle-powernv.c
index 74f5788..78575a8 100644
--- a/drivers/cpuidle/cpuidle-powernv.c
+++ b/drivers/cpuidle/cpuidle-powernv.c
@@ -107,16 +107,14 @@ static int powernv_cpuidle_add_cpu_notifier(struct 
notifier_block *n,
per_cpu(cpuidle_devices, hotcpu);
 
if (dev && cpuidle_get_driver()) {
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
cpuidle_pause_and_lock();
cpuidle_enable_device(dev);
cpuidle_resume_and_unlock();
break;
 
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
cpuidle_pause_and_lock();
cpuidle_disable_device(dev);
cpuidle_resume_and_unlock();
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 50/70] clocksource, metag_generic: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from clocksource/metag_generic.

Signed-off-by: Chen, Gong 
---
 drivers/clocksource/metag_generic.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/clocksource/metag_generic.c 
b/drivers/clocksource/metag_generic.c
index 9e4db41..eefa164 100644
--- a/drivers/clocksource/metag_generic.c
+++ b/drivers/clocksource/metag_generic.c
@@ -159,9 +159,8 @@ static int arch_timer_cpu_notify(struct notifier_block 
*self,
 {
int cpu = (long)hcpu;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_STARTING:
-   case CPU_STARTING_FROZEN:
arch_timer_setup(cpu);
break;
}
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 56/70] irqchip, irq-gic: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from irqchip/irq-gic.

Signed-off-by: Chen, Gong 
---
 drivers/irqchip/irq-gic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 7c131cf..a8df097 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -877,7 +877,7 @@ static int gic_irq_domain_xlate(struct irq_domain *d,
 static int gic_secondary_init(struct notifier_block *nfb, unsigned long action,
  void *hcpu)
 {
-   if (action == CPU_STARTING || action == CPU_STARTING_FROZEN)
+   if ((action & ~CPU_TASKS_FROZEN) == CPU_STARTING)
gic_cpu_init(&gic_data[0]);
return NOTIFY_OK;
 }
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 58/70] scsi, bnx2i, bnx2i_init: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from scsi/bnx2i_init.

Signed-off-by: Chen, Gong 
---
 drivers/scsi/bnx2i/bnx2i_init.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 80c03b4..bd71179 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -476,15 +476,13 @@ static int bnx2i_cpu_callback(struct notifier_block *nfb,
 {
unsigned cpu = (unsigned long)hcpu;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
printk(KERN_INFO "bnx2i: CPU %x online: Create Rx thread\n",
cpu);
bnx2i_percpu_thread_create(cpu);
break;
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
printk(KERN_INFO "CPU %x offline: Remove Rx thread\n", cpu);
bnx2i_percpu_thread_destroy(cpu);
break;
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 57/70] scsi, bnx2fc, bnx2fc_fcoe: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from scsi/bnx2fc_fcoe.

Signed-off-by: Chen, Gong 
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 785d0d7..c56281d 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -2507,14 +2507,12 @@ static int bnx2fc_cpu_callback(struct notifier_block 
*nfb,
 {
unsigned cpu = (unsigned long)hcpu;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
printk(PFX "CPU %x online: Create Rx thread\n", cpu);
bnx2fc_percpu_thread_create(cpu);
break;
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
printk(PFX "CPU %x offline: Remove Rx thread\n", cpu);
bnx2fc_percpu_thread_destroy(cpu);
break;
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 61/70] md, raid5: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from md/raid5.

Signed-off-by: Chen, Gong 
---
 drivers/md/raid5.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 6234b2e..3d76235 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5665,9 +5665,8 @@ static int raid456_cpu_notify(struct notifier_block *nfb, 
unsigned long action,
long cpu = (long)hcpu;
struct raid5_percpu *percpu = per_cpu_ptr(conf->percpu, cpu);
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
if (alloc_scratch_buffer(conf, percpu)) {
pr_err("%s: failed memory allocation for cpu%ld\n",
   __func__, cpu);
@@ -5675,7 +5674,6 @@ static int raid456_cpu_notify(struct notifier_block *nfb, 
unsigned long action,
}
break;
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
free_scratch_buffer(conf, per_cpu_ptr(conf->percpu, cpu));
break;
default:
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 65/70] oprofile, timer_int: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from oprofile/timer_int.

Signed-off-by: Chen, Gong 
---
 drivers/oprofile/timer_int.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
index 61be1d9..ab5a0a9 100644
--- a/drivers/oprofile/timer_int.c
+++ b/drivers/oprofile/timer_int.c
@@ -79,14 +79,12 @@ static int oprofile_cpu_notify(struct notifier_block *self,
 {
long cpu = (long) hcpu;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
smp_call_function_single(cpu, __oprofile_hrtimer_start,
 NULL, 1);
break;
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
__oprofile_hrtimer_stop(cpu);
break;
}
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 63/70] virt, kvm, arm, vgic: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from kvm/arm/vgic.

Signed-off-by: Chen, Gong 
---
 virt/kvm/arm/vgic.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 56ff9be..f93b8c5 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -1452,13 +1452,11 @@ static void vgic_init_maintenance_interrupt(void *info)
 static int vgic_cpu_notify(struct notifier_block *self,
   unsigned long action, void *cpu)
 {
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_STARTING:
-   case CPU_STARTING_FROZEN:
vgic_init_maintenance_interrupt(NULL);
break;
case CPU_DYING:
-   case CPU_DYING_FROZEN:
disable_percpu_irq(vgic_maint_irq);
break;
}
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 64/70] trace, ring_buffer: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from trace/ring_buffer.

Signed-off-by: Chen, Gong 
---
 kernel/trace/ring_buffer.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index ff70271..1cd5793 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -4607,9 +4607,8 @@ static int rb_cpu_notify(struct notifier_block *self,
int cpu_i, nr_pages_same;
unsigned int nr_pages;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
if (cpumask_test_cpu(cpu, buffer->cpumask))
return NOTIFY_OK;
 
@@ -4639,7 +4638,6 @@ static int rb_cpu_notify(struct notifier_block *self,
cpumask_set_cpu(cpu, buffer->cpumask);
break;
case CPU_DOWN_PREPARE:
-   case CPU_DOWN_PREPARE_FROZEN:
/*
 * Do nothing.
 *  If we were to free the buffer, then the user would
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 66/70] lib, cpu-notifier-error-inject: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from lib/cpu-notifier-error-inject.

Signed-off-by: Chen, Gong 
---
 lib/cpu-notifier-error-inject.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/cpu-notifier-error-inject.c b/lib/cpu-notifier-error-inject.c
index 707ca24..78c28db 100644
--- a/lib/cpu-notifier-error-inject.c
+++ b/lib/cpu-notifier-error-inject.c
@@ -10,10 +10,10 @@ MODULE_PARM_DESC(priority, "specify cpu notifier priority");
 
 static struct notifier_err_inject cpu_notifier_err_inject = {
.actions = {
-   { NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE) },
-   { NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE_FROZEN) },
-   { NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE) },
-   { NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE_FROZEN) },
+   {NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE)},
+   {NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE|CPU_TASKS_FROZEN)},
+   {NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE)},
+   {NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE|CPU_TASKS_FROZEN)},
{}
}
 };
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 67/70] lib, percpu_counter: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from lib/percpu_counter.

Signed-off-by: Chen, Gong 
---
 lib/percpu_counter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c
index 7dd33577..9a833ea 100644
--- a/lib/percpu_counter.c
+++ b/lib/percpu_counter.c
@@ -169,7 +169,7 @@ static int percpu_counter_hotcpu_callback(struct 
notifier_block *nb,
struct percpu_counter *fbc;
 
compute_batch_value();
-   if (action != CPU_DEAD && action != CPU_DEAD_FROZEN)
+   if ((action & ~CPU_TASKS_FROZEN) != CPU_DEAD)
return NOTIFY_OK;
 
cpu = (unsigned long)hcpu;
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 68/70] lib, radix-tree: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from lib/radix-tree.

Signed-off-by: Chen, Gong 
---
 lib/radix-tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 3291a8e..5f7231c 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -1465,7 +1465,7 @@ static int radix_tree_callback(struct notifier_block *nfb,
struct radix_tree_preload *rtp;
 
/* Free per-cpu pool of perloaded nodes */
-   if (action == CPU_DEAD || action == CPU_DEAD_FROZEN) {
+   if ((action & ~CPU_TASKS_FROZEN) == CPU_DEAD) {
rtp = &per_cpu(radix_tree_preloads, cpu);
while (rtp->nr) {
kmem_cache_free(radix_tree_node_cachep,
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 70/70] cpu: Eliminate _FROZEN flags thoroughly

2014-07-22 Thread Chen, Gong
By now all usages of XXX_FROZEN have been removed. It can
be deleted safely.

Signed-off-by: Chen, Gong 
---
 include/linux/cpu.h | 9 -
 1 file changed, 9 deletions(-)

diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 95978ad..9de61cc 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -97,15 +97,6 @@ enum {
  */
 #define CPU_TASKS_FROZEN   0x0010
 
-#define CPU_ONLINE_FROZEN  (CPU_ONLINE | CPU_TASKS_FROZEN)
-#define CPU_UP_PREPARE_FROZEN  (CPU_UP_PREPARE | CPU_TASKS_FROZEN)
-#define CPU_UP_CANCELED_FROZEN (CPU_UP_CANCELED | CPU_TASKS_FROZEN)
-#define CPU_DOWN_PREPARE_FROZEN(CPU_DOWN_PREPARE | CPU_TASKS_FROZEN)
-#define CPU_DOWN_FAILED_FROZEN (CPU_DOWN_FAILED | CPU_TASKS_FROZEN)
-#define CPU_DEAD_FROZEN(CPU_DEAD | CPU_TASKS_FROZEN)
-#define CPU_DYING_FROZEN   (CPU_DYING | CPU_TASKS_FROZEN)
-#define CPU_STARTING_FROZEN(CPU_STARTING | CPU_TASKS_FROZEN)
-
 
 #ifdef CONFIG_SMP
 /* Need to know about CPUs going up/down? */
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 69/70] staging, lustre, linux-cpu: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from lustre/linux-cpu.

Signed-off-by: Chen, Gong 
---
 drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c 
b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c
index fc21210..0e061ca 100644
--- a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c
@@ -954,16 +954,14 @@ cfs_cpu_notify(struct notifier_block *self, unsigned long 
action, void *hcpu)
unsigned int  cpu = (unsigned long)hcpu;
bool warn;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
spin_lock(&cpt_data.cpt_lock);
cpt_data.cpt_version++;
spin_unlock(&cpt_data.cpt_lock);
default:
-   if (action != CPU_DEAD && action != CPU_DEAD_FROZEN) {
+   if ((action & ~CPU_TASKS_FROZEN) != CPU_DEAD) {
CDEBUG(D_INFO, "CPU changed [cpu %u action %lx]\n",
   cpu, action);
break;
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 60/70] scsi, virtio_scsi: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from scsi/virtio_scsi.

Signed-off-by: Chen, Gong 
---
 drivers/scsi/virtio_scsi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 308256b..22f4a6e5 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -782,11 +782,9 @@ static int virtscsi_cpu_callback(struct notifier_block 
*nfb,
 unsigned long action, void *hcpu)
 {
struct virtio_scsi *vscsi = container_of(nfb, struct virtio_scsi, nb);
-   switch(action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
__virtscsi_set_affinity(vscsi, true);
break;
default:
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 53/70] cpuidle, cpuidle-pseries: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from cpuidle/cpuidle-pseries.

Signed-off-by: Chen, Gong 
---
 drivers/cpuidle/cpuidle-pseries.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/cpuidle/cpuidle-pseries.c 
b/drivers/cpuidle/cpuidle-pseries.c
index 6f7b019..11902eb 100644
--- a/drivers/cpuidle/cpuidle-pseries.c
+++ b/drivers/cpuidle/cpuidle-pseries.c
@@ -176,16 +176,14 @@ static int pseries_cpuidle_add_cpu_notifier(struct 
notifier_block *n,
per_cpu(cpuidle_devices, hotcpu);
 
if (dev && cpuidle_get_driver()) {
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
cpuidle_pause_and_lock();
cpuidle_enable_device(dev);
cpuidle_resume_and_unlock();
break;
 
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
cpuidle_pause_and_lock();
cpuidle_disable_device(dev);
cpuidle_resume_and_unlock();
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 59/70] scsi, fcoe: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from scsi/fcoe.

Signed-off-by: Chen, Gong 
---
 drivers/scsi/fcoe/fcoe.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 00ee0ed..f1d3f6a 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -1376,14 +1376,12 @@ static int fcoe_cpu_callback(struct notifier_block *nfb,
 {
unsigned cpu = (unsigned long)hcpu;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
FCOE_DBG("CPU %x online: Create Rx thread\n", cpu);
fcoe_percpu_thread_create(cpu);
break;
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
FCOE_DBG("CPU %x offline: Remove Rx thread\n", cpu);
fcoe_percpu_thread_destroy(cpu);
break;
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 55/70] irqchip, irq-armada-370-xp: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from irqchip/irq-armada-370-xp.

Signed-off-by: Chen, Gong 
---
 drivers/irqchip/irq-armada-370-xp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-armada-370-xp.c 
b/drivers/irqchip/irq-armada-370-xp.c
index 574aba0..1c46257 100644
--- a/drivers/irqchip/irq-armada-370-xp.c
+++ b/drivers/irqchip/irq-armada-370-xp.c
@@ -357,7 +357,7 @@ static void armada_xp_mpic_smp_cpu_init(void)
 static int armada_xp_mpic_secondary_init(struct notifier_block *nfb,
 unsigned long action, void *hcpu)
 {
-   if (action == CPU_STARTING || action == CPU_STARTING_FROZEN)
+   if ((action & ~CPU_TASKS_FROZEN) == CPU_STARTING)
armada_xp_mpic_smp_cpu_init();
return NOTIFY_OK;
 }
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 62/70] virt, kvm, arm, arch_timer: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from kvm/arm/arch_timer.

Signed-off-by: Chen, Gong 
---
 virt/kvm/arm/arch_timer.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c
index 22fa819..169512d 100644
--- a/virt/kvm/arm/arch_timer.c
+++ b/virt/kvm/arm/arch_timer.c
@@ -220,13 +220,11 @@ u64 kvm_arm_timer_get_reg(struct kvm_vcpu *vcpu, u64 
regid)
 static int kvm_timer_cpu_notify(struct notifier_block *self,
unsigned long action, void *cpu)
 {
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_STARTING:
-   case CPU_STARTING_FROZEN:
kvm_timer_init_interrupt(NULL);
break;
case CPU_DYING:
-   case CPU_DYING_FROZEN:
disable_percpu_irq(host_vtimer_irq);
break;
}
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 54/70] cpufreq, acpi-cpufreq: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from cpufreq/acpi-cpufreq.

Signed-off-by: Chen, Gong 
---
 drivers/cpufreq/acpi-cpufreq.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index b0c18ed..2b7ffc1 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -533,14 +533,12 @@ static int boost_notify(struct notifier_block *nb, 
unsigned long action,
 * sync with the current global state.
 */
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
boost_set_msrs(acpi_cpufreq_driver.boost_enabled, cpumask);
break;
 
case CPU_DOWN_PREPARE:
-   case CPU_DOWN_PREPARE_FROZEN:
boost_set_msrs(1, cpumask);
break;
 
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 51/70] powercap, intel_rapl: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from powercap/intel_rapl.

Signed-off-by: Chen, Gong 
---
 drivers/powercap/intel_rapl.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c
index b1cda6f..c55de1a 100644
--- a/drivers/powercap/intel_rapl.c
+++ b/drivers/powercap/intel_rapl.c
@@ -1328,11 +1328,9 @@ static int rapl_cpu_callback(struct notifier_block *nfb,
struct rapl_package *rp;
 
phy_package_id = topology_physical_package_id(cpu);
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
case CPU_DOWN_FAILED:
-   case CPU_DOWN_FAILED_FROZEN:
rp = find_package_by_id(phy_package_id);
if (rp)
++rp->nr_cpus;
@@ -1340,7 +1338,6 @@ static int rapl_cpu_callback(struct notifier_block *nfb,
rapl_add_package(cpu);
break;
case CPU_DOWN_PREPARE:
-   case CPU_DOWN_PREPARE_FROZEN:
rp = find_package_by_id(phy_package_id);
if (!rp)
break;
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 48/70] block, blk-softirq: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from block/blk-softirq.

Signed-off-by: Chen, Gong 
---
 block/blk-softirq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-softirq.c b/block/blk-softirq.c
index 53b1737..3ab9c2e 100644
--- a/block/blk-softirq.c
+++ b/block/blk-softirq.c
@@ -85,7 +85,7 @@ static int blk_cpu_notify(struct notifier_block *self, 
unsigned long action,
 * If a CPU goes away, splice its entries to the current CPU
 * and trigger a run of the softirq
 */
-   if (action == CPU_DEAD || action == CPU_DEAD_FROZEN) {
+   if ((action & ~CPU_TASKS_FROZEN) == CPU_DEAD) {
int cpu = (unsigned long) hcpu;
 
local_irq_disable();
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 49/70] driver, base, topology: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from driver/base/topology.

Signed-off-by: Chen, Gong 
---
 drivers/base/topology.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index be7c1fb..369e437 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -141,15 +141,12 @@ static int topology_cpu_callback(struct notifier_block 
*nfb,
unsigned int cpu = (unsigned long)hcpu;
int rc = 0;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
rc = topology_add_dev(cpu);
break;
case CPU_UP_CANCELED:
-   case CPU_UP_CANCELED_FROZEN:
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
topology_remove_dev(cpu);
break;
}
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 43/70] net, iucv: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from net/iucv.

Signed-off-by: Chen, Gong 
---
 net/iucv/iucv.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
index da78793..4a44595 100644
--- a/net/iucv/iucv.c
+++ b/net/iucv/iucv.c
@@ -663,28 +663,22 @@ static int iucv_cpu_notify(struct notifier_block *self,
cpumask_t cpumask;
long cpu = (long) hcpu;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
if (alloc_iucv_data(cpu))
return notifier_from_errno(-ENOMEM);
break;
case CPU_UP_CANCELED:
-   case CPU_UP_CANCELED_FROZEN:
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
free_iucv_data(cpu);
break;
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
case CPU_DOWN_FAILED:
-   case CPU_DOWN_FAILED_FROZEN:
if (!iucv_path_table)
break;
smp_call_function_single(cpu, iucv_declare_cpu, NULL, 1);
break;
case CPU_DOWN_PREPARE:
-   case CPU_DOWN_PREPARE_FROZEN:
if (!iucv_path_table)
break;
cpumask_copy(&cpumask, &iucv_buffer_cpumask);
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 45/70] net, core, dev: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from net/core/dev.

Signed-off-by: Chen, Gong 
---
 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 7990984..2c3801a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6805,7 +6805,7 @@ static int dev_cpu_callback(struct notifier_block *nfb,
unsigned int cpu, oldcpu = (unsigned long)ocpu;
struct softnet_data *sd, *oldsd;
 
-   if (action != CPU_DEAD && action != CPU_DEAD_FROZEN)
+   if ((action & ~CPU_TASKS_FROZEN) != CPU_DEAD)
return NOTIFY_OK;
 
local_irq_disable();
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 42/70] xfs, xfs_mount: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from xfs/xfs_mount.

Signed-off-by: Chen, Gong 
---
 fs/xfs/xfs_mount.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 3507cd0..b701946 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1531,15 +1531,13 @@ xfs_icsb_cpu_notify(
mp = (xfs_mount_t *)container_of(nfb, xfs_mount_t, m_icsb_notifier);
cntp = (xfs_icsb_cnts_t *)
per_cpu_ptr(mp->m_sb_cnts, (unsigned long)hcpu);
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
/* Easy Case - initialize the area and locks, and
 * then rebalance when online does everything else for us. */
memset(cntp, 0, sizeof(xfs_icsb_cnts_t));
break;
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
xfs_icsb_lock(mp);
xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0);
xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0);
@@ -1547,7 +1545,6 @@ xfs_icsb_cpu_notify(
xfs_icsb_unlock(mp);
break;
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
/* Disable all the counters, then fold the dead cpu's
 * count into the total on the global superblock and
 * re-enable the counters. */
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 46/70] block, blk-mq: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from block/blk-mq.

Signed-off-by: Chen, Gong 
---
 block/blk-mq.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index ad69ef6..b5cd279 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1522,9 +1522,11 @@ static int blk_mq_hctx_notify(void *data, unsigned long 
action,
 {
struct blk_mq_hw_ctx *hctx = data;
 
-   if (action == CPU_DEAD || action == CPU_DEAD_FROZEN)
+   action &= ~CPU_TASKS_FROZEN;
+
+   if (action == CPU_DEAD)
return blk_mq_hctx_cpu_offline(hctx, cpu);
-   else if (action == CPU_ONLINE || action == CPU_ONLINE_FROZEN)
+   else if (action == CPU_ONLINE)
return blk_mq_hctx_cpu_online(hctx, cpu);
 
return NOTIFY_OK;
@@ -1939,8 +1941,8 @@ static int blk_mq_queue_reinit_notify(struct 
notifier_block *nb,
 * offline CPUs to first hardware queue. We will re-init the queue
 * below to get optimal settings.
 */
-   if (action != CPU_DEAD && action != CPU_DEAD_FROZEN &&
-   action != CPU_ONLINE && action != CPU_ONLINE_FROZEN)
+   action &= ~CPU_TASKS_FROZEN;
+   if (action != CPU_DEAD && action != CPU_ONLINE)
return NOTIFY_OK;
 
mutex_lock(&all_q_mutex);
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 44/70] net, core, flow: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from net/core/flow.

Signed-off-by: Chen, Gong 
---
 net/core/flow.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/core/flow.c b/net/core/flow.c
index a0348fd..3bb5dc0 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -417,15 +417,13 @@ static int flow_cache_cpu(struct notifier_block *nfb,
int res, cpu = (unsigned long) hcpu;
struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, cpu);
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
res = flow_cache_cpu_prepare(fc, cpu);
if (res)
return notifier_from_errno(res);
break;
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
__flow_cache_shrink(fc, fcp, 0);
break;
}
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 47/70] block, blk-iopoll: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from block/blk-iopoll.

Signed-off-by: Chen, Gong 
---
 block/blk-iopoll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
index 0736729..ba88c82 100644
--- a/block/blk-iopoll.c
+++ b/block/blk-iopoll.c
@@ -193,7 +193,7 @@ static int blk_iopoll_cpu_notify(struct notifier_block 
*self,
 * If a CPU goes away, splice its entries to the current CPU
 * and trigger a run of the softirq
 */
-   if (action == CPU_DEAD || action == CPU_DEAD_FROZEN) {
+   if ((action & ~CPU_TASKS_FROZEN) == CPU_DEAD) {
int cpu = (unsigned long) hcpu;
 
local_irq_disable();
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 39/70] mm, page_alloc: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from mm/page_alloc.

Signed-off-by: Chen, Gong 
---
 mm/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 0ea758b..c52c2a8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5537,7 +5537,7 @@ static int page_alloc_cpu_notify(struct notifier_block 
*self,
 {
int cpu = (unsigned long)hcpu;
 
-   if (action == CPU_DEAD || action == CPU_DEAD_FROZEN) {
+   if ((action & ~CPU_TASKS_FROZEN) == CPU_DEAD) {
lru_add_drain_cpu(cpu);
drain_pages(cpu);
 
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 37/70] mm, vmstat: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from mm/vmstat.

Signed-off-by: Chen, Gong 
---
 mm/vmstat.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
index b37bd49..a29a3d8 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1268,24 +1268,20 @@ static int vmstat_cpuup_callback(struct notifier_block 
*nfb,
 {
long cpu = (long)hcpu;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
refresh_zone_stat_thresholds();
start_cpu_timer(cpu);
node_set_state(cpu_to_node(cpu), N_CPU);
break;
case CPU_DOWN_PREPARE:
-   case CPU_DOWN_PREPARE_FROZEN:
cancel_delayed_work_sync(&per_cpu(vmstat_work, cpu));
per_cpu(vmstat_work, cpu).work.func = NULL;
break;
case CPU_DOWN_FAILED:
-   case CPU_DOWN_FAILED_FROZEN:
start_cpu_timer(cpu);
break;
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
refresh_zone_stat_thresholds();
vmstat_cpu_dead(cpu_to_node(cpu));
break;
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 40/70] mm, slub: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from mm/slub.

Signed-off-by: Chen, Gong 
---
 mm/slub.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index 7300480..0504f6b 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3796,11 +3796,9 @@ static int slab_cpuup_callback(struct notifier_block 
*nfb,
struct kmem_cache *s;
unsigned long flags;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_CANCELED:
-   case CPU_UP_CANCELED_FROZEN:
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
mutex_lock(&slab_mutex);
list_for_each_entry(s, &slab_caches, list) {
local_irq_save(flags);
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 33/70] kernel, timer: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from kernel/timer.

Signed-off-by: Chen, Gong 
---
 kernel/timer.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/timer.c b/kernel/timer.c
index 3bb01a3..cc11324 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1642,16 +1642,14 @@ static int timer_cpu_notify(struct notifier_block *self,
long cpu = (long)hcpu;
int err;
 
-   switch(action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
err = init_timers_cpu(cpu);
if (err < 0)
return notifier_from_errno(err);
break;
 #ifdef CONFIG_HOTPLUG_CPU
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
migrate_timers(cpu);
break;
 #endif
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 34/70] kernel, softirq: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from kernel/softirq.

Signed-off-by: Chen, Gong 
---
 kernel/softirq.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/softirq.c b/kernel/softirq.c
index 5918d22..c4d4484 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -726,10 +726,9 @@ static void takeover_tasklets(unsigned int cpu)
 static int cpu_callback(struct notifier_block *nfb, unsigned long action,
void *hcpu)
 {
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
 #ifdef CONFIG_HOTPLUG_CPU
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
takeover_tasklets((unsigned long)hcpu);
break;
 #endif /* CONFIG_HOTPLUG_CPU */
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 32/70] kernel, smp: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from kernel/smp.

Signed-off-by: Chen, Gong 
---
 kernel/smp.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/kernel/smp.c b/kernel/smp.c
index 80c33f8..808ec06 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -37,9 +37,8 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, 
void *hcpu)
long cpu = (long)hcpu;
struct call_function_data *cfd = &per_cpu(cfd_data, cpu);
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
if (!zalloc_cpumask_var_node(&cfd->cpumask, GFP_KERNEL,
cpu_to_node(cpu)))
return notifier_from_errno(-ENOMEM);
@@ -52,17 +51,12 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long 
action, void *hcpu)
 
 #ifdef CONFIG_HOTPLUG_CPU
case CPU_UP_CANCELED:
-   case CPU_UP_CANCELED_FROZEN:
-   /* Fall-through to the CPU_DEAD[_FROZEN] case. */
-
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
free_cpumask_var(cfd->cpumask);
free_percpu(cfd->csd);
break;
 
case CPU_DYING:
-   case CPU_DYING_FROZEN:
/*
 * The IPIs for the smp-call-function callbacks queued by other
 * CPUs might arrive late, either due to hardware latencies or
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 36/70] mm, vmscan: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from mm/vmscan.

Signed-off-by: Chen, Gong 
---
 mm/vmscan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 0f16ffe..25c0109 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3454,7 +3454,7 @@ static int cpu_callback(struct notifier_block *nfb, 
unsigned long action,
 {
int nid;
 
-   if (action == CPU_ONLINE || action == CPU_ONLINE_FROZEN) {
+   if ((action & ~CPU_TASKS_FROZEN) == CPU_ONLINE) {
for_each_node_state(nid, N_MEMORY) {
pg_data_t *pgdat = NODE_DATA(nid);
const struct cpumask *mask;
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 31/70] kernel, relay: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from fs/relay.

Signed-off-by: Chen, Gong 
---
 kernel/relay.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/relay.c b/kernel/relay.c
index 5a56d3c..3f7b6b1 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -523,9 +523,8 @@ static int relay_hotcpu_callback(struct notifier_block *nb,
unsigned int hotcpu = (unsigned long)hcpu;
struct rchan *chan;
 
-   switch(action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
mutex_lock(&relay_channels_mutex);
list_for_each_entry(chan, &relay_channels, list) {
if (chan->buf[hotcpu])
@@ -542,7 +541,6 @@ static int relay_hotcpu_callback(struct notifier_block *nb,
mutex_unlock(&relay_channels_mutex);
break;
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
/* No need to flush the cpu : will be flushed upon
 * final relay_flush() call. */
break;
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 24/70] s390, perf_cpum_sf: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from s390/perf_cpum_sf.

Signed-off-by: Chen, Gong 
---
 arch/s390/kernel/perf_cpum_sf.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
index ea0c7b2..1cbd3c7 100644
--- a/arch/s390/kernel/perf_cpum_sf.c
+++ b/arch/s390/kernel/perf_cpum_sf.c
@@ -1526,7 +1526,6 @@ static int cpumf_pmu_notifier(struct notifier_block *self,
 
switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
flags = PMC_INIT;
smp_call_function_single(cpu, setup_pmc_cpu, &flags, 1);
break;
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 18/70] arm, kvm: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from arm/kvm.

Signed-off-by: Chen, Gong 
---
 arch/arm/kvm/arm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 3c82b37..0014464 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -860,9 +860,8 @@ static void cpu_init_hyp_mode(void *dummy)
 static int hyp_init_cpu_notify(struct notifier_block *self,
   unsigned long action, void *cpu)
 {
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_STARTING:
-   case CPU_STARTING_FROZEN:
cpu_init_hyp_mode(NULL);
break;
}
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 25/70] sparc, sysfs: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from sparc/sysfs.

Signed-off-by: Chen, Gong 
---
 arch/sparc/kernel/sysfs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
index 7f41d40..e15a4b8 100644
--- a/arch/sparc/kernel/sysfs.c
+++ b/arch/sparc/kernel/sysfs.c
@@ -251,14 +251,12 @@ static int sysfs_cpu_notify(struct notifier_block *self,
 {
unsigned int cpu = (unsigned int)(long)hcpu;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
register_cpu_online(cpu);
break;
 #ifdef CONFIG_HOTPLUG_CPU
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
unregister_cpu_online(cpu);
break;
 #endif
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 27/70] kernel, padata: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from padata.

Signed-off-by: Chen, Gong 
---
 kernel/padata.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/kernel/padata.c b/kernel/padata.c
index 161402f..3a6bc6e 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -842,11 +842,9 @@ static int padata_cpu_callback(struct notifier_block *nfb,
 
pinst = container_of(nfb, struct padata_instance, cpu_notifier);
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
-   case CPU_ONLINE_FROZEN:
case CPU_DOWN_FAILED:
-   case CPU_DOWN_FAILED_FROZEN:
if (!pinst_has_cpu(pinst, cpu))
break;
mutex_lock(&pinst->lock);
@@ -857,9 +855,7 @@ static int padata_cpu_callback(struct notifier_block *nfb,
break;
 
case CPU_DOWN_PREPARE:
-   case CPU_DOWN_PREPARE_FROZEN:
case CPU_UP_CANCELED:
-   case CPU_UP_CANCELED_FROZEN:
if (!pinst_has_cpu(pinst, cpu))
break;
mutex_lock(&pinst->lock);
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 23/70] mips, loongson, smp: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from loongson/smp.

Signed-off-by: Chen, Gong 
---
 arch/mips/loongson/loongson-3/smp.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/mips/loongson/loongson-3/smp.c 
b/arch/mips/loongson/loongson-3/smp.c
index 1e88940..30b91e8 100644
--- a/arch/mips/loongson/loongson-3/smp.c
+++ b/arch/mips/loongson/loongson-3/smp.c
@@ -389,20 +389,17 @@ void play_dead(void)
play_dead_at_ckseg1(state_addr);
 }
 
-#define CPU_POST_DEAD_FROZEN   (CPU_POST_DEAD | CPU_TASKS_FROZEN)
 static int loongson3_cpu_callback(struct notifier_block *nfb,
unsigned long action, void *hcpu)
 {
unsigned int cpu = (unsigned long)hcpu;
 
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_POST_DEAD:
-   case CPU_POST_DEAD_FROZEN:
pr_info("Disable clock for CPU#%d\n", cpu);
LOONGSON_CHIPCFG0 &= ~(1 << (12 + cpu));
break;
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
pr_info("Enable clock for CPU#%d\n", cpu);
LOONGSON_CHIPCFG0 |= 1 << (12 + cpu);
break;
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v1 26/70] rcu, tree: _FROZEN Cleanup

2014-07-22 Thread Chen, Gong
Remove XXX_FROZEN state from rcu/tree.

Signed-off-by: Chen, Gong 
---
 kernel/rcu/tree.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 625d0b0..8518338 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3440,28 +3440,26 @@ static int rcu_cpu_notify(struct notifier_block *self,
struct rcu_state *rsp;
 
trace_rcu_utilization(TPS("Start CPU hotplug"));
-   switch (action) {
+   switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
-   case CPU_UP_PREPARE_FROZEN:
rcu_prepare_cpu(cpu);
rcu_prepare_kthreads(cpu);
break;
case CPU_ONLINE:
case CPU_DOWN_FAILED:
-   rcu_boost_kthread_setaffinity(rnp, -1);
+   if (!(action & CPU_TASKS_FROZEN))
+   rcu_boost_kthread_setaffinity(rnp, -1);
break;
case CPU_DOWN_PREPARE:
-   rcu_boost_kthread_setaffinity(rnp, cpu);
+   if (!(action & CPU_TASKS_FROZEN))
+   rcu_boost_kthread_setaffinity(rnp, cpu);
break;
case CPU_DYING:
-   case CPU_DYING_FROZEN:
for_each_rcu_flavor(rsp)
rcu_cleanup_dying_cpu(rsp);
break;
case CPU_DEAD:
-   case CPU_DEAD_FROZEN:
case CPU_UP_CANCELED:
-   case CPU_UP_CANCELED_FROZEN:
for_each_rcu_flavor(rsp)
rcu_cleanup_dead_cpu(cpu, rsp);
break;
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   >