Received: by 10.223.176.5 with SMTP id f5csp2368746wra; Sun, 28 Jan 2018 19:03:41 -0800 (PST) X-Google-Smtp-Source: AH8x226dxQ/H+FT7BZSBO0dc5I/rZi7dl8Q5HL/svUIfw0ZG8bmF318TZGNO+pVgHAq6/ea04aFC X-Received: by 10.99.123.91 with SMTP id k27mr20460255pgn.179.1517195021680; Sun, 28 Jan 2018 19:03:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517195021; cv=none; d=google.com; s=arc-20160816; b=buLR57hc1k5kFURKvIc5SqOi/UAhnpXuoMR6UoFlbhZWAyMglLrj5Q8ik5q5dT6zOY qzOUXTYqRVLJrK+Y9fwtm0Kj6FEEH0xxeDkPRwwM2fg4zMcwPcv+T46QenmYHRNAA9PB I5zPAxdtRE2AK5UsrYTbXlIKyLajdlUmZbtMJZ/rczJhUH8fJ6a6e3WQUXeUrwiBSttM yV4BWKdRdxx9lSOOF2oiQTtnvvxCOiAcfO1HcQJAim+YYaduTZoiK/qiPXZIq0VrCIjG 6PJMPrD9LcMqJMf+wSLNahALNosjH1EVT0WxrxNql1yh6LYvO1vl75h4ayrm4xqFSjv0 f1hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=fwomKeLj7K7vKKcA08H1uke9DN/jxFXXMEHdrUdbAoY=; b=OHMDAVx/7GRJUBiPEifnGwXYGazAcEZA2r3uclohX8Ze/nIN+QyVAV0VfBCU2NEpGO 13f7UDy0ffZBRf8LhJVjBYzakmsK0827BjmfLBMsFbHUMyWGEcBPmiwyJ2dZHk3RniAd sA8KEryz8tZM4Je6Iwf6fGwNPTfy7sS0zPyCFKrzFQTV1K3d0toZuUUn9du30G5d3L/t Ge40OOJFo2+G52Sd8DTEaWMKnloXDdC4gsPsEvGfuuR3xhQTCxuQMFyLpOCW1e6QE1Og CTMCjHKM2Gkq2hvYCPZwg00OpbNLHekZYKrpqUPXu01v4FKvQVbIFixspTanPi+UuhQK ukkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NapKGyga; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i17si10842874pfk.151.2018.01.28.19.03.27; Sun, 28 Jan 2018 19:03:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NapKGyga; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932731AbeA2CX6 (ORCPT + 99 others); Sun, 28 Jan 2018 21:23:58 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:34811 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932710AbeA2CX5 (ORCPT ); Sun, 28 Jan 2018 21:23:57 -0500 Received: by mail-pf0-f196.google.com with SMTP id e76so3596507pfk.1 for ; Sun, 28 Jan 2018 18:23:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=fwomKeLj7K7vKKcA08H1uke9DN/jxFXXMEHdrUdbAoY=; b=NapKGygaC5QDqK9SHgYHSTAQNkun9CKTHjOYnZP0pB49CICZdN9lU3mqC+Db7bnhJ5 5l+gEBdNnhKcDv40ooZsDQvIxG6dZzSCYFltAc/1e+5JhC0hZ44HtAg6I7aXyMwaM5zH 48phzs8xdqLFQw8Pj+QgjJPlg5AZ+diZ96vas= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fwomKeLj7K7vKKcA08H1uke9DN/jxFXXMEHdrUdbAoY=; b=C1IVEDaWSshqhnlUBShDTqdxaedSnz9WoizR5HhoOaxx/mJeMIh82mUtxZlBxUkbiN Ekv8sgbcdrjvUE5UKWAB5Sy/CSfk7NGqkIFs1v+EpKQF2DkYqUCwtdN642ZZ4EHybSnV wgYFoH3D039lRrb+HukzTsH2MfKdSMlTWhFLf7VOY0ZmEQ8vF//h0cWbO3XB8fDd/xUJ PzA8S7z3dcD7UaMJ0262M7xHZz1j6auSF6iurHyOR2Vj2oX+huBvk3r1R13j1BRQuRdW YMYZ+6WIzhxbRYf0jZGOyugJGSgv1ByG8ZNwkwBXU51O7kf2YbMC1vGHL5+kCacvfS0f 4DAg== X-Gm-Message-State: AKwxytc2y4yM3nZSgd0VbXQNFNIkmGEkv6hSJhc2Ym9QEf/A9pBPE6IO Av9GQEGzMGiay0xBwFsqtvzEhA== X-Received: by 2002:a17:902:82cb:: with SMTP id u11-v6mr213071plz.391.1517192636568; Sun, 28 Jan 2018 18:23:56 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id y5sm29051283pfd.163.2018.01.28.18.23.52 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 28 Jan 2018 18:23:55 -0800 (PST) From: Baolin Wang To: jason.wessel@windriver.com, daniel.thompson@linaro.org Cc: mingo@kernel.org, arnd@arndb.de, broonie@kernel.org, kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH v2] kdb: use ktime_get_mono_fast_ns() instead of ktime_get_ts() Date: Mon, 29 Jan 2018 10:22:51 +0800 Message-Id: <3f15868475cb4b32353885ee03c983209279fa81.1517192387.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kdb code will print the monotonic time by ktime_get_ts(), but the ktime_get_ts() will be protected by a sequence lock, that will introduce one deadlock risk if the lock was already held in the context from which we entered the debugger. Thus we can use the ktime_get_mono_fast_ns() to get the monotonic time, which is NMI safe access to clock monotonic. Moreover we can remove the 'struct timespec', which is not y2038 safe. Signed-off-by: Baolin Wang --- Changes since v1: - Use ktime_get_mono_fast_ns() instead of ktime_get_seconds(). --- kernel/debug/kdb/kdb_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index 69e70f4..bf1d0e0 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c @@ -2486,10 +2486,10 @@ static int kdb_kill(int argc, const char **argv) */ static void kdb_sysinfo(struct sysinfo *val) { - struct timespec uptime; - ktime_get_ts(&uptime); + u64 uptime = ktime_get_mono_fast_ns(); + memset(val, 0, sizeof(*val)); - val->uptime = uptime.tv_sec; + val->uptime = div_u64(uptime, NSEC_PER_SEC); val->loads[0] = avenrun[0]; val->loads[1] = avenrun[1]; val->loads[2] = avenrun[2]; -- 1.7.9.5