All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Sagi Maimon <maimon.sagi@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	richardcochran@gmail.com, luto@kernel.org, datglx@linutronix.de,
	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, 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: Thu, 14 Mar 2024 15:59:39 +0000	[thread overview]
Message-ID: <ZfMe66MfHBEfxrdd@FVFF77S0Q05N> (raw)
In-Reply-To: <CAMuE1bH_H9E+Zx365G9AtmWSmhW-kPPB+-=8s2rH4hpxqE+dHQ@mail.gmail.com>

On Thu, Mar 14, 2024 at 02:19:39PM +0200, Sagi Maimon wrote:
> On Thu, Mar 14, 2024 at 1:12 PM Thomas Gleixner <tglx@linutronix.de> wrote:
> > On Thu, Mar 14 2024 at 11:05, Sagi Maimon wrote:
> > > +     if (crosstime_support_a) {
> > > +             ktime_a = ktime_sub(xtstamp_a2.device, xtstamp_a1.device);
> > > +             ts_offs_err = ktime_divns(ktime_a, 2);
> > > +             ktime_a = ktime_add_ns(xtstamp_a1.device, (u64)ts_offs_err);
> > > +             ts_a1 = ktime_to_timespec64(ktime_a);
> >
> > This is just wrong.
> >
> >      read(a1);
> >      read(b);
> >      read(a2);
> >
> > You _CANNOT_ assume that (a1 + ((a2 - a1) / 2) is anywhere close to the
> > point in time where 'b' is read. This code is preemtible and
> > interruptible. I explained this to you before.
> >
> > Your explanation in the comment above the function is just wishful
> > thinking.
> >
> you explained it before, but still it is better then two consecutive
> user space calls which are also preemptible
> and the userspace to kernel context switch time is added.

How much "better" is that in reality?

The time for a user<->kernel transition should be trivial relative to the time
a task spends not running after having been preempted.

Either:

(a) Your userspace application can handle the arbitrary delta resulting from a
    preemption, in which case the trivial cost shouldn't matter.

    i.e. this patch *is not necessary* to solve your problem.

(b) Your userspace application cannot handle the arbitrary delta resulting from
    a preemption, in which case you need to do something to handle that, which
    you haven't described at all.
  
    i.e. with the information you have provided so far, this patch is
    *insufficient* to solve your problem.

> > > + * In other cases: Read clock_a twice (before, and after reading clock_b) and
> > > + * average these times – to be as close as possible to the time we read clock_b.
> >
> > Can you please sit down and provide a precise technical description of
> > the problem you are trying to solve and explain your proposed solution
> > at the conceptual level instead of throwing out random implementations
> > every few days?

100% agreed.

Please, explain the actual problem you are solving here. What *specifically*
are you trying to do in userspace with these values? "Synchronization" is too
vague a description.

Making what is already the best case *marginally better* without handling the
common and worst cases is a waste of time. It doesn't actually solve the
problem, and it misleads people into thinknig that a problem is solved when it
is not.

Mark.

  reply	other threads:[~2024-03-14 15:59 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 [this message]
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 (महेश बंडेवार)
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=ZfMe66MfHBEfxrdd@FVFF77S0Q05N \
    --to=mark.rutland@arm.com \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=brauner@kernel.org \
    --cc=casey@schaufler-ca.com \
    --cc=datglx@linutronix.de \
    --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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.