Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261650AbVAIRKn (ORCPT ); Sun, 9 Jan 2005 12:10:43 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261646AbVAIRKn (ORCPT ); Sun, 9 Jan 2005 12:10:43 -0500 Received: from fsmlabs.com ([168.103.115.128]:47007 "EHLO fsmlabs.com") by vger.kernel.org with ESMTP id S261650AbVAIRKd (ORCPT ); Sun, 9 Jan 2005 12:10:33 -0500 Date: Sun, 9 Jan 2005 10:10:11 -0700 (MST) From: Zwane Mwaikambo To: Andi Kleen cc: Andrew Morton , Linux Kernel Subject: Re: [PATCH] x86_64: Notify user of MCE events (updated) In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1968 Lines: 58 x86_64 uses a userspace mce utility to decode MCEs, this patch will ensure that the user is notified of MCE events being logged too. Updated to incorporate suggestions from Andi Kleen. Signed-off-by: Zwane Mwaikambo Index: linux-2.6.10-mm1/arch/x86_64/kernel/mce.c =================================================================== RCS file: /home/cvsroot/linux-2.6.10-mm1/arch/x86_64/kernel/mce.c,v retrieving revision 1.1.1.1 diff -u -p -B -r1.1.1.1 mce.c --- linux-2.6.10-mm1/arch/x86_64/kernel/mce.c 4 Jan 2005 04:03:35 -0000 1.1.1.1 +++ linux-2.6.10-mm1/arch/x86_64/kernel/mce.c 9 Jan 2005 17:09:39 -0000 @@ -31,6 +31,8 @@ static int mce_dont_init; static int tolerant = 1; static int banks; static unsigned long bank[NR_BANKS] = { [0 ... NR_BANKS-1] = ~0UL }; +static unsigned long console_logged; +static int notify_user; /* * Lockless MCE logging infrastructure. @@ -68,6 +70,9 @@ void mce_log(struct mce *mce) smp_wmb(); mcelog.entry[entry].finished = 1; smp_wmb(); + + if (!test_and_set_bit(0, &console_logged)) + notify_user = 1; } static void print_mce(struct mce *m) @@ -252,6 +257,19 @@ static void mcheck_timer(void *data) { on_each_cpu(mcheck_check_cpu, NULL, 1, 1); schedule_delayed_work(&mcheck_work, check_interval * HZ); + + /* + * It's ok to read stale data here for notify_user and + * console_logged as we'll simply get the updated versions + * on the next mcheck_timer execution and atomic operations + * on console_logged act as synchronization for notify_user + * writes. + */ + if (notify_user && console_logged) { + notify_user = 0; + clear_bit(0, &console_logged); + printk(KERN_EMERG "Machine check exception logged\n"); + } } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/