Received: by 2002:ab2:6046:0:b0:1fb:d597:ff75 with SMTP id a6csp8082lqm; Tue, 4 Jun 2024 17:53:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVBrjyyT20FpE/74RR6WHW0Mhti0w0erMy4iCPVqvNq3rH6npsUGRLZ3De3Q5F5UMTInhuSqrRcJEnxwarWLx4wN++y1UmbKrHinUa53A== X-Google-Smtp-Source: AGHT+IGd2Wpd3dkWmJzmtvRg2sfOch8esidwaq4nc0ssyE4CIWmK7ntfiOVmybLLR5yyaT9a1Oh9 X-Received: by 2002:a17:902:e84f:b0:1f6:7f16:4fce with SMTP id d9443c01a7336-1f6a5904025mr13780525ad.14.1717548789950; Tue, 04 Jun 2024 17:53:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717548789; cv=pass; d=google.com; s=arc-20160816; b=t5GHvoLxbiBkBkfKR1kq8zePhiCUdNhDj0ObB4/njk6n3JHKxVg++909WONScrLLSB S0/atM6U8yyF8pSOnzguHSWY6d48WIOSh71/l7nYIIO8cEUKdUxSF1m0HYl5dh1YiegD UAx+G55Cif3K2R681jNzE1CgXT4pMLe4OCMiUTEhHqy4G199V06LHbCDfmPMMhPw0SfF HyVdI+pwDsa2NcfslUfMmx0EBtEwmIuLuHgtxCKSsxHyCZgZepmJ32colY9Nb4h+5WWu NIPiQnh/Uj8NdP/m9B7z8vthw3y0WfSCoRz0sPoHKcDl1JtMlwr3vNBARcvT1IJJxh1d opBw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9gO28Na5Or7X4vcdl0zpmmA5fJQ1WvuUB+1qpfVVnOc=; fh=FzNO7QJOSmoZAgHEpz8WfdZUnmb0HH2qXEIzxqhEQPo=; b=OBz02FUPagihS6L+LtTKTd/E8ME9SRInozazCzGNQu61HRGiVIQrAzc2KVZVEWUvmn QYgDLGEpm6Epgg+6T3el0WIsxB9SOafE6rwTQgzUvEXcUsNaftJ4t0m5yGHf/qOrr1Pd soKrx0zQvWxkVskFtRIinpgIm331wbTd1TEJuHrj2+O14CucJLWW3f0py5NWun8cyVE1 K6FEMxRdqPnI3YB0w/HXj++HkS74KEVeDN5aMEiQwPUamR1Bifs4EkRrZaZIMssMo3LW DTTz4qHzSkHSqAsua8RaMUO8dq3o4rJaKV2K5kuOjIw5CHhicwSwr/GySrfbtgOiahYT IkdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=JcdyiTW3; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-201630-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201630-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f66a467acfsi54077485ad.448.2024.06.04.17.53.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 17:53:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201630-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=JcdyiTW3; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-201630-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201630-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8E4CF2849C0 for ; Wed, 5 Jun 2024 00:53:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4EF869460; Wed, 5 Jun 2024 00:52:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="JcdyiTW3" Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DBC13D6D; Wed, 5 Jun 2024 00:52:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717548767; cv=none; b=rueklj6qToe6W7NN4XzHxknqq1NjbIA/kl+lCods/CbBErJMpTWSqFNoFTBagnJdlaUhriVNAxq4bdlmdWzehJYhyqy8eD5MsFWuPpRbszRNanFFXurIqb53znroVLjUO/Ija6swEHISv2RqLcEk1QRNxfWNq+KH58HnxEgzKgQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717548767; c=relaxed/simple; bh=oazLP4EwnwtllawJhyAlk4/fZjyXr7WsdQvrcbP4gqk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mOTQCxpf2mWufjo70ZYgqol645/0Mc4vdj6/v3Lh/SuPFiaGQpl3D2DFx5C3O88Xf51kZlkL67+NrCmGqOk2cEZZyX4meeLmbQCP1SQMUoimO8sjm1vP7CsvtEiMbaguWKp8p0RL/AuxtpvWJzB3BWqaGsJ1B9YppVnqB3prreQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=JcdyiTW3; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=9gO28Na5Or7X4vcdl0zpmmA5fJQ1WvuUB+1qpfVVnOc=; b=JcdyiTW3Sf1oOPzPXSGG4A/aQI WrKOAaIDGvv2yPHWxIHG9bpXlhSF04aVlo28aSx7pfIGBJe07oTz1j5n3BMr9xwV6BenDveB1ZG+I lvQQG0JnvATnP7QejGGclwEinZqkyj419Id1bNa88gtcy7vPcHzBA8yiRWYFrUGsp/m8=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1sEetB-00GrAt-5E; Wed, 05 Jun 2024 02:52:29 +0200 Date: Wed, 5 Jun 2024 02:52:29 +0200 From: Andrew Lunn To: Steven Rostedt Cc: Jason Gunthorpe , Paolo Abeni , Mina Almasry , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, sparclinux@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-arch@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Donald Hunter , Jonathan Corbet , Richard Henderson , Ivan Kokshaysky , Matt Turner , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Andreas Larsson , Jesper Dangaard Brouer , Ilias Apalodimas , Masami Hiramatsu , Mathieu Desnoyers , Arnd Bergmann , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Steffen Klassert , Herbert Xu , David Ahern , Willem de Bruijn , Shuah Khan , Sumit Semwal , Christian =?iso-8859-1?Q?K=F6nig?= , Pavel Begunkov , David Wei , Yunsheng Lin , Shailend Chand , Harshitha Ramamurthy , Shakeel Butt , Jeroen de Borst , Praveen Kaligineedi , Willem de Bruijn , Kaiyuan Zhang Subject: Re: [PATCH net-next v10 05/14] netdev: netdevice devmem allocator Message-ID: References: <20240530201616.1316526-1-almasrymina@google.com> <20240530201616.1316526-6-almasrymina@google.com> <20240604121551.07192993@gandalf.local.home> <20240604163158.GB21513@ziepe.ca> <20240604124243.66203a46@gandalf.local.home> <3be107ce-3d9f-4528-b9f7-1c9e38da0688@lunn.ch> <20240604202738.3aab6308@gandalf.local.home> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240604202738.3aab6308@gandalf.local.home> > How is the compiler going to know which path is going to be taken the most? > There's two main paths in the ring buffer logic. One when an event stays on > the sub-buffer, the other when the event crosses over to a new sub buffer. > As there's 100s of events that happen on the same sub-buffer for every one > time there's a cross over, I optimized the paths that stayed on the > sub-buffer, which caused the time for those events to go from 250ns down to > 150 ns!. That's a 40% speed up. > > I added the unlikely/likely and 'always_inline' and 'noinline' paths to > make sure the "staying on the buffer" path was always the hot path, and > keeping it tight in cache. > > How is a compiler going to know that? It might have some heuristics to try to guess unlikely/likely, but that is not what we are talking about here. How much difference did 'always_inline' and 'noinline' make? Hopefully the likely is enough of a clue it should prefer to inline whatever is in that branch, where as for the unlikely case it can do a function call. But compilers is not my thing, which is why i would reach out to the compiler people and ask them, is it expected to get this wrong, could it be made better? Andrew