From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89FD0C433B4 for ; Wed, 12 May 2021 12:50:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4163C61104 for ; Wed, 12 May 2021 12:50:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230334AbhELMvQ (ORCPT ); Wed, 12 May 2021 08:51:16 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:52986 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230037AbhELMvN (ORCPT ); Wed, 12 May 2021 08:51:13 -0400 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 14CCo0vc021169; Wed, 12 May 2021 14:50:00 +0200 Date: Wed, 12 May 2021 14:50:00 +0200 From: Willy Tarreau To: Mark Brown Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] tools/nolibc: Implement msleep() Message-ID: <20210512125000.GB20883@1wt.eu> References: <20210512114728.19015-1-broonie@kernel.org> <20210512115949.GA20883@1wt.eu> <20210512121858.GA6343@sirena.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210512121858.GA6343@sirena.org.uk> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 12, 2021 at 01:18:58PM +0100, Mark Brown wrote: > On Wed, May 12, 2021 at 01:59:49PM +0200, Willy Tarreau wrote: > > On Wed, May 12, 2021 at 12:47:28PM +0100, Mark Brown wrote: > > > > - Return the number of seconds remaining if the delay does not > > > complete. > > > But why returning the number of seconds instead of milliseconds ? > > The common use case is this: > > > delay = delay_before_next_event(); > > while ((ret = msleep(delay)) > 0) > > delay -= ret; > > It seemed to be what you were asking for and I didn't have strong enough > opinions for it to be worth pushing back. Sorry if I wasn't clear then, but I proposed this example which should return the number of ms left: if (sys_select(0, 0, 0, 0, &my_timeval) < 0) return my_timeval.tv_sec * 1000 + (my_timeval.tv_usec + 999) / 1000; else return 0; In any case all of this is not critical but I'm fairly convinced that your addition is useful, especially if done like this, which is why I was asking. Willy