Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp698871pxy; Wed, 21 Apr 2021 12:43:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9AHU3+6xKKx9eWEeG5U+s+ct76tJbRWcqhk/q/UzaeeDOe/SkOP7YuGDtscT0Ad6dN2KK X-Received: by 2002:aa7:d9d9:: with SMTP id v25mr27345533eds.83.1619034208304; Wed, 21 Apr 2021 12:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619034208; cv=none; d=google.com; s=arc-20160816; b=XCnpho3c6qvFEgPnh+9nIV+Rclg6KaKAiDaUnxrf9uUSE+vNUtvZ6j5X9l5yowzBQ3 neEnr6qeJAm9PbGXZz9l6a0tf+dKTxiLVJTS5H07gPIyIfFF28zWmkOc08Bytyc5Oj59 aOcuHUXlsjSK1Uvpfc+bP1L9ea9dasqzk7HZI2YIfQOlPPaN7hDITV17OXLGWqHmuCBg 1l398uS9UaubEggJmTWPOj/ELVntMWRNbZ58+ZBwmGma8dhwGR6ZTjiKHZ82XslwJXtz 5aRtPVJ6vF4UrYsmrm1hI21wZcBKkIzYIUy7fRJpe3a2Y+SCxBX4MVS5BEw/l0sdo8qR t63A== 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=l1mA+bXgMyEnqSc8k5VDUxU2oNU/RLd1zwL6lAl3pUs=; b=zqeLb/KtCxNblkV1JivGDM0sH2BEy7oloaiA1koKf9wM791E8h4hYbISeSqAuX0+Ee HVrGJ3otqEYJ1MfTqOmamkkVNWUIKPgtIjcLsnx378hCqj/8Kl3WJviZbAeiwTd0O+ko d7t2UKyMUihwz230Z24S2ltlz46Uj+WhIFchyr0k2lS6jHMgyI/VmUkAVb25EuA7ohsM lP/Xjx1NLgvNmnNDTQhBNIqShins4wiEwa77UdSbQptnWiiN5y8IUWc+111ijDf3h0A2 8NSx2rniP3mDwHllw6IgFEMk7UBqFugL+bkNHHXTJPs/n7RNEvXRc5fxvzqnglx0RfBw QJNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ecvgf6QO; 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 j24si217048ejk.65.2021.04.21.12.43.04; Wed, 21 Apr 2021 12:43:28 -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=Ecvgf6QO; 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 S235970AbhDUOJ0 (ORCPT + 99 others); Wed, 21 Apr 2021 10:09:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239452AbhDUOJF (ORCPT ); Wed, 21 Apr 2021 10:09:05 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CF60C06174A for ; Wed, 21 Apr 2021 07:08:32 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id b10so42172428iot.4 for ; Wed, 21 Apr 2021 07:08:32 -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=l1mA+bXgMyEnqSc8k5VDUxU2oNU/RLd1zwL6lAl3pUs=; b=Ecvgf6QOWXhpql5sQ06Tb01lKwQHpKDgjBv6g74QnS9/yfponh28l9ibY3hUVYpxM6 A3lsEIqkk0soZNl444tuBLa1T8sbfggeE7yrlHrPXWX2TrKEitBGDbztvqTmkKAkQ8zu 0VKiL3n/SBR6YU+NH9mN+HqZ0uYcvchmYkk0YEeeNFw/a/ZWYc3bW9rjyLwIjL4LYuF7 py2b52kTyvU/rnIgi8z4WnQ8E8MJiAKj5rfLcnLwkpSolBpKgvWt4vqhg/auFyX2USLQ MADtTErvDu8IUmx/hwPRBoIuWIC8sSrn6M9r0DoBR90xDxvMZveeSzInliOHPXjy2oho EnlA== 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=l1mA+bXgMyEnqSc8k5VDUxU2oNU/RLd1zwL6lAl3pUs=; b=e3UJGbNH9leLA5XaU1kMsCSpKPg77gZLWmhqzR7aTYboQ4TGhaLD2NujIQtOld7lOh zGDlOhUiL7vDO5utw9nATGNhv58tLjdPB1BUiqXNI0CAumXrGDvcwc2/AnJbTa4HUCPh L+18sA5mZEV4fE1f6IZ59c80S6hKEzWxPptRtwmHDQyqYN4hojRULFh8ed4ew+/aBEA9 vr9+ETWCIQtuG4ktvjBeA1EDFxoPMfc8XDsHtNKhY2XePAi9rSK6eOhJG3xJ/3kIYhcz 70hH3z/ZFqtvwImc+pz7qWvFCL5ozUV3IPkurIYGBUYTTfXZgekDmAtzV1dhJ2PWYKT5 KltA== X-Gm-Message-State: AOAM533bzIxZ53NQ9hYbA6eFAJCYP1Uz72twmsIcL1btRKCL7BVXhwnT YrYI456TnWe5d6hmp8RKWd+mkhk5KDneecraRRMD/Q== X-Received: by 2002:a02:918d:: with SMTP id p13mr26420892jag.51.1619014111274; Wed, 21 Apr 2021 07:08:31 -0700 (PDT) MIME-Version: 1.0 References: <87r1jbv6jc.ffs@nanos.tec.linutronix.de> <87eef5qbrx.ffs@nanos.tec.linutronix.de> In-Reply-To: <87eef5qbrx.ffs@nanos.tec.linutronix.de> From: Lorenzo Colitti Date: Wed, 21 Apr 2021 23:08:19 +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 Tue, Apr 20, 2021 at 11:19 PM Thomas Gleixner wrote: > 1) hrtimer is contrary to timer_list not really suited for high > frequency start/cancel/start/... cycles of a timer. It's optimized > for the start and expire precisely case. Ack. This is not what the f_ncm gadget code needs. It just needs a timer to fire "about 300us after the last packet submitted". Under load the timer will almost never fire since there will always be another packet coming. So the speed of adding/updating the timer is much more important than the accuracy. We will try to move it to timer_list. > I assume that's an ARM64 system. ARM64 CPUs have an architected per > CPU timer where the reprogramming is pretty fast as it's next to > the CPU, but who knows what your system is using. This system appears to be using timer hardware that is... slow to program (microseconds). We're looking at whether it's possible to use the arch timer instead. > Now in the meantime I looked into __hrtimer_start_range_ns() whether > that double reprogram can be avoided without creating a total trainwreck > and imposing penalty on all sensible use cases. Completely untested > patch below should do the trick and it's not ugly enough that I hate it > with a passion. I tested this and in my simple benchmark, the double calls are gone and hrtimer_start calls tick_program_event approximately once (more precisely, 90.06% of the time; sometimes it doesn't call it at all). This is not enough to cancel the regression we're seeing because the previous code would pretty much never call tick_program_event at all. But it's definitely better.