From patchwork Mon Jan 29 02:22:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 126135 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp2061826ljd; Sun, 28 Jan 2018 18:24:03 -0800 (PST) X-Google-Smtp-Source: AH8x226l/61nPlxfuJjhaXs2CTeiUowVpskZWvjX3mk2jo+bt2cFNzBodX38ns9HIW7Ws5eCW9kw X-Received: by 2002:a17:902:14d:: with SMTP id 71-v6mr20597347plb.42.1517192643044; Sun, 28 Jan 2018 18:24:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517192643; cv=none; d=google.com; s=arc-20160816; b=p2mpGOxg2Lvyht3Egvl+qsPOKqnnngqiFCgncm29HXMPiPTehMb0c0Q+/gPbteTut/ Ccii1cRtmTs5X1wViJkeKFmpA51+hH+OCGRJnpx7oVS4UZPrr+E2I1un2LzFxfAu9Z6P I3ajBptUGMqy8WRruK5CBI+DZDDQAeCpcqb5sldQBFEjLFJRqVs5pG8hlcrVCYkeYswO lfjc1ekHYNVAEpHVvaMEUu7uVkrUg6X+PFcuvyCFidyoDJ0Ab1CLKID/FDgJL4aScFwB wnsV3nKpGyuSLMvtNKW1mKAK7TGCueblqsuFQQKhwk3bNO1cSkeupnpagKxF6exnBwAi jHTA== 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 2si10828396pfu.122.2018.01.28.18.24.02; Sun, 28 Jan 2018 18:24:03 -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 S932744AbeA2CX7 (ORCPT + 23 others); Sun, 28 Jan 2018 21:23:59 -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(-) -- 1.7.9.5 Reviewed-by: Daniel Thompson Reviewed-by: Arnd Bergmann 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];