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.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_PASS autolearn=ham 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 69959C43218 for ; Sat, 27 Apr 2019 12:55:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 35D9D2087C for ; Sat, 27 Apr 2019 12:55:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bQrlxOCH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727431AbfD0MzT (ORCPT ); Sat, 27 Apr 2019 08:55:19 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:52796 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726004AbfD0MzS (ORCPT ); Sat, 27 Apr 2019 08:55:18 -0400 Received: by mail-wm1-f68.google.com with SMTP id j13so7398304wmh.2 for ; Sat, 27 Apr 2019 05:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=NNvIYic4MOScmgfj4o3T9c++hrUQkw3TUx7XCFzRIwY=; b=bQrlxOCHwgKhiZu7Tw1WnoiHkBgwoErQgKzQB7usqzF7AAM71zGMosEQDxHMWBOQqs pgZ5AKKd1o2ayabRA+FZzqauJNJ1B8JHJLz0FGG/K+Z09/+BASQ2mH/32pvBBZuxjCmG mSYTwsWESgNgn8keX1Pz6aBfowLMzLTQ62wzjkn37Q91qbZwr4CN7FfDbDx9ViPqE7RM 3GGFQbR3nOYsCcSRh1EpOtt1BqiNFpq00bga7W2eVwhUZV/jRL6lTXtZRLpcsjwKk+j/ bVztljrJnUun83IReRQOp3KwXN1mRv1bnc3jn5SPzbJLQae8nZeimOX4aIvsQICaYOTs SIJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=NNvIYic4MOScmgfj4o3T9c++hrUQkw3TUx7XCFzRIwY=; b=MVDKpcd9U6N/VJdYMK5h69omvn5VWQDp5YtV6p5X600JZFWWauFN+jNlNN975rnqiY EVINRy6hmFLCG1Oeaz2SOOdzWr41bT9xZdeuiBTc07KcD0BVOR/BgBulyx6psLBy2W/O mrPSmvaxbA9FpJZYT3JRKV/RXOkJ++ZFmjDgFiBpL6P83LIITVgE0j8wDQ+KBSj9M97n CYTmF08vULMAxdJq7KDVu4MU9RhkJvcSu9sFWppYfG7TJbrUScX5g22+i0UZXyvweuwY mZNrSMqRYrGyhXEMsxUO/7V3pKSXcPeS6MI0gWJFgCpDUMI1Tb6SnFlbK4LsoPlQgiTo Lq4w== X-Gm-Message-State: APjAAAUm9W7Mzh6Sl0UBlchTZVLZEMPoM7daOcqiS9qBCn+N5AimxBj/ /LcffwH3GYAohVUBaId2Vi8Rrt9/ X-Google-Smtp-Source: APXvYqzBJFLXhHEaxWiYGE3otSDHcvCSadTvhCE+QleCeywBUeIIoMx5PqhfL7T1ABh3mZ4C4D6BeA== X-Received: by 2002:a1c:67c4:: with SMTP id b187mr11153746wmc.148.1556369716693; Sat, 27 Apr 2019 05:55:16 -0700 (PDT) Received: from [192.168.1.2] (5-12-225-227.residential.rdsnet.ro. [5.12.225.227]) by smtp.gmail.com with ESMTPSA id c6sm23210818wmb.21.2019.04.27.05.55.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Apr 2019 05:55:16 -0700 (PDT) To: stephen@networkplumber.org Cc: "netdev@vger.kernel.org" From: Vladimir Oltean Subject: Unit of measurement for clock_t in the bridge driver Message-ID: Date: Sat, 27 Apr 2019 15:55:15 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi Stephen, "man ip-link" mentions for ageing_time, forward_delay, hello_time and so on, that they specify a number of seconds. The bridge core takes the value from userspace unfiltered and passes it through the clock_t_to_jiffies function. This begs the questions "what is clock_t measured in"? One would think it does this since patch "[BRIDGE]: Make use of jiffies_to_clock." [1], but actually it appears to have done that even before (this patch is only a non-functional API change). Actually the clock_t_to_jiffies function (added in patch [2] with rather minimal introduction) should arguably be called user_ticks_to_jiffies, and there aren't a lot of users apart from the bridge driver. I'm finding that in order for me to convert the value emitted by the bridge driver into anything with physical significance, I have to multiply the ageing_time with the cosmological constant of USER_HZ (100 per popular vote). # ip link add name br0 type bridge stp_state 1 ageing_time 1 [ 2368.667020] br0: br_set_ageing_time: ageing_time (clock_t) 1 t (jiffies) 1 [ 2368.673891] br0: __set_ageing_time: t (jiffies) 1 ageing_time (clock_t) 1 It is quite apparent that clock_t_to_jiffies doesn't convert from seconds to jiffies. By the way I am quite puzzled as to how downstream users of this function, such as dsa_port_ageing_time which further convert using jiffies_to_msecs, have ever worked. Am I missing something obvious? Thanks, -Vladimir [1] https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/?id=ef443d0f02bb66d8ed4976e459ddd11b8b1407b7 [2] https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/?id=220443f8fa6562345e6848fa9f3c956343daf0d6