Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2971972ybl; Fri, 20 Dec 2019 01:36:29 -0800 (PST) X-Google-Smtp-Source: APXvYqxWjshWjCOKSWZDa7O5hReQ57qO1TLU17vZuIcvuf1hZt5IVLUS9EfCrr4cfpJ18Yvod6w0 X-Received: by 2002:a9d:8f1:: with SMTP id 104mr11559001otf.107.1576834588949; Fri, 20 Dec 2019 01:36:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576834588; cv=none; d=google.com; s=arc-20160816; b=bPBkA1bpZ7XTo4+cUGiWAGAwAiKzS/ZaUkZx9ri0Q5vKXInj7rJi+cPEDqfz0eFSbA D0PwJnvWvPyKbMAKgf8SqJNfzLQ9JSNPYG8d+H0Ep+mA1o74TnQfHumDM6SaFTOFJk7j 6kpfAp36ej/17NXA5H5ZuzTrDkFMFzSrnj1nssoJlzzQi5+eTqc9NFnBSZYJqaV78wRH KTRtF5T9wcL/jARLOx59VO2gqxVgR/t0aRAAySKc14IIGmqtabRzyt8mga09BnBORLMJ exRiBQyORuqV5GQy66QIWSpBHgCHCQaApzFdvy3KZgmXNvmN96uYZLmqTAcV2IXeWRbm Qt0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=0/UxvPCeTXUKVldWIXLXTiQznfkGrThtTbge0OdQKe4=; b=ln7myhdfeaQDqJTPvX8jRHbGBX5n712oCGgPjLS5rFmvqceqRhvRQoNpe1Zua+vR/k Z3OOpow7Xa6YCTYZ9wNQtLsWpYhtofAAui725DvwLJthtyKHSW7TkEKK/LlipzQEKq5g SipAZzPjdGNyrJOaQIpwU7DrO5YX/IZJpfEtvzmv6wG/FCAOKYZ2RpGDCIZxS8azn+GE hT5SKiJkGn7vDszubUTQH38EdQwFkx8GvjamEnkjE2tKiON7GRJ6BHXpxIodzb3atDf0 0sSFL5B0clgHVVNCIMSg3aJly4N4pjgRRzCg9fLX8XJ4LAAU+3dO85X3nkv02kRWFe2X ZKww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Wr73SsqL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w4si4724985otl.214.2019.12.20.01.36.17; Fri, 20 Dec 2019 01:36:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Wr73SsqL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727412AbfLTJed (ORCPT + 99 others); Fri, 20 Dec 2019 04:34:33 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:41192 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727279AbfLTJec (ORCPT ); Fri, 20 Dec 2019 04:34:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576834471; 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=0/UxvPCeTXUKVldWIXLXTiQznfkGrThtTbge0OdQKe4=; b=Wr73SsqLoUnzP0qsA+LNqwxJnV7UETTmNcjUAqU4jlb9W37Lxg5+FoBMBm472gBMnd9uN2 VWV55W3nT7fudccG0+budwK+SwkvapTznOG/+y0bhtsntmn+qAyJZ0wPdbxgrqmEWMhbzK gRY3OGLXWMYiwaT3QSTEWxwUamAfBmo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-102--qmUq0DYNauUF-7U1HEAow-1; Fri, 20 Dec 2019 04:34:28 -0500 X-MC-Unique: -qmUq0DYNauUF-7U1HEAow-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E9D3510054E3; Fri, 20 Dec 2019 09:34:26 +0000 (UTC) Received: from carbon (ovpn-200-18.brq.redhat.com [10.40.200.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42B5A67009; Fri, 20 Dec 2019 09:34:21 +0000 (UTC) Date: Fri, 20 Dec 2019 10:34:20 +0100 From: Jesper Dangaard Brouer To: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= Cc: bpf , brouer@redhat.com, LKML , Tejun Heo , Christoph Lameter , Dennis Zhou Subject: Re: Percpu variables, benchmarking, and performance weirdness Message-ID: <20191220103420.6f9304ab@carbon> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 20 Dec 2019 09:25:43 +0100 Bj=C3=B6rn T=C3=B6pel wrote: > I've been doing some benchmarking with AF_XDP, and more specific the > bpf_xdp_redirect_map() helper and xdp_do_redirect(). One thing that > puzzles me is that the percpu-variable accesses stands out. >=20 > I did a horrible hack that just accesses a regular global variable, > instead of the percpu struct bpf_redirect_info, and got a performance > boost from 22.7 Mpps to 23.8 Mpps with the rxdrop scenario from > xdpsock. Yes, this an 2 ns overhead, which is annoying in XDP context. (1/22.7-1/23.8)*1000 =3D 2 ns > Have anyone else seen this? Yes, I see it all the time... > So, my question to the uarch/percpu folks out there: Why are percpu > accesses (%gs segment register) more expensive than regular global > variables in this scenario. I'm also VERY interested in knowing the answer to above question!? (Adding LKML to reach more people) > One way around that is changing BPF_PROG_RUN, and BPF_CALL_x to pass a > context (struct bpf_redirect_info) explicitly, and access that instead > of doing percpu access. That would be a pretty churny patch, and > before doing that it would be nice to understand why percpu stands out > performance-wise. --=20 Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer