Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754168AbYJQI5r (ORCPT ); Fri, 17 Oct 2008 04:57:47 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752072AbYJQI5f (ORCPT ); Fri, 17 Oct 2008 04:57:35 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:63711 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752029AbYJQI5e (ORCPT ); Fri, 17 Oct 2008 04:57:34 -0400 Message-ID: <48F852FD.7070108@cn.fujitsu.com> Date: Fri, 17 Oct 2008 16:55:25 +0800 From: Lai Jiangshan User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: Ingo Molnar CC: Linux Kernel Mailing List Subject: [PATCH] x86/proc: fix /proc/cpuinfo cpu offline bug Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1386 Lines: 48 In my test, I found that if a cpu has been offline, the next cpus may not be shown in the /proc/cpuinfo. trivially reproduce this bug: 1) add these lines in the end of show_cpuinfo() if (m->size - m->count - 20 > 0) seq_printf(m, "%*s", (int)(m->size - m->count - 20), "show bug\n"); 2) rebuilt kernel & reboot 3) offline cpu#1 4) cat /proc/cpuinfo cpu#2 and cpu#3 .... cannot be shown in /proc/cpuinfo Signed-off-by: Lai Jiangshan --- diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c index a26c480..01b1244 100644 --- a/arch/x86/kernel/cpu/proc.c +++ b/arch/x86/kernel/cpu/proc.c @@ -160,14 +160,16 @@ static void *c_start(struct seq_file *m, loff_t *pos) { if (*pos == 0) /* just in case, cpu 0 is not the first */ *pos = first_cpu(cpu_online_map); - if ((*pos) < nr_cpu_ids && cpu_online(*pos)) + else + *pos = next_cpu_nr(*pos - 1, cpu_online_map); + if ((*pos) < nr_cpu_ids) return &cpu_data(*pos); return NULL; } static void *c_next(struct seq_file *m, void *v, loff_t *pos) { - *pos = next_cpu(*pos, cpu_online_map); + (*pos)++; return c_start(m, pos); } -- 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/