Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1233197 > unrolled thread

[PATCH] x86/kgdb: Replace bool_int_array[NR_CPUS] with bitmap

Started byDenys Vlasenko <dvlasenk@redhat.com>
First post2015-09-26 14:50 +0200
Last post2015-09-29 10:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] x86/kgdb: Replace bool_int_array[NR_CPUS] with bitmap Denys Vlasenko <dvlasenk@redhat.com> - 2015-09-26 14:50 +0200
    [tip:x86/debug] x86/kgdb: Replace bool_int_array[NR_CPUS]   with bitmap tip-bot for Denys Vlasenko <tipbot@zytor.com> - 2015-09-29 10:50 +0200

#1233197 — [PATCH] x86/kgdb: Replace bool_int_array[NR_CPUS] with bitmap

FromDenys Vlasenko <dvlasenk@redhat.com>
Date2015-09-26 14:50 +0200
Subject[PATCH] x86/kgdb: Replace bool_int_array[NR_CPUS] with bitmap
Message-ID<qcX5o-dn-13@gated-at.bofh.it>
Straigntforward conversion from
    int was_in_debug_nmi[NR_CPUS]
to
    DECLARE_BITMAP(was_in_debug_nmi, NR_CPUS)

Saves about 2 kbytes in bss for NR_CPUS=512.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
CC: Jason Wessel <jason.wessel@windriver.com>
CC: Ingo Molnar <mingo@kernel.org>
CC: H. Peter Anvin <hpa@zytor.com>
CC: x86@kernel.org
CC: linux-kernel@vger.kernel.org
---
 arch/x86/kernel/kgdb.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
index d6178d9..dd0a003 100644
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -511,24 +511,27 @@ single_step_cont(struct pt_regs *regs, struct die_args *args)
 	return NOTIFY_STOP;
 }
 
-static int was_in_debug_nmi[NR_CPUS];
+static DECLARE_BITMAP(was_in_debug_nmi, NR_CPUS);
 
 static int kgdb_nmi_handler(unsigned int cmd, struct pt_regs *regs)
 {
+	int cpu;
+
 	switch (cmd) {
 	case NMI_LOCAL:
 		if (atomic_read(&kgdb_active) != -1) {
 			/* KGDB CPU roundup */
-			kgdb_nmicallback(raw_smp_processor_id(), regs);
-			was_in_debug_nmi[raw_smp_processor_id()] = 1;
+			cpu = raw_smp_processor_id();
+			kgdb_nmicallback(cpu, regs);
+			set_bit(cpu, was_in_debug_nmi);
 			touch_nmi_watchdog();
 			return NMI_HANDLED;
 		}
 		break;
 
 	case NMI_UNKNOWN:
-		if (was_in_debug_nmi[raw_smp_processor_id()]) {
-			was_in_debug_nmi[raw_smp_processor_id()] = 0;
+		cpu = raw_smp_processor_id();
+		if (__test_and_clear_bit(cpu, was_in_debug_nmi)) {
 			return NMI_HANDLED;
 		}
 		break;
-- 
1.8.1.4

--
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/

[toc] | [next] | [standalone]


#1234861 — [tip:x86/debug] x86/kgdb: Replace bool_int_array[NR_CPUS] with bitmap

Fromtip-bot for Denys Vlasenko <tipbot@zytor.com>
Date2015-09-29 10:50 +0200
Subject[tip:x86/debug] x86/kgdb: Replace bool_int_array[NR_CPUS] with bitmap
Message-ID<qdYLP-1nH-71@gated-at.bofh.it>
In reply to#1233197
Commit-ID:  0d44975d1e2791f6df2b84b182f49d815ba3c9e0
Gitweb:     http://git.kernel.org/tip/0d44975d1e2791f6df2b84b182f49d815ba3c9e0
Author:     Denys Vlasenko <dvlasenk@redhat.com>
AuthorDate: Sat, 26 Sep 2015 14:47:17 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 28 Sep 2015 10:13:31 +0200

x86/kgdb: Replace bool_int_array[NR_CPUS] with bitmap

Straigntforward conversion from:

    int was_in_debug_nmi[NR_CPUS]

to:

    DECLARE_BITMAP(was_in_debug_nmi, NR_CPUS)

Saves about 2 kbytes in BSS for NR_CPUS=512.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/1443271638-2568-1-git-send-email-dvlasenk@redhat.com
[ Tidied up the code a bit. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/kgdb.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
index d6178d9..44256a6 100644
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -511,26 +511,31 @@ single_step_cont(struct pt_regs *regs, struct die_args *args)
 	return NOTIFY_STOP;
 }
 
-static int was_in_debug_nmi[NR_CPUS];
+static DECLARE_BITMAP(was_in_debug_nmi, NR_CPUS);
 
 static int kgdb_nmi_handler(unsigned int cmd, struct pt_regs *regs)
 {
+	int cpu;
+
 	switch (cmd) {
 	case NMI_LOCAL:
 		if (atomic_read(&kgdb_active) != -1) {
 			/* KGDB CPU roundup */
-			kgdb_nmicallback(raw_smp_processor_id(), regs);
-			was_in_debug_nmi[raw_smp_processor_id()] = 1;
+			cpu = raw_smp_processor_id();
+			kgdb_nmicallback(cpu, regs);
+			set_bit(cpu, was_in_debug_nmi);
 			touch_nmi_watchdog();
+
 			return NMI_HANDLED;
 		}
 		break;
 
 	case NMI_UNKNOWN:
-		if (was_in_debug_nmi[raw_smp_processor_id()]) {
-			was_in_debug_nmi[raw_smp_processor_id()] = 0;
+		cpu = raw_smp_processor_id();
+
+		if (__test_and_clear_bit(cpu, was_in_debug_nmi))
 			return NMI_HANDLED;
-		}
+
 		break;
 	default:
 		/* do nothing */
--
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/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web