Skip to content

Commit cb098d5

Browse files
committed
Merge tag 'for_linus-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/kgdb
Pull kdb updates from Jason Wessel: - fix 2032 time access issues and new compiler warnings - minor regression test cleanup - formatting fixes for end user use of kdb * tag 'for_linus-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/kgdb: kdb: use memmove instead of overlapping memcpy kdb: use ktime_get_mono_fast_ns() instead of ktime_get_ts() kdb: bl: don't use tab character in output kdb: drop newline in unknown command output kdb: make "mdr" command repeat kdb: use __ktime_get_real_seconds instead of __current_kernel_time misc: kgdbts: Display progress of asynchronous tests
2 parents 07820c3 + 2cf2f0d commit cb098d5

File tree

6 files changed

+51
-57
lines changed

6 files changed

+51
-57
lines changed

drivers/misc/kgdbts.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,14 @@ static void skip_back_repeat_test(char *arg)
400400
int go_back = simple_strtol(arg, NULL, 10);
401401

402402
repeat_test--;
403-
if (repeat_test <= 0)
403+
if (repeat_test <= 0) {
404404
ts.idx++;
405-
else
405+
} else {
406+
if (repeat_test % 100 == 0)
407+
v1printk("kgdbts:RUN ... %d remaining\n", repeat_test);
408+
406409
ts.idx -= go_back;
410+
}
407411
fill_get_buf(ts.tst[ts.idx].get);
408412
}
409413

include/linux/timekeeping.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct timespec64 get_monotonic_coarse64(void);
3131
extern void getrawmonotonic64(struct timespec64 *ts);
3232
extern void ktime_get_ts64(struct timespec64 *ts);
3333
extern time64_t ktime_get_seconds(void);
34+
extern time64_t __ktime_get_real_seconds(void);
3435
extern time64_t ktime_get_real_seconds(void);
3536
extern void ktime_get_active_ts64(struct timespec64 *ts);
3637

kernel/debug/kdb/kdb_bp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,11 @@ static void kdb_printbp(kdb_bp_t *bp, int i)
242242
kdb_symbol_print(bp->bp_addr, NULL, KDB_SP_DEFAULT);
243243

244244
if (bp->bp_enabled)
245-
kdb_printf("\n is enabled");
245+
kdb_printf("\n is enabled ");
246246
else
247247
kdb_printf("\n is disabled");
248248

249-
kdb_printf("\taddr at %016lx, hardtype=%d installed=%d\n",
249+
kdb_printf(" addr at %016lx, hardtype=%d installed=%d\n",
250250
bp->bp_addr, bp->bp_type, bp->bp_installed);
251251

252252
kdb_printf("\n");

kernel/debug/kdb/kdb_main.c

Lines changed: 40 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,16 @@ void kdb_set_current_task(struct task_struct *p)
11501150
kdb_current_regs = NULL;
11511151
}
11521152

