From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 613DAC4332F for ; Thu, 17 Nov 2022 02:10:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A309D6B0072; Wed, 16 Nov 2022 21:10:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9DFAD8E0001; Wed, 16 Nov 2022 21:10:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A71E6B0074; Wed, 16 Nov 2022 21:10:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 7A5696B0072 for ; Wed, 16 Nov 2022 21:10:37 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3BBA614055E for ; Thu, 17 Nov 2022 02:10:37 +0000 (UTC) X-FDA: 80141305314.16.E502B89 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) by imf22.hostedemail.com (Postfix) with ESMTP id D04F9C000B for ; Thu, 17 Nov 2022 02:10:36 +0000 (UTC) Received: by mail-ed1-f54.google.com with SMTP id s12so562800edd.5 for ; Wed, 16 Nov 2022 18:10:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=lKnBO6So9impXfpSbxyKIhxd4m9bOycIy3EvQ3SnKPk=; b=Wrhjlk62iCtO7UsdZi/wo/EV0n8pYX/cPcJFLfzlfINkD6fD+swsB4T1WfKYKKDN7m OL0VnOWwnlYkYp6KyySe/4/6RHTq5PhzgDpvaWv8uzN8y0qsK6rStL6w0irYNjPlXS4M 0JOhQSY9yDHZuwveSC5fu4RRPmXMXOpF6KQCsYOS1Sqj8P6tfNUUc+UxMl9BiC3Wxg1g s0zNtZhP8Lns9PgnHWKRIC0iu9UADTFi/zerm/fFu8q7LSTcTmeqw7Z5T6eehScDygXF 1dCF7aPCmctU4aTsx922TLvLsUvHA8E7wHCYH8bXLd6GwPO9FoNFTcXZw8zLVdi5YzMC sh+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lKnBO6So9impXfpSbxyKIhxd4m9bOycIy3EvQ3SnKPk=; b=XFOe4mcOLYVaT7GlxXjEFhpkqzniz+NQf69OcC/ZW9Yxq3vYBDjst6cUy38RCWqRm3 Ov7Yl2hXLdBZHWCmPITY5owFQjGe8E+4ZQVcuZA/r/KtP/R/StVEbySTUyGkAiNlVCpD OBjc8ipTObugrN38Tb5WzSG+qsQVEzuiHYRiQaUxemlEi8ZdtNJ4lC683urNaJVgcUfJ FP79QjdGHnAMPWcfJbTc/xIjkDjKxDpyeZK4d96hcJ2+6mKEKOJhqPp+0muERitgz7YM 59aF4us+2rtmXYCUkSJmg3ItOils4lE3uz1e+w2L14e406SpqOA7Oj8SOtCHOau/d2Eo 41TQ== X-Gm-Message-State: ANoB5pnvmu2qpOm5vv1b7VsiFt04JOlMkKoiJMUNdVbKeV9m9e4xHS9O gQbZwC6W5HVoV4SSJEPlFdNCcg0dyXUfXIVpQR4= X-Google-Smtp-Source: AA0mqf5UeAy87zYM3LMDJcOjB6wfm+vldAPFIXzpcL3/Qtvt/0u+Vu/rUCQ4Wc4PqsQAoNMdPW+N7bg06h+wlRh0jmY= X-Received: by 2002:aa7:c2d5:0:b0:467:8fb6:d11 with SMTP id m21-20020aa7c2d5000000b004678fb60d11mr352590edp.421.1668651035314; Wed, 16 Nov 2022 18:10:35 -0800 (PST) MIME-Version: 1.0 References: <20221117010621.1891711-1-song@kernel.org> <20221117010621.1891711-5-song@kernel.org> In-Reply-To: From: Alexei Starovoitov Date: Wed, 16 Nov 2022 18:10:23 -0800 Message-ID: Subject: Re: [PATCH bpf-next v3 4/6] bpf: use execmem_alloc for bpf program and bpf dispatcher To: Luis Chamberlain Cc: Song Liu , bpf , linux-mm , Andrew Morton , X86 ML , Peter Zijlstra , Christoph Hellwig , Rick Edgecombe , aaron.lu@intel.com, Mike Rapoport Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668651036; a=rsa-sha256; cv=none; b=nT3eQjicpg96KUNAerY9XwAz0zYzgqmtav5oR/lDs/7CNkbDBwVZTkUlQeTqjcuqFhmQVh ynfDT79JsSZxR2FTYGga7B2OdRffYAKygrRjCHGwki03XYXMLhXaegz4dAkfjJ/Tv8Drus sBPI7BgtZgm5EA/Mm3U8ihaqyZd/NYM= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Wrhjlk62; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.208.54 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668651036; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lKnBO6So9impXfpSbxyKIhxd4m9bOycIy3EvQ3SnKPk=; b=tYOMVFtUyUrnr1V6srWQq2dPT8ojdKbPXNzokKC7y4spzDUdKvJ+fVTkTgOIkAZLXqHqvp yo8LV1Dba5r/9BeHhSq8PA2ObVZ97P2uKp8UNqtMyTcJ/FAfXpxZr7cac2Fwh6YHAVHKA9 hClyH07Fx+upDvCcFnjBVFHSVGtug5o= X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: D04F9C000B Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Wrhjlk62; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.208.54 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com X-Stat-Signature: 3jggrykun1ojty5e4kxdidp1kc6wwqzz X-HE-Tag: 1668651036-886287 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Nov 16, 2022 at 6:04 PM Luis Chamberlain wrote: > > On Wed, Nov 16, 2022 at 05:06:19PM -0800, Song Liu wrote: > > Use execmem_alloc, execmem_free, and execmem_fill instead of > > bpf_prog_pack_alloc, bpf_prog_pack_free, and bpf_arch_text_copy. > > > > execmem_free doesn't require extra size information. Therefore, the free > > and error handling path can be simplified. > > > > There are some tests that show the benefit of execmem_alloc. > > > > Run 100 instances of the following benchmark from bpf selftests: > > tools/testing/selftests/bpf/bench -w2 -d100 -a trig-kprobe > > which loads 7 BPF programs, and triggers one of them. > > > > Then use perf to monitor TLB related counters: > > perf stat -e iTLB-load-misses,itlb_misses.walk_completed_4k, \ > > itlb_misses.walk_completed_2m_4m -a > > > > The following results are from a qemu VM with 32 cores. > > > > Before bpf_prog_pack: > > iTLB-load-misses: 350k/s > > itlb_misses.walk_completed_4k: 90k/s > > itlb_misses.walk_completed_2m_4m: 0.1/s > > > > With bpf_prog_pack (current upstream): > > iTLB-load-misses: 220k/s > > itlb_misses.walk_completed_4k: 68k/s > > itlb_misses.walk_completed_2m_4m: 0.2/s > > > > With execmem_alloc (with this set): > > iTLB-load-misses: 185k/s > > itlb_misses.walk_completed_4k: 58k/s > > itlb_misses.walk_completed_2m_4m: 1/s > > Wonderful. > > It would be nice to have this integrated into the bpf selftest, No. Luis please stop suggesting things that don't make sense. selftest/bpf are not doing performance benchmarking. We have the 'bench' tool for that. That's what Song used and it's only running standalone and not part of any CI.