Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp934633lqt; Fri, 19 Apr 2024 15:33:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW32in7NLy4vPHeg3zXn7kMRx6oI23LKJStcuqAtGPm61ueMR7H9DotfAKwmrXtnIjiHNXKli7gvfK9nUWJmEoNYAEwOgO67UkyuvhyWA== X-Google-Smtp-Source: AGHT+IEkYM+z5um1e02M8R/gvTw16O0/GZF3cbQY0yios9cjO+95+6kzj+UuOEfKE/IDgb49JMxL X-Received: by 2002:a05:6808:2189:b0:3c6:fe98:fc03 with SMTP id be9-20020a056808218900b003c6fe98fc03mr4420024oib.36.1713565994391; Fri, 19 Apr 2024 15:33:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713565994; cv=pass; d=google.com; s=arc-20160816; b=0wE06LsLr+9niD5T5p8AR+tnWvBuKZEMx7AaREEaBYG2bdyJZcL7f/iiF4r3tAEx8B VmGYKdVcGQ5pLjJugWo0iZjhah4u5qJ13si6d2mPVWlyrkHLktgch4gk0ic81AcFPyvN SPfmP38o5loz2NXUrHuZpqkG3w9qA/Xo8ks//C1LpsXoJSdE1s41svIZYWzAy3uWC0BV Z7M5DG1YLDYaiandMHT5oEGp1r/WnNY1/PfRFJNuKdqO2+VYBlXH0CuZc6KI9GGLButD 2QyYvVxHnqm1mkambamF6WpX9+E4qXHNTbTpzYOOldVmSRcvO1dwdMjDmlrGhWaLmhhs 8wEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=EICelP/lE33eIq2U0CujJA6vcfBMPCSauA8jxb4szvI=; fh=AnhYD2t1KbJsWqEIaAHo0Ns3gJ/BrbM3qelzPrMSX9g=; b=w2ROw9RqkVa1F+iloMd6DxBQqRNM1tKtuHEEF7vFju0iNty5uMCMB1TUE6FSB47dGN W6gYSe4CQ5HbbmNmS3rb1GziXrK9t9U4bnaO/w4epyScyPINZddmWIXoKusH/P6FxE3z 4zaBEeaPJHzjGUrcrT4iu+Qetcni4h2u6suQoaMe3+2lGTiC1jcsEdF8KFDbriRo/2LQ 4bOLxSjkQkMUBgzBfw8XgCJSFbZ9PYLhzI1CfBlDNqnijSjOWw82iSf7LeXT+6DT/qyg wc1zTEHNkiOx0lTddFLHwQZSMCkaCaWMUd7Oysvfnsrg23kg/nC9U3/eyrWuaH5t1AM+ Czsw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=u7t8xvfO; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-152007-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152007-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w20-20020ac87e94000000b004364611172esi5199721qtj.467.2024.04.19.15.33.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 15:33:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152007-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=u7t8xvfO; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-152007-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152007-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 115201C20CAA for ; Fri, 19 Apr 2024 22:33:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F06A13D60C; Fri, 19 Apr 2024 22:33:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="u7t8xvfO" Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9807D10A28 for ; Fri, 19 Apr 2024 22:33:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713565988; cv=none; b=YcemJqoOFooahGtL4rPbASh26gCFfpav5CwDzvz6PvDh1N+4Y2IMZFS8JcHZkUtmgyrs8RZvLX61K0YeBo7MX22k6lhzmf3yGg+STAkPzzEE1p+BTSZ2r/8rF6jMk57mlYXAx+8Elg7k9sYjcOtOC6aQpJxa/S0U/yosu54fDr8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713565988; c=relaxed/simple; bh=qo7/N5ZF9+TTT+lb3wooerYp+x/U68ObQtBJ6S9FeKE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=aXd6cIVzQn5O1BzUSiLKxALaoVu93bcwObswTU5YAtkvvDVXNQh+H0vCqRnJu8zkZqkQGGt7q8UwvnWPCKIYvp314BV7cClYdP6vNTSGFePYx2kXuoFGFwgFhUKHbljqoI9d0clQ4hgdWedRZebfYXyMvEmq30c6VouMzpw6u/U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=u7t8xvfO; arc=none smtp.client-ip=209.85.161.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-5acf5c1a2f5so1652240eaf.0 for ; Fri, 19 Apr 2024 15:33:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713565985; x=1714170785; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=EICelP/lE33eIq2U0CujJA6vcfBMPCSauA8jxb4szvI=; b=u7t8xvfOt/2PWWJX0GO62wwDFNOiCd8dcypkXmGjKbNPru2pGrz+Teg+hsmHdmJI8c rh4d8mhsPsV+AgOtH/JgYleSZ1eehf7K91JZvGrds1erFAeAqNSfBNiZaBP5Z31am7SI C4tplUS5i1avIkZWzrl99QzjpxxnS93+6mHgOrq3wamx4Ijz7w+WeDiJsQKeSZbZ8Dsk UcroIMFtqiUcFwkRYIa0/KLPM0DekD3JFGzbZSoOlE3xiwqrdne96nAjnqD39ub+Qs8X /uVrpqkTz2qoT0oLQGLAZ+Eeyr/7Xsr8l4VLGVbYgOlyi6Wp3ca4042DQjaNHqDHe6kM oNXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713565985; x=1714170785; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EICelP/lE33eIq2U0CujJA6vcfBMPCSauA8jxb4szvI=; b=T58kyaOH3y219ztQTxlPbF+ZB+dilz1IyzewJnF1vfkDbGo4I+hwfFCRXSWT93QUHX wArladkGIEz7smNgsNNFSgqho3MW57DzH2b3U8KhY8cEX2aVqk/RS3fIdx8sdi+jwM3Q 2DOwJ0d4NSeDOrRqFU3eHajwTmKllIMU8nNAkBwo0uoS0KJORV7sl7d6CFEjq5Zau/uw aqZSPvAhlhng37Omr/V5yo4Y9PeeHaLlkCjiDsLV3C+wt3oAgNF5j1Cof5xBDhWEzOwH wJ85G93/8Fd1OZfw0mvI5Yd6eg9vAtSfZgWCUqxKviawZV03eGUjbrtMHQcNLnqjBBAA c7kA== X-Forwarded-Encrypted: i=1; AJvYcCU8hA1KugeiU9zaUGsoLGjiV1bQ5SudveBtnBljaAw8EpOvcPCMpP4aq1KA4WH/kf1ZciARsWDefM5e2EtYM5aEp+QGfJYqJjTTFPCz X-Gm-Message-State: AOJu0YwPjRAeCSBpAUYsXsvseeNj0iNYZ7pmcTvV5ZCQnD9otXOF4ZRd x4ZWZWfS0uRe17aWF0odVbUyU74etKErfddDXaJe7ezkkEKqZ/bWghVT4DPbHovo9AK9S2RkOhj FsOr0O11ZeCX41KqwSRKuSv2dbz6CliXn7dlB X-Received: by 2002:a05:6358:5d8e:b0:185:fc1f:23ab with SMTP id s14-20020a0563585d8e00b00185fc1f23abmr4306920rwm.6.1713565985270; Fri, 19 Apr 2024 15:33:05 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240418042706.1261473-1-maheshb@google.com> <87cyqmx850.ffs@tglx> In-Reply-To: <87cyqmx850.ffs@tglx> From: =?UTF-8?B?TWFoZXNoIEJhbmRld2FyICjgpK7gpLngpYfgpLYg4KSs4KSC4KSh4KWH4KS14KS+4KSwKQ==?= Date: Fri, 19 Apr 2024 15:32:37 -0700 Message-ID: Subject: Re: [PATCHv2 next] ptp: update gettimex64 to provide ts optionally in mono-raw base. To: Thomas Gleixner Cc: Netdev , Linux , David Miller , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Richard Cochran , Arnd Bergmann , Sagi Maimon , Jonathan Corbet , John Stultz , Mahesh Bandewar Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Apr 18, 2024 at 9:56=E2=80=AFPM Thomas Gleixner wrote: > > On Wed, Apr 17 2024 at 21:27, Mahesh Bandewar wrote: > > Subject: ptp: update gettimex64 to provide ts optionally in mono-raw base= . > > Can we please have proper sentences without cryptic abbreviations? This > is not twatter or SMS. > character limit in the description is the limiting factor. > Aside of that this is not about updating gettimex64(). The fact that > this is an UAPI change is the real important information. gettimex64() > is only the kernel side implementation detail. > > ptp/ioctl: Support MONOTONIC_RAW timestamps forPTP_SYS_OFFSET_EXTENDED > > or something like that. > ack. > > The current implementation of PTP_SYS_OFFSET_EXTENDED provides > > PHC reads in the form of [pre-TS, PHC, post-TS]. These pre and > > post timestamps are useful to measure the width of the PHC read. > > However, the current implementation provides these timestamps in > > CLOCK_REALTIME only. Since CLOCK_REALTIME is disciplined by NTP > > or NTP-like service(s), the value is subjected to change. This > > makes some applications that are very sensitive to time change > > have these timestamps delivered in different time-base. > > The last sentence does not make any sense to me. > > > This patch updates the gettimex64 / ioctl op PTP_SYS_OFFSET_EXTENDED > > git grep 'This patch' Documentation/process/ > > > to provide these (sandwich) timestamps optionally in > > CLOCK_MONOTONIC_RAW timebase while maintaining the default behavior > > or giving them in CLOCK_REALTIME. > > This change log lacks a proper explanation why this is needed and what's > the purpose and benefit. > > Aside of that it fails to mention that using the currently unused > reserved field is correct because CLOCK_REALTIME =3D=3D 0. > > > ~# testptp -d /dev/ptp0 -x 3 -y raw > > extended timestamp request returned 3 samples > > sample # 0: mono-raw time before: 371.548640128 > > phc time: 371.579671788 > > mono-raw time after: 371.548640912 > > sample # 1: mono-raw time before: 371.548642104 > > phc time: 371.579673346 > > mono-raw time after: 371.548642490 > > sample # 2: mono-raw time before: 371.548643320 > > phc time: 371.579674652 > > mono-raw time after: 371.548643756 > > ~# testptp -d /dev/ptp0 -x 3 -y real > > extended timestamp request returned 3 samples > > sample # 0: system time before: 1713243413.403474250 > > phc time: 385.699915490 > > system time after: 1713243413.403474948 > > sample # 1: system time before: 1713243413.403476220 > > phc time: 385.699917168 > > system time after: 1713243413.403476642 > > sample # 2: system time before: 1713243413.403477555 > > phc time: 385.699918442 > > system time after: 1713243413.403477961 > > That takes up a lot of space, but what's the actual value of this > information? Especially as there is no actual test case for this which > people can use to validate the changes. > I'll polish the testptp.c changes and submit them later. But if this is not adding any value, I can remove it from the log. > > diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock= _kernel.h > > index 6e4b8206c7d0..7563da6db09b 100644 > > --- a/include/linux/ptp_clock_kernel.h > > +++ b/include/linux/ptp_clock_kernel.h > > @@ -47,10 +47,12 @@ struct system_device_crosststamp; > > * struct ptp_system_timestamp - system time corresponding to a PHC ti= mestamp > > * @pre_ts: system timestamp before capturing PHC > > * @post_ts: system timestamp after capturing PHC > > + * @clockid: clockid used for cpaturing timestamp > > cpaturing? > > s/timestamp/the system timestamps/ > > Precision matters not only for PTP. > :) ack > > */ > > struct ptp_system_timestamp { > > struct timespec64 pre_ts; > > struct timespec64 post_ts; > > + clockid_t clockid; > > }; > > > > /** > > @@ -457,14 +459,34 @@ static inline ktime_t ptp_convert_timestamp(const= ktime_t *hwtstamp, > > > > static inline void ptp_read_system_prets(struct ptp_system_timestamp *= sts) > > { > > - if (sts) > > - ktime_get_real_ts64(&sts->pre_ts); > > + if (sts) { > > + switch (sts->clockid) { > > + case CLOCK_REALTIME: > > + ktime_get_real_ts64(&sts->pre_ts); > > + break; > > + case CLOCK_MONOTONIC_RAW: > > + ktime_get_raw_ts64(&sts->pre_ts); > > + break; > > + default: > > + break; > > + } > > + } > > } > > > > static inline void ptp_read_system_postts(struct ptp_system_timestamp = *sts) > > { > > - if (sts) > > - ktime_get_real_ts64(&sts->post_ts); > > + if (sts) { > > + switch (sts->clockid) { > > + case CLOCK_REALTIME: > > + ktime_get_real_ts64(&sts->post_ts); > > + break; > > + case CLOCK_MONOTONIC_RAW: > > + ktime_get_raw_ts64(&sts->post_ts); > > + break; > > + default: > > + break; > > + } > > + } > > } > > > > #endif > > diff --git a/include/uapi/linux/ptp_clock.h b/include/uapi/linux/ptp_cl= ock.h > > index 053b40d642de..fc5825e72330 100644 > > --- a/include/uapi/linux/ptp_clock.h > > +++ b/include/uapi/linux/ptp_clock.h > > @@ -157,7 +157,12 @@ struct ptp_sys_offset { > > > > struct ptp_sys_offset_extended { > > unsigned int n_samples; /* Desired number of measurements. */ > > - unsigned int rsv[3]; /* Reserved for future use. */ > > + /* The original implementation provided timestamps (always) in > > + * REALTIME clock-base. Since CLOCK_REALTIME is 0, adding > > + * clockid doesn't break backward compatibility. > > + */ > > This wants to be in the change log. > Ack > If you want to document the evolution of this data structure in a > comment, then 'original implementation' is not really the best wording > to use. > > I'd rather see the documentation fixed so that it uses proper kernel doc > style for the whole data structure instead of having this mix of inline > and tail comments along with a properly structured version information. > > /** > * ptp_sys_offset_extended - Data structure for IOCTL_PTP_..... > * > * @n_samples: Desired number of samples > * .... > * @... > * > * History: > * V1: Initial implementation > * > * V2: Use the first reserved field for @clockid. That's backwards > * compatible for V1 user space because CLOCK_REALTIME is 0 and > * the reserved fields must be 0. > */ > > Or something like that. Hmm? > will attempt to add it. > Thanks, > > tglx Thanks for reviewing Thomas, I'll address them in the next revision. --mahesh..