mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tile kgdb: fix bug in copy to gdb regs, and optimize memset
       [not found] <DUB128-W66DCB8DE4A3DFA72EBCD879CC60@phx.gbl>
@ 2016-01-26 17:33 ` Chris Metcalf
  0 siblings, 0 replies; only message in thread
From: Chris Metcalf @ 2016-01-26 17:33 UTC (permalink / raw)
  To: linux-kernel, David Binderman; +Cc: Chris Metcalf

David Binderman pointed out that we were doing a full memset()
of the gdb register buffer and then doing a memcpy() to it that
was almost as big.  This commit optimizes that by only doing a
memset() of the registers that are intended to be zero.

While making this change I noticed that we were not copying the
link register (LR, number 55) due to a fencepost error in commit
f419e6f63c5a ("arch: tile: kernel: kgdb.c: Use memcpy() instead of
pointer copy one by one"), and I've corrected that as well.

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
---
 arch/tile/kernel/kgdb.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/tile/kernel/kgdb.c b/arch/tile/kernel/kgdb.c
index a506c2c28943..6ad99925900e 100644
--- a/arch/tile/kernel/kgdb.c
+++ b/arch/tile/kernel/kgdb.c
@@ -126,15 +126,15 @@ void
 sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *task)
 {
 	struct pt_regs *thread_regs;
+	const int NGPRS = TREG_LAST_GPR + 1;
 
 	if (task == NULL)
 		return;
 
-	/* Initialize to zero. */
-	memset(gdb_regs, 0, NUMREGBYTES);
-
 	thread_regs = task_pt_regs(task);
-	memcpy(gdb_regs, thread_regs, TREG_LAST_GPR * sizeof(unsigned long));
+	memcpy(gdb_regs, thread_regs, NGPRS * sizeof(unsigned long));
+	memset(&gdb_regs[NGPRS], 0,
+	       (TILEGX_PC_REGNUM - NGPRS) * sizeof(unsigned long));
 	gdb_regs[TILEGX_PC_REGNUM] = thread_regs->pc;
 	gdb_regs[TILEGX_FAULTNUM_REGNUM] = thread_regs->faultnum;
 }
-- 
2.1.2

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-01-26 17:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <DUB128-W66DCB8DE4A3DFA72EBCD879CC60@phx.gbl>
2016-01-26 17:33 ` [PATCH] tile kgdb: fix bug in copy to gdb regs, and optimize memset Chris Metcalf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®