Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp936220pxb; Thu, 15 Apr 2021 09:50:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjgKbs4X3DXlUquarvv0JX0pj2PxDkTnO9NWAQNf+Ojk6h90rr0HEzKjwdnPr/DcpFTNx1 X-Received: by 2002:a05:6402:46:: with SMTP id f6mr5388778edu.252.1618505453957; Thu, 15 Apr 2021 09:50:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618505453; cv=none; d=google.com; s=arc-20160816; b=S2yU3Q/CcJGMIJOEdnZ9g2Gq23m6p63gzq0knjyJCYZhgtrJVv1DBJAFTZfZ5kMO2g D73nUm2t4OOeROyjo5xVtLEQ4gAVBKSd63T1Y1Xum8Vyg3GqZtH2thHc2c3JdVfsI087 0LmqzkTyqO9rSnKxdiykS4S0tq65YeKj+aL/n/oWST11aS7YpyBW98FoVGQ0Ej59ZNla yFCjrb9rxn6126V80Vhqy4DLel3u4/XVgxllogAWh9Ala0B/1H3Ofv/XXLvkckvDVBXi rek25R71DxFqwIv8swRagshVpArjvlMhlALW8D9FtD229obAzZBhuhFqNb138Vyr5PMj 3HYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=Ij+uTvdXS+i44BI8usBRso/TQwX1K1KTl2LSXZhUKWo=; b=p/is/dtkyaxONpEcLO7Dwl7D8eFtvr7gvwi2u0HWpU+2sLonvN4op3P1Oo1L4xb5ds JsRqtzyl+xHh0cdYRzpp9+ekqC5NKjPKehyRmk/ZNWxcwVkFGLGSag5hzoFXlDv3t/Li LsaGkXVX5PEw1dkfPJVuLqBqrbwUwDOQYGNuao6jLZVwCmRSrvC/DVbN2lpzWsyRXqoj Z9XMHgArvtePx5IWVEcYPd/uxloWZaUB3ot8ZumQB1eWAyOgljrjd8/4qSfMgAMVkv4a WTbN0gw25RJ1nXj1IRXy9dqAH13JBXrK1siD7WDqCE2e/bNbVxaJcOJPOQfqGqNMTM3e y07g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vEAEiuya; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=XIpKNyzm; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l19si2897884edc.214.2021.04.15.09.50.29; Thu, 15 Apr 2021 09:50:53 -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=@linutronix.de header.s=2020 header.b=vEAEiuya; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=XIpKNyzm; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233916AbhDOQsA (ORCPT + 99 others); Thu, 15 Apr 2021 12:48:00 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:32900 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231137AbhDOQr7 (ORCPT ); Thu, 15 Apr 2021 12:47:59 -0400 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1618505255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Ij+uTvdXS+i44BI8usBRso/TQwX1K1KTl2LSXZhUKWo=; b=vEAEiuyatSPvPasYmHicpnRVSKCmNLpbaupdo2cJ2KNDO3r9kLSwyDKKYfVEXJpfliRe8A vwS/CfbECdwH2oz4Rzgv+Gc1t4jzPaW1DULTHR+nYoZzq1rCJ1cPMqn/Mdvt5x9uUbNk51 q3Oz6A550mCu4oUvX40/ueEc48sYLdRR3tV9cLqlsnu7NaHHnE+PAMLsAgT02BX2saN0LE ehblqAGvMD6PYC7vYqtPA40HliOUuFj8APztpRRnKsPLMX00SiVnHPts0dKrTRRr035n+A hnGr5g5mj+1u5ui7rNCchaF92y0hG/ngzUDQMMRH+/X5pQseUW96D5D4J6NgqQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1618505255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Ij+uTvdXS+i44BI8usBRso/TQwX1K1KTl2LSXZhUKWo=; b=XIpKNyzm6L4xPG0HN3vGp+unsBCCbWn4VN6zHsp1zE+YXOWbwpcesZ4B+2yuQxMmc6N94c oNKzfDriw3Ix5MBg== To: Lorenzo Colitti , Greg KH Cc: Maciej =?utf-8?Q?=C5=BBenczykowski?= , Ingo Molnar , Anna-Maria Behnsen , lkml , mikael.beckius@windriver.com, Maciej =?utf-8?Q?=C5=BBenczykowski?= Subject: Re: [PATCH] hrtimer: Update softirq_expires_next correctly after __hrtimer_get_next_event() In-Reply-To: References: Date: Thu, 15 Apr 2021 18:47:35 +0200 Message-ID: <87r1jbv6jc.ffs@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 14 2021 at 11:49, Lorenzo Colitti wrote: > On Wed, Apr 14, 2021 at 2:14 AM Greg KH wrote: >> To give context, the commit is now 46eb1701c046 ("hrtimer: Update >> softirq_expires_next correctly after __hrtimer_get_next_event()") and is >> attached below. >> >> The f_ncm.c driver is doing a lot of calls to hrtimer_start() with mode >> HRTIMER_MODE_REL_SOFT for I think every packet it gets. If that should >> not be happening, we can easily fix it but I guess no one has actually >> had fast USB devices that noticed this until now :) > > AIUI the purpose of this timer is to support packet aggregation. USB > transfers are relatively expensive/high latency. 6 Gbps is 500k > 1500-byte packets per second, or one every 2us. So f_ncm buffers as > many packets as will fit into 16k (usually, 10 1500-byte packets), and > only initiates a USB transfer when those packets have arrived. That > ends up doing only one transfer every 20us. It sets a 300us timer to > ensure that if the 10 packets haven't arrived, it still sends out > whatever it has when the timer fires. The timer is set/updated on > every packet buffered by ncm. > > Is this somehow much more expensive in 5.10.24 than it was before? > Even if this driver is somehow "holding it wrong", might there not be > other workloads that have a similar problem? What about regressions on > those workloads? Let's put the question of whether this hrtimer usage is sensible or not aside for now. I stared at the change for a while and did some experiments to recreate the problem, but that didn't get me anywhere. Could you please do the following? Enable tracing and enable the following tracepoints: timers/hrtimer_cancel timers/hrtimer_start timers/hrtimer_expire_entry irq/softirq_raise irq/softirq_enter irq/softirq_exit and function tracing filtered on ncm_wrap_ntb() and package_for_tx() only (to reduce the noise). Run the test on a kernels with and without that commit and collect trace data for both. That should give me a pretty clear picture what's going on. Thanks, tglx