1153+
static void drop_newline(char *buf)
1154+
{
1155+
size_t len = strlen(buf);
1156+
1157+
if (len == 0)
1158+
return;
1159+
if (*(buf + len - 1) == '\n')
1160+
*(buf + len - 1) = '\0';
1161+
}
1162+
11531163
/*
11541164
* kdb_local - The main code for kdb. This routine is invoked on a
11551165
* specific processor, it is not global. The main kdb() routine
@@ -1327,6 +1337,7 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
13271337
cmdptr = cmd_head;
13281338
diag = kdb_parse(cmdbuf);
13291339
if (diag == KDB_NOTFOUND) {
1340+
drop_newline(cmdbuf);
13301341
kdb_printf("Unknown kdb command: '%s'\n", cmdbuf);
13311342
diag = 0;
13321343
}
@@ -1566,6 +1577,7 @@ static int kdb_md(int argc, const char **argv)
15661577
int symbolic = 0;
15671578
int valid = 0;
15681579
int phys = 0;
1580+
int raw = 0;
15691581

15701582
kdbgetintenv("MDCOUNT", &mdcount);
15711583
kdbgetintenv("RADIX", &radix);
@@ -1575,9 +1587,10 @@ static int kdb_md(int argc, const char **argv)
15751587
repeat = mdcount * 16 / bytesperword;
15761588

15771589
if (strcmp(argv[0], "mdr") == 0) {
1578-
if (argc != 2)
1590+
if (argc == 2 || (argc == 0 && last_addr != 0))
1591+
valid = raw = 1;
1592+
else
15791593
return KDB_ARGCOUNT;
1580-
valid = 1;
15811594
} else if (isdigit(argv[0][2])) {
15821595
bytesperword = (int)(argv[0][2] - '0');
15831596
if (bytesperword == 0) {
@@ -1613,7 +1626,10 @@ static int kdb_md(int argc, const char **argv)
16131626
radix = last_radix;
16141627
bytesperword = last_bytesperword;
16151628
repeat = last_repeat;
1616-
mdcount = ((repeat * bytesperword) + 15) / 16;
1629+
if (raw)
1630+
mdcount = repeat;
1631+
else
1632+
mdcount = ((repeat * bytesperword) + 15) / 16;
16171633
}
16181634

16191635
if (argc) {
@@ -1630,7 +1646,10 @@ static int kdb_md(int argc, const char **argv)
16301646
diag = kdbgetularg(argv[nextarg], &val);
16311647
if (!diag) {
16321648
mdcount = (int) val;
1633-
repeat = mdcount * 16 / bytesperword;
1649+
if (raw)
1650+
repeat = mdcount;
1651+
else
1652+
repeat = mdcount * 16 / bytesperword;
16341653
}
16351654
}
16361655
if (argc >= nextarg+1) {
@@ -1640,8 +1659,15 @@ static int kdb_md(int argc, const char **argv)
16401659
}
16411660
}
16421661

1643-
if (strcmp(argv[0], "mdr") == 0)
1644-
return kdb_mdr(addr, mdcount);
1662+
if (strcmp(argv[0], "mdr") == 0) {
1663+
int ret;
1664+
last_addr = addr;
1665+
ret = kdb_mdr(addr, mdcount);
1666+
last_addr += mdcount;
1667+
last_repeat = mdcount;
1668+
last_bytesperword = bytesperword; // to make REPEAT happy
1669+
return ret;
1670+
}
16451671

16461672
switch (radix) {
16471673
case 10:
@@ -2473,52 +2499,17 @@ static int kdb_kill(int argc, const char **argv)
24732499
return 0;
24742500
}
24752501

2476-
struct kdb_tm {
2477-
int tm_sec; /* seconds */
2478-
int tm_min; /* minutes */
2479-
int tm_hour; /* hours */
2480-
int tm_mday; /* day of the month */
2481-
int tm_mon; /* month */
2482-
int tm_year; /* year */
2483-
};
2484-
2485-
static void kdb_gmtime(struct timespec *tv, struct kdb_tm *tm)
2486-
{
2487-
/* This will work from 1970-2099, 2100 is not a leap year */
2488-
static int mon_day[] = { 31, 29, 31, 30, 31, 30, 31,
2489-
31, 30, 31, 30, 31 };
2490-
memset(tm, 0, sizeof(*tm));
2491-
tm->tm_sec = tv->tv_sec % (24 * 60 * 60);
2492-
tm->tm_mday = tv->tv_sec / (24 * 60 * 60) +
2493-
(2 * 365 + 1); /* shift base from 1970 to 1968 */
2494-
tm->tm_min = tm->tm_sec / 60 % 60;
2495-
tm->tm_hour = tm->tm_sec / 60 / 60;
2496-
tm->tm_sec = tm->tm_sec % 60;
2497-
tm->tm_year = 68 + 4*(tm->tm_mday / (4*365+1));
2498-
tm->tm_mday %= (4*365+1);
2499-
mon_day[1] = 29;
2500-
while (tm->tm_mday >= mon_day[tm->tm_mon]) {
2501-
tm->tm_mday -= mon_day[tm->tm_mon];
2502-
if (++tm->tm_mon == 12) {
2503-
tm->tm_mon = 0;
2504-
++tm->tm_year;
2505-
mon_day[1] = 28;
2506-
}
2507-
}
2508-
++tm->tm_mday;
2509-
}
2510-
25112502
/*
25122503
* Most of this code has been lifted from kernel/timer.c::sys_sysinfo().
25132504
* I cannot call that code directly from kdb, it has an unconditional
25142505
* cli()/sti() and calls routines that take locks which can stop the debugger.
25152506
*/
25162507
static void kdb_sysinfo(struct sysinfo *val)
25172508
{
2518-
struct timespec uptime;
2519-
ktime_get_ts(&uptime);
2509+
u64 uptime = ktime_get_mono_fast_ns();
2510+
25202511
memset(val, 0, sizeof(*val));
2521-
val->uptime = uptime.tv_sec;
2512+
val->uptime = div_u64(uptime, NSEC_PER_SEC);
25222513
val->loads[0] = avenrun[0];
25232514
val->loads[1] = avenrun[1];
25242515
val->loads[2] = avenrun[2];
@@ -2533,8 +2524,8 @@ static void kdb_sysinfo(struct sysinfo *val)
25332524
*/
25342525
static int kdb_summary(int argc, const char **argv)
25352526
{
2536-
struct timespec now;
2537-
struct kdb_tm tm;
2527+
time64_t now;
2528+
struct tm tm;
25382529
struct sysinfo val;
25392530

25402531
if (argc)
@@ -2548,9 +2539,9 @@ static int kdb_summary(int argc, const char **argv)
25482539
kdb_printf("domainname %s\n", init_uts_ns.name.domainname);
25492540
kdb_printf("ccversion %s\n", __stringify(CCVERSION));
25502541

2551-
now = __current_kernel_time();
2552-
kdb_gmtime(&now, &tm);
2553-
kdb_printf("date %04d-%02d-%02d %02d:%02d:%02d "
2542+
now = __ktime_get_real_seconds();
2543+
time64_to_tm(now, 0, &tm);
2544+
kdb_printf("date %04ld-%02d-%02d %02d:%02d:%02d "
25542545
"tz_minuteswest %d\n",
25552546
1900+tm.tm_year, tm.tm_mon+1, tm.tm_mday,
25562547
tm.tm_hour, tm.tm_min, tm.tm_sec,

kernel/debug/kdb/kdb_support.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab)
129129
}
130130
if (i >= ARRAY_SIZE(kdb_name_table)) {
131131
debug_kfree(kdb_name_table[0]);
132-
memcpy(kdb_name_table, kdb_name_table+1,
132+
memmove(kdb_name_table, kdb_name_table+1,
133133
sizeof(kdb_name_table[0]) *
134134
(ARRAY_SIZE(kdb_name_table)-1));
135135
} else {
136136
debug_kfree(knt1);
137137
knt1 = kdb_name_table[i];
138-
memcpy(kdb_name_table+i, kdb_name_table+i+1,
138+
memmove(kdb_name_table+i, kdb_name_table+i+1,
139139
sizeof(kdb_name_table[0]) *
140140
(ARRAY_SIZE(kdb_name_table)-i-1));
141141
}

kernel/time/timekeeping_internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,4 @@ static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
3131
}
3232
#endif
3333

34-
extern time64_t __ktime_get_real_seconds(void);
35-
3634
#endif /* _TIMEKEEPING_INTERNAL_H */

0 commit comments

Comments
 (0)