From owner-freebsd-arch@freebsd.org Fri Dec 11 16:18:22 2020 Return-Path: Delivered-To: freebsd-arch@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2EE774B3E51 for ; Fri, 11 Dec 2020 16:18:22 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cswv20dYQz4YYp for ; Fri, 11 Dec 2020 16:18:21 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qv1-xf35.google.com with SMTP id u16so4427009qvl.7 for ; Fri, 11 Dec 2020 08:18:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9acIYKTPu02wlEKhHHLBMqGggxvvbJWSO0tqgaooTH8=; b=KEhyhh6fHIaGFE+1H8n0Uofk9ZuIFgVrH+VDcFfLckfH/V/GfxmhTVNsf+LumSJMRd bZZ4t3wyWLCZjIZom4APBnW5enk/KSWEJ19ZZmNpxjrIsG0iYh5VUH+w7Vxuz/42j9Dt q+3aekaypdY7D82virReBjKRF2P5TcE69DGcRvRwbLcrh3OQBucjzFEyMVv2IKqFvYz4 iTQOK9lrXp7aiPPaqldG80cyYBc4JKxgcseYPSbtbOZrKp1TyoUX1thZNQh6ylvRaa1z OcpesUfCjOdHy0BW8xNqVGGIFlRIq+eacY57/AYLPWeAyWg1p7PiGKHuFxkc9gHh1Tle Ayhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9acIYKTPu02wlEKhHHLBMqGggxvvbJWSO0tqgaooTH8=; b=iOlpVo1bRMOZYCp4ikFgV5i9PlboYGZq6kYEj8Sk5N2XsMeb0MAgk6rN08PJ/a70ia vTYHsojy3yBWN5eqbam0dCLTHoQbEUJN8quiaMoWGhHrWYlE7TT5fen7oY+rON02oSi3 milngRGRNBDBPHUYNyIYLD+RDT08tzdRbR4QJlMIED9o+TprtbaVwufb5cLo+ANpAXYV 7IBFHOXT4ejeTlpSfoPff3x1WiTvv38MP3j4AFDhMZtAxbBkS4skxTTa2uYIPS0h/lEi 12l4iy6Z/H4u7jrg3MTTEfgfBDctyX1YrKUsSLoKEV17FniIK6TA9UuIJwtxywZWhDSJ Evkg== X-Gm-Message-State: AOAM530IabKw8Ilmtls1Zv8qkQDe1z/P6TAAaZYvvwM8C0pnTHWF2hjd 9r9ra2P0bAbsl9vkgRmmtVG6m8fv7qgh2nnc0Y7LYQ== X-Google-Smtp-Source: ABdhPJyqEvfG9U4Jo/V5XzqiD+ELQDOski8JA9ZVRxKTvR3bAKiJBdodn4JovQmEuczbZzwqMcJUwYJEOlpwBI2O+sw= X-Received: by 2002:a0c:b66b:: with SMTP id q43mr16604005qvf.24.1607703501153; Fri, 11 Dec 2020 08:18:21 -0800 (PST) MIME-Version: 1.0 References: <202012030523.0B35NsG7003810@slippy.cwsent.com> <4086.1606982335@critter.freebsd.dk> <5e0db735b29f1ece02521871b2cd392c3467101d.camel@freebsd.org> <25487.1607029223@critter.freebsd.dk> <202012032203.0B3M3VJx004269@slippy.cwsent.com> <25989.1607033614@critter.freebsd.dk> <202012032258.0B3MwqVQ004875@slippy.cwsent.com> <202012040114.0B41EuFc006408@slippy.cwsent.com> In-Reply-To: From: Warner Losh Date: Fri, 11 Dec 2020 09:18:09 -0700 Message-ID: Subject: Re: struct timex and Linux adjtimex() To: Konstantin Belousov Cc: Cy Schubert , Poul-Henning Kamp , Ian Lepore , freebsd-arch@freebsd.org X-Rspamd-Queue-Id: 4Cswv20dYQz4YYp X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Dec 2020 16:18:22 -0000 On Fri, Dec 11, 2020, 8:15 AM Konstantin Belousov wrote: > On Thu, Dec 03, 2020 at 05:14:56PM -0800, Cy Schubert wrote: > > In message , Konstantin Belousov writes: > > > On Thu, Dec 03, 2020 at 02:58:52PM -0800, Cy Schubert wrote: > > > > In message <25989.1607033614@critter.freebsd.dk>, "Poul-Henning > Kamp" > > > > writes: > > > > > -------- > > > > > Cy Schubert writes: > > > > > > > > > > > I will go back > > > > > > with my initial proposal of a timespec add/subtract syscall > takes a > > > > > > timespec as input increments or decrements the clock by the > timespec an > > > d > > > > > > returns a timespec with the time. > > > > > > > > > > I would be tempted by the clock_settime(2) "clock_id" argument. > > > > > > > > > > The functionality required has a LOT more commonality with > > > > > clock_settime(2) than with ntp_adjtime(2), and absconding with a > > > > > couple of the top bits of clock_id for "CLOCK_ADD_ADJUSTMENT" and > > > > > "CLOCK_SUB_ADJUSTMENT" would be be a pretty clean solution. > > > > > > > > Correct. My initial proposal was: > > > > > > > > +.Fn clock_updtime "clockid_t clock_id" "const struct timespec *itp" > > > > "struct timespec *otp" > > > > > > > > Briefly it does this: > > > > > > > > +int > > > > +kern_clock_updtime(struct thread *td, clockid_t clock_id, > > > > + const struct timespec *its, struct timespec *ots) > > > Note that phk suggested using specific clock id with clock_settime(), > > > and I believe that you only need one such clock id. > > > > Correct. This is from work I stashed in my git repo from Sunday. I > haven't > > updated it yet with phk's suggestions. > > > > > > > > > +{ > > > > + struct timespec ats; > > > > + int error; > > > > + > > > > + if ((error = kern_clock_gettime(td, clock_id, &ats)) != 0) > > > > + return (error); > > > > + > > > > + timespecadd(its, &ats, &ats); > > > > + > > > > + if ((error = kern_clock_settime(td, clock_id, &ats)) != 0) > > > > + return (error); > > > > + > > > > + return(kern_clock_gettime(td, clock_id, ots)); > > > > +} > > > This is awful, it must not be done this way. > > > > > > Look how tc_setclock() is implemented. It is careful to adjust time > > > with interrupts and preemption disabled, and does it by adjusting the > > > source of truth, not by fetching through several layers and then hoping > > > that we did not get delayed too much when pushing back. > > > > Thanks. I'll look there. > > > > > > > > I think you need to refactor tc_setclock() somewhat to allow to specify > > > offset instead of absolute value and use it as a helper. > > > > I'll do that. I'll add phk and you as reviewers. > > > > > > > > > > > > > I can prepare a review if you want. I haven't touched the man page > nor any > > > > tests yet. > > > > > > > > It's affected by kib@'s https://reviews.freebsd.org/D27471, as > conflicts > > > > will result. I'll wait until that's committed before continuing work > on it, > > > > > > > assuming this is the direction we want to go. > > > This change does not affect *setclock() work above. > > > > Thanks. > > Ok, I went ahead and wrote https://reviews.freebsd.org/D27571 . > This should handle all notes from the conversation. > Apart from two arbitrary limits that aren't explained, I like this. Warner _______________________________________________ > freebsd-arch@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-arch > To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" >