Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4689ybv; Wed, 19 Feb 2020 15:12:56 -0800 (PST) X-Google-Smtp-Source: APXvYqz8pSTp2/O5gKZ/fbk08EhdJIaHP+mFoR9/QleMC4S+/Yo4Aw6Z7zToA9SlGvicSI7Kyw0x X-Received: by 2002:aca:43c1:: with SMTP id q184mr64917oia.116.1582153976783; Wed, 19 Feb 2020 15:12:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582153976; cv=none; d=google.com; s=arc-20160816; b=i3cb5kuq5W4Vsj7Mx+sZiqSZmnJ9ivmvMgLW3/mXOk/DV8GM2lEwWu4odNecsHDaLB KpwJCIvNMj1SLwuvJ1W2Up9ErKlQ1dGcPP+6jxXS3LlKFykXO4echPmL0GC24NoSXgh5 bq58OB2bxuvFUUIGVhI+oGdNICPR5nQbwnGRS0vKuZcDRTQaiJtHrbU+9nXzBlp4phpt 45aeZpY/2z+xZke4O52DaNA8RGWz7T6xNbKbaEbzaP8g25C6fCldlmwg/+TBZBIwvxFv B+6GDJ0hgEG4MA+St569wAkpQ2jxBrdWZaVU8CzxHnohQkKGwUTk3znfHFA8ihCyrv59 Tvaw== 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=wWdZgMsswVvJQU2MierpIWKnEFD04FeEgnx6asgVYnI=; b=aAm3GVEePLqmotOh+PUJGe902UHJsEQqDYE3qVg4FEJdqyXoVecG+lcr7KCT3O+n6H IPkCpFEf3HkORZvU4wZKkWcsypxKMUW4NkDvKnQwNOIFozz6TcjRQSSlJBt07BPpe4Jr dMMD9ylCRgD1BohgrE9C2AS16tqtXYspYSjJ2kSW/bgIa1kWn6pib3CHQKyhF/V4/oWH PGhQJAcfJ1Du8P5yVBABMBu06BgWVaUoT7a/8f9YZ1L+q5+tkETAHQs8j8IhH67YD8gJ g8pSkZkAviXefCAdVV9sWOimUDn7D+GFjMMlxG4tpEyYOxZtRG/E3QttkeR7LXU/O7Md OWeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WZp2sja7; 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 j9si592424otl.153.2020.02.19.15.12.43; Wed, 19 Feb 2020 15:12:56 -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=@gmail.com header.s=20161025 header.b=WZp2sja7; 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 S1726718AbgBSXMV (ORCPT + 99 others); Wed, 19 Feb 2020 18:12:21 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:42764 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726613AbgBSXMV (ORCPT ); Wed, 19 Feb 2020 18:12:21 -0500 Received: by mail-lj1-f195.google.com with SMTP id d10so2161859ljl.9; Wed, 19 Feb 2020 15:12:19 -0800 (PST) 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=wWdZgMsswVvJQU2MierpIWKnEFD04FeEgnx6asgVYnI=; b=WZp2sja7wA3CR4NIL6OyZNdn7QmZHOUFWiYV+dkja9uSHKew/+bKSEoWrRnL4FOiqN NGKZ4lkj83ixJoxxqYMgH7q+tRSNqs/cV0YQugYHYC6+zecrm6XFLsvmzH/6VoY2M6DH YNyynBe/YBVf54qhOuBgRSG0BduKg2rd+Gi9nZfJ+ShsciOYfrDHTibht+8oGOG8wO2i C6Mmp0pSF3V8ndb4C8RNL5DKFVNkzFNa4ps+1Uswgqj7AgLHsbDJUrCqc/ZnY1fnbNkT TFIojIeyAX77RzBMv0GTNM7oCJsteTdQAglUGUpH1pvd7ycS+nb4V0fsW8NgEVIWhmIY iydg== 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=wWdZgMsswVvJQU2MierpIWKnEFD04FeEgnx6asgVYnI=; b=IoyEC68NEy2B9YxLveA561cB1QlNGnv9l+4aHQr3/vSr8aCZu540C0hOz3ApJFtd4E maHWFUz5YTZXEVtSqM3kRM129bPQrSuUaDteQXCJRbyJ/2EacT7XRPCN5wXpzzTMvteD w39ZuBWvWofJWMVM/ajfTxEtslUzsjFPQTpXa8f1CM6U2KtVmDrqvEUJK9FMns0Vgdtv /j5444GS1hoVvQLpHN+dvNcXrtUQeNk7zUD6Mx5p+WiM1mDEb1slua+tUI0WvDOWtdnQ O6uW/UCbG+5HxwEFAbDfOT6wSJSdDvIWEYR7kiQHARlzx4VgvSuIOOFtP28JaVCQ7KN9 5swA== X-Gm-Message-State: APjAAAWukbffjjmctfRkVxE6NfHQUOI3IuSmGTGQrO+uwJNtuSIduaQd GCXPJ6zE524VyvNMplzo+VoRCRCH/+XCA84rt3Y= X-Received: by 2002:a2e:84d0:: with SMTP id q16mr17395927ljh.138.1582153938706; Wed, 19 Feb 2020 15:12:18 -0800 (PST) MIME-Version: 1.0 References: <20200218172552.215077-1-brianvv@google.com> In-Reply-To: From: Alexei Starovoitov Date: Wed, 19 Feb 2020 15:12:06 -0800 Message-ID: Subject: Re: [PATCH v2 bpf] bpf: Do not grab the bucket spinlock by default on htab batch ops To: Yonghong Song Cc: Brian Vazquez , Brian Vazquez , Alexei Starovoitov , Daniel Borkmann , "David S . Miller" , LKML , Network Development , bpf 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 Tue, Feb 18, 2020 at 1:23 PM Yonghong Song wrote: > > > > On 2/18/20 9:25 AM, Brian Vazquez wrote: > > Grabbing the spinlock for every bucket even if it's empty, was causing > > significant perfomance cost when traversing htab maps that have only a > > few entries. This patch addresses the issue by checking first the > > bucket_cnt, if the bucket has some entries then we go and grab the > > spinlock and proceed with the batching. > > > > Tested with a htab of size 50K and different value of populated entries. > > > > Before: > > Benchmark Time(ns) CPU(ns) > > --------------------------------------------- > > BM_DumpHashMap/1 2759655 2752033 > > BM_DumpHashMap/10 2933722 2930825 > > BM_DumpHashMap/200 3171680 3170265 > > BM_DumpHashMap/500 3639607 3635511 > > BM_DumpHashMap/1000 4369008 4364981 > > BM_DumpHashMap/5k 11171919 11134028 > > BM_DumpHashMap/20k 69150080 69033496 > > BM_DumpHashMap/39k 190501036 190226162 > > > > After: > > Benchmark Time(ns) CPU(ns) > > --------------------------------------------- > > BM_DumpHashMap/1 202707 200109 > > BM_DumpHashMap/10 213441 210569 > > BM_DumpHashMap/200 478641 472350 > > BM_DumpHashMap/500 980061 967102 > > BM_DumpHashMap/1000 1863835 1839575 > > BM_DumpHashMap/5k 8961836 8902540 > > BM_DumpHashMap/20k 69761497 69322756 > > BM_DumpHashMap/39k 187437830 186551111 > > > > Fixes: 057996380a42 ("bpf: Add batch ops to all htab bpf map") > > Cc: Yonghong Song > > Signed-off-by: Brian Vazquez > > Thanks for the fix. > Acked-by: Yonghong Song Applied. Thanks