Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp515491pxy; Thu, 22 Apr 2021 07:21:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw60amAhJs9vUx/1Sao2BdUT1eB5+M7EyZ4JSrSoFEG8D/OV74BTojE07XQwd0Z/zG55KH0 X-Received: by 2002:aa7:c850:: with SMTP id g16mr4136649edt.324.1619101302613; Thu, 22 Apr 2021 07:21:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619101302; cv=none; d=google.com; s=arc-20160816; b=giDwO54vh11/br//yVEBa7RpPs+Yx8P9Tke++rXTSxvc2Z9vEtKXMhTCTkOj8e6/3m jScYpB6Dn95PpQkP3DruC4Ox6sMMDkdyYEuUhzMumfVIhQd/ZYwEqEImbkA0O33TYddk yn3hxiiP+lNXADttgPi+F35vgwWuJsy/eWAOmGa/EMyfI6qhzN3LB3FjlZPktGaxmaP0 i0LDKi/A8MBFFzVMF7/yqhPgK9yU68h9OEYC5PnZkTbZSBYjVLAvcoThmiWR2d3/ikxb Gp4IymV023PH9XzB94CfeZl9Sdc61RgJ02Uldm1VK8CI5Ux9FE4giMkcnhO8+V9KPdFr Opwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=WrJWKg8qXVKHqftlCgBjaSL6VbGyPelbV07Irtnhz3E=; b=RTcp/9lz2rb8yjOutDylHZ8DAa151GxJ7ngQoJpzA9Jac5GUW6uoHmZM/h9hEIMy7Q 1y7kGuyx8TV50TijIMvDPHyyKfQKozI4aICGDRgrGT/oYLlGxjpUAdSWcYjcHMYykCqr wSfAeB+MrMIPdsoci5zhQ1g82s09ulHsavvZGrqzCG2A0niBvpWMXmzYloE2KhjjqT9E Sp/fvJq0ZZz68uqL3s+ator1MEyZcPAM/yvGQfC5PlwjU0rfY2DTFaya0tV8hu9DUBeJ UBBTXUH+HMqgisGPQoVsxjokYoBgdLXCNdipjD5o3oQBZDx+mojiZXwMg1sIrI39MkKN zJxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PCWwmxGZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g1si2369254ejh.285.2021.04.22.07.21.19; Thu, 22 Apr 2021 07:21:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PCWwmxGZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237033AbhDVOVA (ORCPT + 99 others); Thu, 22 Apr 2021 10:21:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236496AbhDVOU7 (ORCPT ); Thu, 22 Apr 2021 10:20:59 -0400 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4960C06138B for ; Thu, 22 Apr 2021 07:20:20 -0700 (PDT) Received: by mail-il1-x133.google.com with SMTP id l9so2206471ilh.10 for ; Thu, 22 Apr 2021 07:20:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WrJWKg8qXVKHqftlCgBjaSL6VbGyPelbV07Irtnhz3E=; b=PCWwmxGZfVK0z3Ug+FWfoNd2U+c4S+UYgxKsD0KK3dTdpSGJEGkbB+E9NbscwSjo/3 2hzCpqnRXJDxpVWHipELFDknyxGNDrrf3V3fMhViaW8DreVLZYzhEiQJv2ODcj4xIcwk MPhdeBbrZWxbj1JgVMVbT0FwXKEovnTKZvtqfIgkytBE7HPXsmArPC+J7DAmcUrVyiUQ Y9MRkwVjGJKQ6PAq5FrRL0twGF521XkoMM2SxlGMuoYSLXRf5JNPcMu1ZIedj5szN7DB NfIAVANcU5q/VuiGla0es/kmuTzjggNf2ZIRUrwdOU9rPUxd+ftEYb0O/wNJbm7M2Z+S eBdg== 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=WrJWKg8qXVKHqftlCgBjaSL6VbGyPelbV07Irtnhz3E=; b=FvW8kBpWVhb1SRFR3waBIvOtezEwVaqEeyVhzlf5YsTf9Rd61GAaOjnougRsawcT/j +DL6Noc03roctp/MJcdIPJuqikoyG3d5Zim4vsQ0fXaNQHoEHON6qFY1NEXK7afh6njd 0FYFoVk4qHcgUqDGYxzdyb/r+OmaXSpeMORpzjiIPJZjcgl/gSTyWroI5z30BvWNcbL+ k12xj6SGOvLUZZzsBdKDTrTrCteB2FJRAuEng6T+icxze4aDRoE52pPU1ewup0WEBPdW xEOodEg/T/+53WtXHFe8mseckZa8ObvqYykeqe7uiuJxmBFqrHjLoj015iVicLc3k+aD IDUg== X-Gm-Message-State: AOAM531HzeYfHFW58w06cX7QZSXXkYPkK6p+YAMOvgRef/lX0BS4ZwmC FSDjQMAVbnx5Fz09Q0g8dZAtuUbOtYPQZyix/N5s9w== X-Received: by 2002:a92:d09:: with SMTP id 9mr2924207iln.229.1619101219892; Thu, 22 Apr 2021 07:20:19 -0700 (PDT) MIME-Version: 1.0 References: <87v98fxjtm.ffs@nanos.tec.linutronix.de> In-Reply-To: <87v98fxjtm.ffs@nanos.tec.linutronix.de> From: Lorenzo Colitti Date: Thu, 22 Apr 2021 23:20:07 +0900 Message-ID: Subject: Re: [PATCH] hrtimer: Update softirq_expires_next correctly after __hrtimer_get_next_event() To: Thomas Gleixner Cc: Greg KH , =?UTF-8?Q?Maciej_=C5=BBenczykowski?= , Ingo Molnar , Anna-Maria Behnsen , lkml , mikael.beckius@windriver.com, =?UTF-8?Q?Maciej_=C5=BBenczykowski?= , Will Deacon Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 22, 2021 at 9:08 AM Thomas Gleixner wrote: > Just for comparison. In a VM I'm experimenting with right now the > reprogramming time is ~500ns which is still a lot of cycles, but > compared to 5us faster by an order of magnitude. And on the sane > machine bare metal its way faster and therefore less noticeable. FWIW, on this hardware, frtrace says that arming the arm64 architected timer takes 0.7us. Definitely better than 2-3us, but still not free. This is not a high-end desktop or server, but it's also not super slow, low-power hardware. > * The transmit should only be run if no skb data has been sent for a > * certain duration. > > which is useless word salad. You're the one who wrote that comment - see b1a31a5f5f27. You'll forgive me for being amused. :-) Thanks for the history/analysis/suggestions. I think it's a fact that this is a regression in performance: this particular code has performed well for a couple of years now. The fact that the good performance only existed due to a correctness bug in the hrtimer code definitely does make it harder to argue that the regression should be reverted. That said: if you have a fix for the double reprogram, then that fix should probably be applied? 0.5us is not free, and even if hrtimers aren't designed for frequent updates, touching the hardware twice as often does seem like a bad idea, since, as you point out, there's a *lot* of hardware that is slow. Separately, we're also going to look at making ncm better. (In defense of the original author, in 2014 I don't think anyone would even have dreamed of USB being fast enough for this to be a problem.) The first thing we're going to try to do is set the timer once per NTB instead of once per packet (so, 10x less). My initial attempt to do that causes the link to die after a while and I need to figure out why before I can send a patch up. I'm suspicious of the threading, which uses non-atomic variables (timer_force_tx, ncm->skb_tx_data) to synchronize control flow between the timer and the transmit function, which can presumably run on different CPUs. That seems wrong since either core could observe stale variables. But perhaps there are memory barriers that I'm not aware of. The idea of getting rid of the timer by doing aggregation based on transmit queue lengths seems like a much larger effort, but probably one that is required to actually improve performance substantially beyond what it is now.