Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1120097ybi; Wed, 3 Jul 2019 09:49:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFr3jFX4Q8GywcrcfYriFhEV2MhuoZYMbKIKbH+UfeQ7ELngJvH06RxPqo9Z2ECESZkNU5 X-Received: by 2002:a17:90a:d997:: with SMTP id d23mr13221790pjv.84.1562172582436; Wed, 03 Jul 2019 09:49:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562172582; cv=none; d=google.com; s=arc-20160816; b=g9uYjAArWXeW/90EpaG8MssDEHJb1G1FtJ1Kcv6lJqRuD1bg/kDokcPRBjU3WZOLe7 ql7iQQ0GTv8prRBXzMoexTumSHyaV1x6r2BX3o6at6FihUiJZhB4p6joYQvFfauMCRDF YE+JFyu1wOeD7P4ypyOS3j0vewCbCI7js+t2ZNhjLoopw2NFn6XKBYqOKWb1brjR6QAv 3Vo46oki2/48HTX0EHSmpd280HAE8hJZqGCMId5fcYQtIq8Yp5yqgeRnE0RK3KVX52Mc WdMTMIHwmK3f0gHKsRCwmDFvtGFx0QHkkuqSxrRomDNwcYd2nglHMu035G360KXn1F2E wx8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=yJ/AMqCgjHOX7uREQW2b21H1rv+p0xkV9JezuXq3Lrs=; b=ZT3+8t/lieazv+ZODJx5yzHvgPqm5xe+Op7JRNYYeEQVm3IBrjyafYBPOJpR2H0oGZ eFUm0MDYlsCPeRKPHRQr5SlUqqGiMqO3l21od4RjY8O++I/9jNPvk3/3Em4D2YmtsRiS mNYb+xE/wbllA74ENT0HSD04PGtG8wu/Ryz9hq61P7wcY0q6ZsjBgaAZe584ifdsKAA7 z4RdrzO+dh/iDHI85hdvA/u0xVxu0iFc4lrbraYa/xjlBTc7msfYoVAUls+cSZLpAMAX 2qkjP9FlyD0i3TXSV8i8aksTeqQUGu+kJ3P045WXW6wAm0mLeheAqhothucTPl58U4vL WCMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PYCV3Ki+; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e25si2878062pff.30.2019.07.03.09.49.27; Wed, 03 Jul 2019 09:49:42 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=PYCV3Ki+; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727056AbfGCQsx (ORCPT + 99 others); Wed, 3 Jul 2019 12:48:53 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:43936 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726430AbfGCQsw (ORCPT ); Wed, 3 Jul 2019 12:48:52 -0400 Received: by mail-qt1-f195.google.com with SMTP id w17so1203447qto.10; Wed, 03 Jul 2019 09:48:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yJ/AMqCgjHOX7uREQW2b21H1rv+p0xkV9JezuXq3Lrs=; b=PYCV3Ki+HIxfv3LCSaaOhpNO0ILCQojaCN/Usn1R7wPqtJthrqytqFJ3xAEs5RVllF mcdBg1xGlEmpZV15vV47oY1ANNSVFV8PZqk8k+5J6Ap+moz06KU2dZf93XxMTp9crwOU SbC2rSoy/zfmOE+STsNSaVc26bxGUhMkIFh0OeZwUdllN2mqxZuG3Cflqoaxki6KrQOR UTuZv7+tBucPPxMZw/+l86b+cCSLX3Yt99lCF5r2NuM10pY1R6GrzKUWM/bTStwzrqSE 659SFGlMCIgDiUKxk1SUDlpkSmmt4eGi6ULQNjPth35HN0TmSpmkHLFFeEZni/epIC8D Lv2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yJ/AMqCgjHOX7uREQW2b21H1rv+p0xkV9JezuXq3Lrs=; b=nEngJeeZiYolpKUutDaLqpqHHKKGBZHfSfk09qD8reQPitkkojg9wU/VmkNyiiAZFJ 7ODPn/XAsc0Wtz1RV03ABiXaAiVXo59XQr3Py+972oGAZ52is1AMVwgo+FI748HLGfvF SwWGqTg1x5M7UZxX89aQqe5Rb5X9reBqFv/nXRzOgWH91reb3D2SB8qUBqtj3nUomayo JX4ZGJwBRtiHtDDXSYm2yUK2mLwAkcABZe8DnXZ3YSq6f0CRJl6uyqWc2rVoL7uEsJhP urGCRJTbWVd2R1d/YLxf8jkwPQiBraZeYTl5QETXGvfxVAI9kUhqEKRWKNH3sH/2Ff6i xntA== X-Gm-Message-State: APjAAAUJe+SwlPbB3Lac+m/TOJIkQWtjuLx9QcAPDzzXWXUKHIXEsGNz pwzTYMPXuSSQPSO6tjpVV3As/yL5a4m9yzLMzio= X-Received: by 2002:a0c:c586:: with SMTP id a6mr33611361qvj.177.1562172531460; Wed, 03 Jul 2019 09:48:51 -0700 (PDT) MIME-Version: 1.0 References: <20190703120916.19973-1-i.maximets@samsung.com> In-Reply-To: From: William Tu Date: Wed, 3 Jul 2019 09:48:09 -0700 Message-ID: Subject: Re: [PATCH bpf v2] xdp: fix race on generic receive path To: Magnus Karlsson Cc: Ilya Maximets , Network Development , LKML , bpf , Xdp , "David S. Miller" , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Jonathan Lemon , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 3, 2019 at 6:20 AM Magnus Karlsson wrote: > > On Wed, Jul 3, 2019 at 2:09 PM Ilya Maximets wrote: > > > > Unlike driver mode, generic xdp receive could be triggered > > by different threads on different CPU cores at the same time > > leading to the fill and rx queue breakage. For example, this > > could happen while sending packets from two processes to the > > first interface of veth pair while the second part of it is > > open with AF_XDP socket. > > > > Need to take a lock for each generic receive to avoid race. > > I measured the performance degradation of rxdrop on my local machine > and it went from 2.19 to 2.08, so roughly a 5% drop. I think we can > live with this in XDP_SKB mode. If we at some later point in time need > to boost performance in this mode, let us look at it then from a > broader perspective and find the most low hanging fruit. > > Thanks Ilya for this fix. > > Acked-by: Magnus Karlsson > > > Fixes: c497176cb2e4 ("xsk: add Rx receive functions and poll support") > > Signed-off-by: Ilya Maximets > > --- Tested on my machine and works ok. Tested-by: William Tu