Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2720076lqz; Wed, 3 Apr 2024 06:51:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXDYFu2Cjg3MRg0svVC+3cZ9ha28hwIMqqEg6J47MuDD5SVGwCQ+MGptZJZ5RQdh+2e4hI0mkCQmfVOv3Y9QfvA520topyTD6p7CMW6wQ== X-Google-Smtp-Source: AGHT+IF36d4JGXsnjeZd1W/Mqr/wjutzByy0GQxRWu9g6VvqkT0LYE51P4BeWkuwVI2ykxcD3Qfu X-Received: by 2002:a05:6a21:394c:b0:1a5:7409:f2ce with SMTP id ac12-20020a056a21394c00b001a57409f2cemr3646834pzc.25.1712152266006; Wed, 03 Apr 2024 06:51:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712152265; cv=pass; d=google.com; s=arc-20160816; b=eABnoS+Iq6ocS14ZHE67/Hv3wxRfHuonM9zGDAsa0/ZKpBMcIwE5MhxWnjfkNBHUhl iEasugrB96rXHuEeAO31j9yHUlJae8moxWta8y61SPp7QxSEfITevgItfTElK/CwWTGg Np1WrY5wm86xjzxk4Cbl4eqNfglUAvYUkF977slK9DlLXM8CqckzpMfT5FKuQbAUgNGE /aErE7kO6qYs3caKRHww37sDghlaVAl9BDvOKQYrNDUpDcfSjM+j8Kc2D4hE0Klmz7AX QC0Pe+hMk1uB0mQFjl8FfnVl99ytxU0N5+8kz7AHmKwzj3ab0ZSsinDwHDRZ/HIfYmn9 iygA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=e7kLxvWk/5gRltzRCZSO2/VhtuBBFwcoV8m7fx6icxE=; fh=gFJ9guboxaM1F8e+eYVaq4a30yzb0XAuMgxNzrx7mY8=; b=SC8sYqpprxfmrLDjIngXJkHn7w+w9eIbWCWV0TzhxQLDjM6vXXM7MtZpoubpQMnrGk 9qKv83cj9fW5/DLIrhu9UV850R1F3+tVT8i633I7kQxEAkqZkB0wcg43X7J63WIu9oRU tLMDXyWSWbRJbSK6mAqtoMvNjHbm2lAxbbYnwZ+4Nt01xMnsAWrYs74DQ2WI87q1rabh E+wk+KrgT0+6F7j6JJz1eTHICM5We4QzaV+rlMVJDoMc0MIfDOZN2rweJu3O6yp4BYR8 Wpgjm1dF0z+PlJ5oqV8RysgPu/7+LDzP10S/SU7La4TFOzPD0lY4NJoE443aPhQPdQWD N+dg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=oy6vBAjo; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-129878-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129878-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u2-20020a655c02000000b005e438e96c48si13116050pgr.164.2024.04.03.06.51.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:51:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-129878-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=oy6vBAjo; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-129878-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129878-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9F6C32862F0 for ; Wed, 3 Apr 2024 13:49:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F16C0148836; Wed, 3 Apr 2024 13:48:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="oy6vBAjo"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dMSZN9SO" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 151F51487E0; Wed, 3 Apr 2024 13:48:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712152136; cv=none; b=H2EU761yLj/E15F90edItcfk8gmMa7tAAilDkB7dFwbJ4r4Y6S73yw3qiSta2Y+xZuYAre2yMhsHTIc0TopWDnMscdDAW/vhxZOtBNR282v4/7npjsQJH9fw4Xle6y6khnbP7k+rblsJ//9axFBCtwtjVctRTZ6/nS0w3SdLCfU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712152136; c=relaxed/simple; bh=qoTFFleE42BgrSkvKarf5pCVIY29rDDpqfsHaC7hnc4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=DbG+SG7UMjorrLj/SqvSlsrs/E63jKC8d6+8Fhrf4fBux+52UYbEAX0lk/+n3EdQs+0HB7g2LFfSwesrpTB/jo7q6Tvh7n9mR2X0JgKh6VD/EKCllDtuhLvzPZIPsHqrGA3Ob9KlpWyVZRWkefDdCUUASPO7HPTkFAeEYbbjy8M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=oy6vBAjo; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=dMSZN9SO; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1712152132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e7kLxvWk/5gRltzRCZSO2/VhtuBBFwcoV8m7fx6icxE=; b=oy6vBAjox1TNAs+TZf+sluJyIhyG+yUvn4oR5PmJNKXZgJRpLiUL8ueqPNp11qni1Sgji0 C1dZpA4PrxvLDIjWNzybh4s97wN0RB7g6l5zSgoyzVTyn46APfr4Pdgfw5/q6iSR2pwNib EI4JoU2J2MbavCyfuLMtjcZO17ty2AWmnHGkBFtJbBLyrABDRnOF+V2Xrky0dDrBHc50F3 0N2uehmxvltD/2eeiHwbSWrB87AL0y+jhgGKU/JqMhvAF0NL9QSwRWASew/93Yezpnms+l IOo6gGF+KgJnEjGVf61SG1xQLOx/bx0UxeTi1cIa8a8wsHeNgzXoK3TphkBDig== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1712152132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e7kLxvWk/5gRltzRCZSO2/VhtuBBFwcoV8m7fx6icxE=; b=dMSZN9SOEbyPVeTuY2xmvA7+bdIbzh65aIqcDnmKw45YoP7FeZHZuu6ZtEdkGIRAEoE+9C ebusyTmb9oxT05Aw== To: =?utf-8?B?TWFoZXNoIEJhbmRld2FyICjgpK7gpLngpYfgpLYg4KSs4KSC4KSh4KWH4KS1?= =?utf-8?B?4KS+4KSwKQ==?= Cc: Sagi Maimon , richardcochran@gmail.com, luto@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, arnd@arndb.de, geert@linux-m68k.org, peterz@infradead.org, hannes@cmpxchg.org, sohil.mehta@intel.com, rick.p.edgecombe@intel.com, nphamcs@gmail.com, palmer@sifive.com, keescook@chromium.org, legion@kernel.org, mark.rutland@arm.com, mszeredi@redhat.com, casey@schaufler-ca.com, reibax@gmail.com, davem@davemloft.net, brauner@kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v7] posix-timers: add clock_compare system call In-Reply-To: References: <878r29hjds.ffs@tglx> <87o7asdd65.ffs@tglx> <87il10ce1g.ffs@tglx> <877chfcrx3.ffs@tglx> Date: Wed, 03 Apr 2024 15:48:51 +0200 Message-ID: <871q7md0ak.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Tue, Apr 02 2024 at 16:37, Mahesh Bandewar (=E0=A4=AE=E0=A4=B9=E0=A5=87= =E0=A4=B6 =E0=A4=AC=E0=A4=82=E0=A4=A1=E0=A5=87=E0=A4=B5=E0=A4=BE=E0=A4=B0) = wrote: > On Tue, Apr 2, 2024 at 3:37=E2=80=AFPM Thomas Gleixner wrote: > The modification that you have proposed (in a couple of posts back) > would work but it's still not ideal since the pre/post ts are not > close enough as they are currently (properly implemented!) > gettimex64() would have. The only way to do that would be to have > another ioctl as I have proposed which is a superset of current > gettimex64 and pre-post collection is the closest possible. Errm. What I posted as sketch _is_ using gettimex64() with the extra twist of the flag vs. a clockid (which is an implementation detail) and the difference that I carry the information in ptp_system_timestamp instead of needing a new argument clockid to all existing callbacks because the modification to ptp_read_prets() and postts() will just be sufficient, no? For the case where the driver does not provide gettimex64() then the extension of the original offset ioctl is still providing a better mechanism than the proposed syscall. I also clearly said that all drivers should be converted over to gettimex64(). > Having said that, the 'flag' modification proposal is a good backup > for the drivers that don't have good implementation (close enough but > not ideal). Also, you don't need a new ioctl-op. So if we really want > precision, I believe, we need a new ioctl op (with supporting > implementation similar to the mlx4 code above). but we want to save > the new ioctl-op and have less precision then proposed modification > would work fine. I disagree. The existing gettimex64() is good enough if the driver implements it correctly today. If not then those drivers need to be fixed independent of this. So assumed that a driver does: gettimex64() ptp_prets(sts); read_clock(); ptp_postts(sts); =20=20=20 today then having: static inline void ptp_read_system_prets(struct ptp_system_timestamp *sts) { if (sts) { if (sts->flags & PTP_SYS_OFFSET_MONO_RAW) ktime_get_raw_ts64(&sts->pre_ts); else ktime_get_real_ts64(&sts->pre_ts); } } static inline void ptp_read_system_postts(struct ptp_system_timestamp *sts) { if (sts) { if (sts->flags & PTP_SYS_OFFSET_MONO_RAW) ktime_get_raw_ts64(&sts->post_ts); else ktime_get_real_ts64(&sts->post_ts); } } or static inline void ptp_read_system_prets(struct ptp_system_timestamp *sts) { if (sts) { switch (sts->clockid) { case CLOCK_MONOTONIC_RAW: time_get_raw_ts64(&sts->pre_ts); break; case CLOCK_REALTIME: ktime_get_real_ts64(&sts->pre_ts); break; }=20=20=20=20=20=20=20=20 } } static inline void ptp_read_system_postts(struct ptp_system_timestamp *sts) { if (sts) { switch (sts->clockid) { case CLOCK_MONOTONIC_RAW: time_get_raw_ts64(&sts->post_ts); break; case CLOCK_REALTIME: ktime_get_real_ts64(&sts->post_ts); break; }=20=20=20=20=20=20=20=20 } } is doing the exact same thing as your proposal but without touching any driver which implements gettimex64() correctly at all. While your proposal requires to touch every single driver for no reason, no? It is just an implementation detail whether you use a flag or a clockid. You can carry the clockid for the clocks which actually can be read in that context in a reserved field of PTP_SYS_OFFSET_EXTENDED: struct ptp_sys_offset_extended { unsigned int n_samples; /* Desired number of measurements. */ clockid_t clockid; unsigned int rsv[2]; /* Reserved for future use. */ }; and in the IOCTL: if (extoff->clockid !=3D CLOCK_MONOTONIC_RAW) return -EINVAL; sts.clockid =3D extoff->clockid; and it all just works, no? I have no problem to decide that PTP_SYS_OFFSET will not get this treatment and the drivers have to be converted over to PTP_SYS_OFFSET_EXTENDED. But adding yet another callback just to carry a clockid as argument is a more than pointless exercise as I demonstrated. Thanks, tglx