Skip to content

Commit 0dcd91a

Browse files
Sebastian OttMartin Schwidefsky
authored andcommitted
s390/debug: only write data once
debug_event_common memsets the active debug entry with zeros to prevent stale data leakage. This is overwritten with the actual debug data in the next step. Only write zeros to that part of the debug entry that's not used by new debug data. Micro benchmarks show a 2-10% reduction of cpu cycles with this approach. Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Acked-by: Michael Holzheu <holzheu@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent 94158e5 commit 0dcd91a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎arch/s390/kernel/debug.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,9 @@ debug_entry_t *debug_event_common(debug_info_t *id, int level, const void *buf,
902902
}
903903
do {
904904
active = get_active_entry(id);
905-
memset(DEBUG_DATA(active), 0, id->buf_size);
906905
memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size));
906+
if (len < id->buf_size)
907+
memset((DEBUG_DATA(active)) + len, 0, id->buf_size - len);
907908
debug_finish_entry(id, active, level, 0);
908909
len -= id->buf_size;
909910
buf += id->buf_size;
@@ -934,8 +935,9 @@ debug_entry_t *debug_exception_common(debug_info_t *id, int level,
934935
}
935936
do {
936937
active = get_active_entry(id);
937-
memset(DEBUG_DATA(active), 0, id->buf_size);
938938
memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size));
939+
if (len < id->buf_size)
940+
memset((DEBUG_DATA(active)) + len, 0, id->buf_size - len);
939941
debug_finish_entry(id, active, level, len <= id->buf_size);
940942
len -= id->buf_size;
941943
buf += id->buf_size;

0 commit comments

Comments
 (0)