From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mail.toke.dk (Postfix) with ESMTPS id 374EC9EA232 for ; Thu, 16 Feb 2023 16:17:51 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=imSjoBPZ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676560670; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Hu0NDPUgPtJQPv1XAu2IlR0R1Izce8nrz7t5aM+xvQk=; b=imSjoBPZi8GH44bbXhpMnMqGs3hRUIPHFwVtsPhPI1p+OZld+9IfqwQIfpgq/n5AXIdSo0 pKn00CLo6d2nnSf46eOp31XlTCGdNPtzGyg0+b2D33w1ncAGspeFF6eCUmpy4cotw80UJC P41uDbaF9jKWUhOF7bG6fj1kd539NpQ= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-596-c8YuKEG4NoqDzqw2DBeDEA-1; Thu, 16 Feb 2023 10:17:49 -0500 X-MC-Unique: c8YuKEG4NoqDzqw2DBeDEA-1 Received: by mail-ed1-f71.google.com with SMTP id g14-20020a056402090e00b0046790cd9082so1968963edz.21 for ; Thu, 16 Feb 2023 07:17:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:content-language:references :to:subject:cc:user-agent:mime-version:date:message-id:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Hu0NDPUgPtJQPv1XAu2IlR0R1Izce8nrz7t5aM+xvQk=; b=q6i+d5bpAJ+0TrrUuODSj0p/MUpmQSI9W6m8T8qRzl2vH/2LyASwiIxQNM7gVw+gk7 cbWAtVOWyitCDQbLwzyfqblA+mQYfWPJD+KVmCr+H6NEVXqIAELwi6K1BRxI7JXKDBdS 1IU2r2zgw9CVjTa6jXBP3zUD5Osy232mqBY9ZViAB3w/gqPvhJ5Q3k0ggqRyZAjClEGC bTyJ6oi61t2PayppZr6yx7HTLkqNc3dnJt0W4UEVEn5M4Y1FHFMFlU+aP+G3wXmNrpME wIqi4oyZFjCEVyBNmFt6oJm78IJJnHp/2DigvtNNbjPw3DERKher/582XmOBNjVfpC4p THbA== X-Gm-Message-State: AO0yUKWPES53DFrVJPqZWiNr5j32JmD28w/O+5zCNrSxuSa5hJzM4CWt 81Bp8/NijZBCdU50fNZZMnl3W+IY4Pm85VZaaNEW9RCYA+Y0NVGJ9cUWeellEPMJV+q8yX/WuKo NRCxiZZ72zuB+l22RlGyI X-Received: by 2002:aa7:cfc6:0:b0:4ab:2503:403a with SMTP id r6-20020aa7cfc6000000b004ab2503403amr5969370edy.34.1676560668571; Thu, 16 Feb 2023 07:17:48 -0800 (PST) X-Google-Smtp-Source: AK7set/e0ygiKMDvoNKR1sy40kN4i/T2Q1Ay4lVRellixuesMpm665RS/+dBn5HBdKLkS/bSjZzPIQ== X-Received: by 2002:aa7:cfc6:0:b0:4ab:2503:403a with SMTP id r6-20020aa7cfc6000000b004ab2503403amr5969337edy.34.1676560668263; Thu, 16 Feb 2023 07:17:48 -0800 (PST) Received: from [192.168.42.100] (nat-cgn9-185-107-15-52.static.kviknet.net. [185.107.15.52]) by smtp.gmail.com with ESMTPSA id t9-20020a50d709000000b004a249a97d84sm995434edi.23.2023.02.16.07.17.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Feb 2023 07:17:47 -0800 (PST) From: Jesper Dangaard Brouer X-Google-Original-From: Jesper Dangaard Brouer Message-ID: <9a7a44a6-ec0c-e5e9-1c94-ccc0d1755560@redhat.com> Date: Thu, 16 Feb 2023 16:17:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 To: Alexander Lobakin , Paul Menzel References: <167604167956.1726972.7266620647404438534.stgit@firesoul> <6a5ded96-2425-ff9b-c1b1-eca1c103164c@molgen.mpg.de> In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: CBMJ4ZQ6FKKJ7OJRV3I7LERMDQFQCCB2 X-Message-ID-Hash: CBMJ4ZQ6FKKJ7OJRV3I7LERMDQFQCCB2 X-MailFrom: jbrouer@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: brouer@redhat.com, bpf@vger.kernel.org, xdp-hints@xdp-project.net, martin.lau@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org, ast@kernel.org, Stanislav Fomichev , yoong.siang.song@intel.com, anthony.l.nguyen@intel.com, intel-wired-lan@lists.osuosl.org X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] Re: [Intel-wired-lan] [PATCH bpf-next V1] igc: enable and fix RX hash usage by netstack List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 14/02/2023 16.13, Alexander Lobakin wrote: > From: Paul Menzel > Date: Tue, 14 Feb 2023 16:00:52 +0100 >> >> Am 10.02.23 um 16:07 schrieb Jesper Dangaard Brouer: >>> When function igc_rx_hash() was introduced in v4.20 via commit 0507ef8a0372 >>> ("igc: Add transmit and receive fastpath and interrupt handlers"), the >>> hardware wasn't configured to provide RSS hash, thus it made sense to not >>> enable net_device NETIF_F_RXHASH feature bit. >>> [...] >> >>> hash value doesn't include UDP port numbers. Not being PKT_HASH_TYPE_L4, have >>> the effect that netstack will do a software based hash calc calling into >>> flow_dissect, but only when code calls skb_get_hash(), which doesn't >>> necessary happen for local delivery. >> >> Excuse my ignorance, but is that bug visible in practice by users >> (performance?) or is that fix needed for future work? > > Hash calculation always happens when RPS or RFS is enabled. So having no > hash in skb before hitting the netstack slows down their performance. > Also, no hash in skb passed from the driver results in worse NAPI bucket > distribution when there are more traffic flows than Rx queues / CPUs. > + Netfilter needs hashes on some configurations. > Thanks Olek for explaining that. My perf measurements show that the expensive part is that netstack will call the flow_dissector code, when the hardware RX-hash is missing. >> >>> Fixes: 2121c2712f82 ("igc: Add multiple receive queues control >>> supporting") >>> Signed-off-by: Jesper Dangaard Brouer > > [...] > > Nice to see that you also care about (not) using short types on the stack :) As can be seen by godbolt.org exploration[0] I have done, the stack isn't used for storing the values. [0] https://github.com/xdp-project/xdp-project/tree/master/areas/hints/godbolt/ I have created three files[2] with C-code that can be compiled via https://godbolt.org/. The C-code contains a comment with the ASM code that was generated with -02 with compiler x86-64 gcc 12.2. The first file[01] corresponds to this patch. [01] https://github.com/xdp-project/xdp-project/blob/master/areas/hints/godbolt/igc_godbolt01.c [G01] https://godbolt.org/z/j79M9aTsn The second file igc_godbolt02.c [02] have changes in [diff02] [02] https://github.com/xdp-project/xdp-project/blob/master/areas/hints/godbolt/igc_godbolt02.c [G02] https://godbolt.org/z/sErqe4qd5 [diff02] https://github.com/xdp-project/xdp-project/commit/1f3488a932767 The third file igc_godbolt03.c [03] have changes in [diff03] [03] https://github.com/xdp-project/xdp-project/blob/master/areas/hints/godbolt/igc_godbolt03.c [G03] https://godbolt.org/z/5K3vE1Wsv [diff03] https://github.com/xdp-project/xdp-project/commit/aa9298f68705 Summary, the only thing we can save is replacing some movzx (zero-extend) with mov instructions. >> >> [1]: https://notabs.org/coding/smallIntsBigPenalty.htm > > Thanks, > Olek >