linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Mahesh Bandewar (महेश बंडेवार)" <maheshb@google.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Sagi Maimon <maimon.sagi@gmail.com>,
	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
Date: Tue, 2 Apr 2024 16:37:27 -0700	[thread overview]
Message-ID: <CAF2d9jjg0PEgPorXdrBHVkvz-fmUV7UXUPqnpQGVEvgXTpHY0A@mail.gmail.com> (raw)
In-Reply-To: <877chfcrx3.ffs@tglx>

On Tue, Apr 2, 2024 at 3:37 PM Thomas Gleixner <tglx@linutronix.de> wrote:
>
> On Tue, Apr 02 2024 at 14:16, Mahesh Bandewar (महेश बंडेवार) wrote:
> > On Tue, Apr 2, 2024 at 2:25 AM Thomas Gleixner <tglx@linutronix.de> wrote:
> >> Works as well. I'm not seing the point for CLOCK_MONOTONIC and the
> >> change logs are not really telling anything about the problem being
> >> solved....
> >>
> > https://lore.kernel.org/lkml/20240104212431.3275688-1-maheshb@google.com/T/#:~:text=*%20[PATCHv3%20net%2Dnext%200/3]%20add%20ptp_gettimex64any()%20API,21:24%20Mahesh%20Bandewar%200%20siblings%2C%200%20replies;
> >
> > This is the cover letter where I tried to explain the need for this.
>
> The justification for a patch needs to be in the change log and not in
> the cover letter because the cover letter is not part of the git
> history.
>
ack

> > Granted, my current use case is for CLOCK_MONOTONIC_RAW but just
> > because I don't have a use case doesn't mean someone else may not have
> > it and hence added it.
>
> Then why did you not five other clock IDs? Someone else might have a
> use case, no?
>
> While a syscall/ioctl should be flexible for future use, the kernel does
> not add features just because there might be some use case. It's
> documented how this works.
>
I see your point. I don't mind removing the CLOCK_MONOTONIC for now
and just have CLOCK_REALTIME and CLOCK_MONOTONIC_RAW support. Also as
I mentioned, it will be just a matter of adding new clock-ids and
support for the pre/post-ts for respective clock-ids if needed in the
future.

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.

Here is my sample mlx4 (since I use that) of the new ioctl method
(just for the reference)

--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -43,6 +43,7 @@
 #include <linux/io-mapping.h>
 #include <linux/delay.h>
 #include <linux/etherdevice.h>
+#include <linux/ptp_clock_kernel.h>
 #include <net/devlink.h>

 #include <uapi/rdma/mlx4-abi.h>
@@ -1929,7 +1930,7 @@ static void unmap_bf_area(struct mlx4_dev *dev)
                io_mapping_free(mlx4_priv(dev)->bf_mapping);
 }

-u64 mlx4_read_clock(struct mlx4_dev *dev)
+u64 mlx4_read_clock(struct mlx4_dev *dev, struct ptp_system_timestamp
*sts, int clkid)
 {
        u32 clockhi, clocklo, clockhi1;
        u64 cycles;
@@ -1937,7 +1938,13 @@ u64 mlx4_read_clock(struct mlx4_dev *dev)
        struct mlx4_priv *priv = mlx4_priv(dev);

        for (i = 0; i < 10; i++) {
-               clockhi = swab32(readl(priv->clock_mapping));
+               if (sts) {
+                       ptp_read_any_prets(sts, clkid);
+                       clockhi = swab32(readl(priv->clock_mapping));
+                       ptp_read_any_postts(sts, clkid);
+               } else {
+                       clockhi = swab32(readl(priv->clock_mapping));
+               }
                clocklo = swab32(readl(priv->clock_mapping + 4));
                clockhi1 = swab32(readl(priv->clock_mapping));
                if (clockhi == clockhi1)

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.

> Thanks,
>
>         tglx
>

  reply	other threads:[~2024-04-02 23:37 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-14  9:05 [PATCH v7] posix-timers: add clock_compare system call Sagi Maimon
2024-03-14 11:12 ` Thomas Gleixner
2024-03-14 12:19   ` Sagi Maimon
2024-03-14 15:59     ` Mark Rutland
2024-03-14 18:08     ` Thomas Gleixner
2024-03-20 14:42       ` Sagi Maimon
2024-03-23  0:38         ` Thomas Gleixner
2024-03-23  0:42           ` Thomas Gleixner
2024-03-24 11:04             ` Kurt Kanzenbach
2024-03-28 15:40           ` Sagi Maimon
2024-04-01 20:46             ` Thomas Gleixner
2024-04-02  5:42               ` Mahesh Bandewar (महेश बंडेवार)
2024-04-02  9:24                 ` Thomas Gleixner
2024-04-02 21:16                   ` Mahesh Bandewar (महेश बंडेवार)
2024-04-02 22:37                     ` Thomas Gleixner
2024-04-02 23:37                       ` Mahesh Bandewar (महेश बंडेवार) [this message]
2024-04-03 13:48                         ` Thomas Gleixner
2024-04-03 15:42                           ` Thomas Gleixner
2024-04-11  2:55                           ` Mahesh Bandewar (महेश बंडेवार)
2024-04-11  7:11                             ` Sagi Maimon
2024-04-11 16:33                               ` Mahesh Bandewar (महेश बंडेवार)
2024-04-14 12:22                                 ` Sagi Maimon
2024-04-15 17:23                                   ` Mahesh Bandewar (महेश बंडेवार)
2024-04-16  8:39                                     ` Sagi Maimon
2024-03-14 15:46   ` Sagi Maimon
2024-03-14 18:42     ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAF2d9jjg0PEgPorXdrBHVkvz-fmUV7UXUPqnpQGVEvgXTpHY0A@mail.gmail.com \
    --to=maheshb@google.com \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=brauner@kernel.org \
    --cc=casey@schaufler-ca.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=geert@linux-m68k.org \
    --cc=hannes@cmpxchg.org \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=legion@kernel.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=maimon.sagi@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=mszeredi@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=nphamcs@gmail.com \
    --cc=palmer@sifive.com \
    --cc=peterz@infradead.org \
    --cc=reibax@gmail.com \
    --cc=richardcochran@gmail.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=sohil.mehta@intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).