Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2475349pxj; Sat, 19 Jun 2021 13:32:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB3z+vpaaKxj/ZHqFgkt8kPLE2p9axVIVerrbQqPd1rFHkhKZUhwC8u5aodNMfnaO7lIKN X-Received: by 2002:a05:6402:26d3:: with SMTP id x19mr12832442edd.234.1624134723939; Sat, 19 Jun 2021 13:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624134723; cv=none; d=google.com; s=arc-20160816; b=LUdbFm6fWlMyxuycakiCH3vOg3q5nFulLsUKk1Cy1voBycrYq7IvOHl0lc2w1i7Onn uSqz4SgmboYgDy4ywNGnPwTtCGcfVYDVgmdoYsNZL6+o8MMOEtkQA4VlTOT0IEolVE74 50DWb0IYiEshysOtPwF1CJyks8XiRw19YMij+YRC/22B/HoBUPAhbz3aZcCfc4kM1FDf vsyr3AQDQ1w8IGPTW81MshC1T0JDHmvHhGL+jAoXQ1vvDIoqpgs/zoL+uXXJ7bzNP2nC /ApkF5ULyNXDfRNGJ5sIiQCwnCVVRUTwdsd58xa26TqJJNclirx1lj6XlKriTLdQxHxA asEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=oH2jSKB0oG9E10s3UDyes7hq07Qau1J6SSPiext+Trw=; b=RAuP3g/W10V7bXFyOissr1m2SB48vcQVZi4A/8tv1UWdT95YFM285qOicXX2vxfYuS /VnoYpqPj/qCFziiXAYfCUEv7prMsF7web1GBYiIOAmQzSFQfcbdFNqnXDr/Kczhj9me H2X0yg6LmCB8EwV7uBw4x7Wv+j987ik43VhSgcKf+ENVN5Tm45LOTXm2f2qHIQ6PDk5g EmOVFYfhOgH0DAUkR9JfV5p3JVYyYuGvUGDXl9mlbYmkWiSXucrDIMLoO1OOYDmhd7gp OJsT0ZjwdbIrKAGbtVj4b+tnfpZ8IEU10nI2qDFr80a8wU0hr8oTEkDzTLEZgaqnzTfF V5Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JH4xBrXd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c21si7184918edv.215.2021.06.19.13.31.42; Sat, 19 Jun 2021 13:32:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JH4xBrXd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233035AbhFSKxZ (ORCPT + 99 others); Sat, 19 Jun 2021 06:53:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:39020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233143AbhFSKxU (ORCPT ); Sat, 19 Jun 2021 06:53:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 212246120A; Sat, 19 Jun 2021 10:51:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624099869; bh=aUsPX+nFItWHPd+EdQgT8+dhm7c6uNdqhHhjptNmOss=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=JH4xBrXd9BAC3Lr6WW2Yw6oT09Zeci220I4NDA/EKgK1zDsyxNNszJf0gWFIHuBFc giTbZ8z/zqQPfp+TAFiD8vLwSAYAlzalyZUinyE3vdwT9fBEQi4xbrhQQ/Y1OUNYZe a5TapQqIoN601UmJ8uiBvhr4Wj/Eu+hiQflLWHbf/Rau6cW97a/RC38VsK11ZQy7+j yfeOICVOKKAv4PFi4ixHdO57QfCouJ+acLh43LJ7/wcmdGpWac8k23gO1UgYWQcfza B8S25Au7oNt+xZ/wZseDIqRniZCkzVE6wVoV3sRNVVHgmpqpoOnvj3rWWVBeNnW3dm EF4H1ScNWJJLQ== Message-ID: Subject: Re: [PATCH] net: ceph: Use CLOCK_MONOTONIC ktime_get_ts64() From: Jeff Layton To: Yejune Deng , idryomov@gmail.com, davem@davemloft.net, kuba@kernel.org Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sat, 19 Jun 2021 06:51:08 -0400 In-Reply-To: <20210618142740.3345-1-yejune.deng@gmail.com> References: <20210618142740.3345-1-yejune.deng@gmail.com> Content-Type: text/plain; charset="ISO-8859-15" User-Agent: Evolution 3.40.2 (3.40.2-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2021-06-18 at 22:27 +0800, Yejune Deng wrote: > The Documentation/core-api/timekeeping.rst recommend that we should use > monotonic time ktime_get_ts64(), to avoid glitches with a concurrent > settimeofday(). > > Signed-off-by: Yejune Deng > --- > net/ceph/messenger.c | 2 +- > net/ceph/messenger_v1.c | 2 +- > net/ceph/messenger_v2.c | 2 +- > net/ceph/osd_client.c | 4 ++-- > 4 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c > index 57d043b..2d07ab5 100644 > --- a/net/ceph/messenger.c > +++ b/net/ceph/messenger.c > @@ -1809,7 +1809,7 @@ bool ceph_con_keepalive_expired(struct ceph_connection *con, > (con->peer_features & CEPH_FEATURE_MSGR_KEEPALIVE2)) { > struct timespec64 now; > struct timespec64 ts; > - ktime_get_real_ts64(&now); > + ktime_get_ts64(&now); > jiffies_to_timespec64(interval, &ts); > ts = timespec64_add(con->last_keepalive_ack, ts); > return timespec64_compare(&now, &ts) >= 0; > diff --git a/net/ceph/messenger_v1.c b/net/ceph/messenger_v1.c > index 2cb5ffd..2ec7b1d 100644 > --- a/net/ceph/messenger_v1.c > +++ b/net/ceph/messenger_v1.c > @@ -310,7 +310,7 @@ static void prepare_write_keepalive(struct ceph_connection *con) > if (con->peer_features & CEPH_FEATURE_MSGR_KEEPALIVE2) { > struct timespec64 now; > > - ktime_get_real_ts64(&now); > + ktime_get_ts64(&now); > con_out_kvec_add(con, sizeof(tag_keepalive2), &tag_keepalive2); > ceph_encode_timespec64(&con->v1.out_temp_keepalive2, &now); > con_out_kvec_add(con, sizeof(con->v1.out_temp_keepalive2), > diff --git a/net/ceph/messenger_v2.c b/net/ceph/messenger_v2.c > index cc40ce4..2125e77 100644 > --- a/net/ceph/messenger_v2.c > +++ b/net/ceph/messenger_v2.c > @@ -1439,7 +1439,7 @@ static int prepare_keepalive2(struct ceph_connection *con) > struct ceph_timespec *ts = CTRL_BODY(con->v2.out_buf); > struct timespec64 now; > > - ktime_get_real_ts64(&now); > + ktime_get_ts64(&now); > dout("%s con %p timestamp %lld.%09ld\n", __func__, con, now.tv_sec, > now.tv_nsec); > > diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c > index ff8624a..5192a8a 100644 > --- a/net/ceph/osd_client.c > +++ b/net/ceph/osd_client.c > @@ -4717,7 +4717,7 @@ ceph_osdc_watch(struct ceph_osd_client *osdc, > ceph_oid_copy(&lreq->t.base_oid, oid); > ceph_oloc_copy(&lreq->t.base_oloc, oloc); > lreq->t.flags = CEPH_OSD_FLAG_WRITE; > - ktime_get_real_ts64(&lreq->mtime); > + ktime_get_ts64(&lreq->mtime); > > lreq->reg_req = alloc_watch_request(lreq, CEPH_OSD_WATCH_OP_WATCH); > if (!lreq->reg_req) { > @@ -4767,7 +4767,7 @@ int ceph_osdc_unwatch(struct ceph_osd_client *osdc, > ceph_oid_copy(&req->r_base_oid, &lreq->t.base_oid); > ceph_oloc_copy(&req->r_base_oloc, &lreq->t.base_oloc); > req->r_flags = CEPH_OSD_FLAG_WRITE; > - ktime_get_real_ts64(&req->r_mtime); > + ktime_get_ts64(&req->r_mtime); > osd_req_op_watch_init(req, 0, lreq->linger_id, > CEPH_OSD_WATCH_OP_UNWATCH); > I think this is OK. Most of these timestamps get marshalled onto the wire to use as identifiers. Those are almost certainly better off with CLOCK_MONOTONIC since you could have a clock jump that caused you to send (e.g.) 2 keepalives with the same timestamp otherwise. Reviewed-by: Jeff Layton