Received: by 2002:ab2:6046:0:b0:1fb:d597:ff75 with SMTP id a6csp835lqm; Tue, 4 Jun 2024 17:34:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUccP2382E4WCVMyzk7TFy9/b70Vy9Vf18XYV4cBdZ8bGJWd7EOQ7A3ao9QZWo6y2t44P8sKQDyDFDZfiknrz5IWai3uEEhHfHKD8qJVg== X-Google-Smtp-Source: AGHT+IHumA6RsJMPDRmp093UX+YrZViDvx8tYPsxDJbJdTi8B1xBf6vfzuECQgXFGwAbdv92tweA X-Received: by 2002:a17:906:e2d5:b0:a68:e0fc:c64f with SMTP id a640c23a62f3a-a699f362d02mr70465266b.15.1717547665524; Tue, 04 Jun 2024 17:34:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717547665; cv=pass; d=google.com; s=arc-20160816; b=Ohy9ZFuPXKNsG5tyrLljb0/aWPgxzUECYYISFl83XV4UVtzra+NRI9mMW1wYBHZNds g1uXzWXYCEq1XINb1VJp/3PVd57D/9769ITLgxlRSK7hOXJoBN8gE1sqe021dFcxf4bH Xkh9fEM1ZzjOOOv9CFIphfDjUO5D5rOPrkVV+cwkuOlvXfnhvh3zk8+moQ6daIR2YU6e m+nYy9+aTTvX4iUQZFx+XZgdIctPlKSwDNjM1h0aukH4QvgbK3eDMIAeJNhL7McSww5t snEE3HjXpb5H9x8ZCk4wHEwWbnlV9JMGYfqdGBcORw45+QlL6NKzO26A8+PQ1fblvF6q zuDQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=9w+MbeBqFEEEcWJMHWHUnV6V0GTKb7ur1q+rqGrpy3U=; fh=JBezuglN3T0SVw/ISaWHnTZvH/5TlhnClxb0deCoYn4=; b=zh0/ydCSq1I1D1A6HrkKExueVkSA1RWFEaP13EZRTx5dGGe2qNkoE5o23D/gAkcH6T zPqMeHjv3VKmkQXV0MzoMvzB7Jkqur0eds0x4tfFDzsEfa1H4i4sqfE7WqgygALIDHN+ KRiNU87XcJJEJA7f0SaeIP9LiXVUnOyDH+NZRPUqZmudBjwAiWpyE53sD0ux1UUQ6NaR slGRLQKfAqXJl2K5WpJweJDmriqJJi1p8Lb6PdtfnASBJXO20w0EzBGoJ9bHMFwSqDby PzHEqsDC7Eo/Ny+qDMh2QBZSHWexIX7KJyiez+p0eQOb0msmh/TTHLAiSgZpV/fhDaKC CT8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-201621-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201621-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a67eaf65280si523459066b.801.2024.06.04.17.34.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 17:34:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201621-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-201621-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201621-linux.lists.archive=gmail.com@vger.kernel.org" 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 380D31F2382B for ; Wed, 5 Jun 2024 00:34:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CCE81F946; Wed, 5 Jun 2024 00:27:45 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8174417552; Wed, 5 Jun 2024 00:27:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717547264; cv=none; b=MWcfVAZ4n+u5XEkGbtkX4bt0zSHcZAekEvsYzTEBQBnjz97qmANH9Su9V5ZK5AEXDoo3CGFRCVDe+puYNex/5HX30OmHgbPkx5SPnMBLJqc8rXm2oFWe51AcE08CDUVo54uyZbWXjTWYjHPI+kJalp0S1S+agYQ6qr+i092ZHoY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717547264; c=relaxed/simple; bh=4ioJ7jsTZe7TCII2oIQNctHCar1QWaLEso6N0VtfjuA=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MecI/+6KlnBZVdfTskfYl+KMczTNbj0JaVTsDLmPD9rtPeAM8ItLbqSXfcbQ1jVHEr05iO6QnIW/XhTfZSVrTyjsyNXxFZ0vWwt6Bp28vA9dztj73rb7Wn2CdNoxzObjwwP8CAsZgHLvDdrZgKrzdNC65Hqji7yuifvoYi9dpiQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC87EC2BBFC; Wed, 5 Jun 2024 00:27:37 +0000 (UTC) Date: Tue, 4 Jun 2024 20:27:38 -0400 From: Steven Rostedt To: Andrew Lunn 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 =?UTF-8?B?S8O2bmln?= , 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: <20240604202738.3aab6308@gandalf.local.home> In-Reply-To: <3be107ce-3d9f-4528-b9f7-1c9e38da0688@lunn.ch> 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> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Wed, 5 Jun 2024 01:44:37 +0200 Andrew Lunn wrote: > > Interesting, as I sped up the ftrace ring buffer by a substantial amount by > > adding strategic __always_inline, noinline, likely() and unlikely() > > throughout the code. It had to do with what was considered the fast path > > and slow path, and not actually the size of the function. gcc got it > > horribly wrong. > > And what did the compiler people say when you reported gcc was getting > it wrong? > > Our assumption is, the compiler is better than a human at deciding > this. Or at least, a human who does not spend a long time profiling > and tuning. If this assumption is not true, we probably should be > trying to figure out why, and improving the compiler when > possible. That will benefit everybody. > 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? -- Steve