Received: by 10.223.176.46 with SMTP id f43csp749849wra; Fri, 26 Jan 2018 06:22:46 -0800 (PST) X-Google-Smtp-Source: AH8x226uUvwtQm6S0BYInmRvQq/qK1L6TWKFU7YJPfsgOac6dWJgIH01XFC3KeWw8Fn2F3g4+Mwm X-Received: by 2002:a17:902:3103:: with SMTP id w3-v6mr5561745plb.3.1516976566793; Fri, 26 Jan 2018 06:22:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516976566; cv=none; d=google.com; s=arc-20160816; b=hvooL0wFUb3R2K7ijplB36AU4MLxPQi+tVyRvD6lqllIRbCp6dDNrIgta3rpYlBScp ctyCN4oiszJFoZZpJrMb4Dpbu4OTdT6jO1XIF8R+AKi01O2FwOkSv/hNGLCXUEnH5YvG x59BzuOWQZbDTnMYVTYfPwAlDsoQ4pVrjvVaKDV6GJcYnUYx0FfDr1Op8QLTQwjouuRc iZwsXKpgE949a+K1Y7D9F3eDRRh7dvlnSot2lazaLGViA1PlD8pzo5mEM3mTtLtnGP5+ g2ze1FzCaaew1p9OW3z1fPTalDhru0YvFhAYJ1mpcii31daY3zTWHHUPJmHwy+BczLtF vFDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=iK7SjSZy/62VMFtMFLVMePNu3WOGvLroKLMuhjmaMzg=; b=G2+CheCfRv94iXe/ja8OUrQiQl9pMfzCGmDQfOs3i6SNS7gvm7t+t2Sdl++njtqy9N mNbYyU/b7+4mVF8/35ahMxKtnKJF2t/K6y8dYtMhqJ3jAKBEIJa2VKotgj5/kKrgwsSa Ql2e6M8ebD82krCDrsAQhUSC2TVAWfxVCMVfIJwlrvcSvPxwmzFOyCFrsNfmZV1Q4Amr UJjFTct9ZqgPHVM6LQ3ELyBpGrxYKiBFMwhK/wfjQlcE20DpciqzJKtHPfF5SXqmrNAj MXzc2cAHDfi/lV/FJB0RzhmpO3Sx25z6ZtROZMo4AUOG4RPVBYRCPF5xqUilQ8ixXWHL ck8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dsT63nnc; 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 v10-v6si3732801ply.177.2018.01.26.06.22.32; Fri, 26 Jan 2018 06:22:46 -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=dsT63nnc; 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 S1752853AbeAZOUy (ORCPT + 99 others); Fri, 26 Jan 2018 09:20:54 -0500 Received: from mail-oi0-f68.google.com ([209.85.218.68]:37611 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752722AbeAZOUw (ORCPT ); Fri, 26 Jan 2018 09:20:52 -0500 Received: by mail-oi0-f68.google.com with SMTP id t78so394282oih.4 for ; Fri, 26 Jan 2018 06:20:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=iK7SjSZy/62VMFtMFLVMePNu3WOGvLroKLMuhjmaMzg=; b=dsT63nncA5BYUzacKLTwto+AFSE3vFC1zxeXU04LX5qK6qsR/tWK3CarkxV9AM5APh Yh/NQcTQ4XTtyIi2pBUHOsDSJLg0qTfJmHRLSAiDbXm5QWfouoWqGkx9PGkg2xau46K7 7zI4L3JXJ7UT4jnwmaPOtgv+lRVxPmXI55wtA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=iK7SjSZy/62VMFtMFLVMePNu3WOGvLroKLMuhjmaMzg=; b=N6b1zDuHIV1SJkuUoFFKYNmV1FOKca2BOfOO2waaJ5z3RXK97JOqv9V1w6M3CSbhWU mzQ2L729lqe2Gzw1CAn4XT0Gbpm/pXs4Oa5JBDlQrm5RnS4R6c5H+J0Gi+QzFE76CmUt VrfrvIBWC9b7VY7USCtYVeiMzGXKvRYl3hFseYBEJG9gYFnQdoUyi4dleFsjbbyWDxjL FShE4SrBlyhBweJw/Agfi2TC4WKD0UtqdiuAIBZcKokMr2BJi3/sZt4Np1jW2bvwMhZr rPo2KtikEDsc52UDkgjRF3rAtVfO0D43J7ALUzEbziH4adbmZ2ll4WVNMS1Uc9bPgugX 0Nyg== X-Gm-Message-State: AKwxyteDkh29mSc2pRlWTGv+RcYZZpCoJ3ey5j+q3m+CDQwSltVcqS07 UzKufITyB0hhuspEsfanQWcdmWpMlFcRK/qKt9Rkrw== X-Received: by 10.202.55.84 with SMTP id e81mr12098392oia.303.1516976452200; Fri, 26 Jan 2018 06:20:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.68.147 with HTTP; Fri, 26 Jan 2018 06:20:51 -0800 (PST) In-Reply-To: <20180126140033.ix2n7j62k6iccmdh@oak.lan> References: <20180126140033.ix2n7j62k6iccmdh@oak.lan> From: Baolin Wang Date: Fri, 26 Jan 2018 22:20:51 +0800 Message-ID: Subject: Re: [PATCH] kdb: use ktime_get_seconds() instead of ktime_get_ts() To: Daniel Thompson Cc: Arnd Bergmann , Jason Wessel , Ingo Molnar , Mark Brown , kgdb-bugreport@lists.sourceforge.net, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26 January 2018 at 22:00, Daniel Thompson wrote: > On Fri, Jan 26, 2018 at 10:21:58AM +0100, Arnd Bergmann wrote: >> On Fri, Jan 26, 2018 at 4:03 AM, Baolin Wang wrote: >> > 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. >> > >> > Since kdb is only interested in the second field, we can use the >> > ktime_get_seconds() to get the monotonic time without a lock, >> > moreover we can remove the 'struct timespec', which is not y2038 >> > safe. >> > >> > Signed-off-by: Baolin Wang >> > --- >> > kernel/debug/kdb/kdb_main.c | 4 +--- >> > 1 file changed, 1 insertion(+), 3 deletions(-) >> > >> > diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c >> > index 69e70f4..f0fc6f7 100644 >> > --- a/kernel/debug/kdb/kdb_main.c >> > +++ b/kernel/debug/kdb/kdb_main.c >> > @@ -2486,10 +2486,8 @@ static int kdb_kill(int argc, const char **argv) >> > */ >> > static void kdb_sysinfo(struct sysinfo *val) >> > { >> > - struct timespec uptime; >> > - ktime_get_ts(&uptime); >> > memset(val, 0, sizeof(*val)); >> > - val->uptime = uptime.tv_sec; >> > + val->uptime = ktime_get_seconds(); >> > val->loads[0] = avenrun[0]; >> > val->loads[1] = avenrun[1]; >> > val->loads[2] = avenrun[2]; >> >> Using ktime_get_seconds() avoids locking problems, but I wonder what >> would happen if we trigger the 'WARN_ON(timekeeping_suspended)' >> from kdb. Is that a problem? If it is, we have to use ktime_get_mono_fast_ns() >> and div_u64() instead. > > Normally a WARN_ON() doesn't triggered a kgdb_breakpoint() so (apart > from bugs) we can start executing the warning. Unfortunately > kdb_trap_printk isn't set when we call ktime_get_seconds() so printing > the warning isn't safe. > > If we had no choice of time function we could work around by > enabling printk() trapping for the call but since ktime_get_mono_fast_ns() > already exists its probably best just to use that. > If timekeeping_suspended is set, which means the system had been in suspend state. So now we still need debugger the system? But cores were already powered down. The ktime_get_mono_fast_ns() will access the the clocksource driver, if the timekeeping is suspended following system suspend and the clocksource is not SUSPEND_NONSTOP, we may meet some unexpected issue to access the timer's register without clock. So I am not sure if ktime_get_mono_fast_ns() can work well for this case. -- Baolin.wang Best Regards