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 X-Spam-Level: X-Spam-Status: No, score=-3.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3046DC61CE8 for ; Sat, 19 Jan 2019 18:07:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E48752087E for ; Sat, 19 Jan 2019 18:07:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="rG2IRbsd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728898AbfASSHN (ORCPT ); Sat, 19 Jan 2019 13:07:13 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:33141 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726724AbfASSHN (ORCPT ); Sat, 19 Jan 2019 13:07:13 -0500 Received: by mail-qt1-f193.google.com with SMTP id l11so18898281qtp.0 for ; Sat, 19 Jan 2019 10:07:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sEUiHsbZsUUgFZ7nZoXgUalqTZXJeuVtl3HQh5/pkpI=; b=rG2IRbsdY5Mj/cOod7FyVX9oCufqhgcopkN9czFI1RXi8wH3tZTNWFN0GM7JvptaVv VAxeusnKWyH0YwRmg9wSZPMY2/UB95RS8wE2XnTDNeondwLTgi0Q9sjpYMypK+uymm6B nwTYaON4mBwAf5SXBF1p0yIOuC78OvxIs7/SE02BO8xcoBhbLnhusMcjDbeP4Pv/rr4f fGZQ+WiauX5BQFIhInLxFf7Y/1gmjRPvY4ZedKEm9O5w0EScRM0cILo41XvlZUnY11c7 DEsnDXXDUuPHT41GnX3/Mob1hYVMMDdZfQaSF9Wwmly+5xat0xcNr/cHILFqhXbT9Vcx NkLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sEUiHsbZsUUgFZ7nZoXgUalqTZXJeuVtl3HQh5/pkpI=; b=iFNNlyQMKRqheKmuFWLHCAFIuo/27KW4dz4RBbBWZBTjOv0W7SFchrYOL/INv2QtSN 55MeiEQe8C/tjf46oXv6VxUQR8+WwnWj49PZ6qvYTJXtYOJnKaI1jCkr6xVoTH5DlQK3 Nx5lCQgYMR876tYk42bG9Mwdn/4cBv9P9AozkZNoCBcj+0mZfNCht8wjPwaqUKi/QKEo Gk+iqRDGEsjod6z4mWicnE7fClrENIEK3eAX/d70yzAlJ+i2amjVWMUGOzO+o5s864ob aJsMhR9ECXG9ZfFCWUIYdfsm19IFQI5YmALYcJMMIX4oKn+avl5iiaVsZcI1K9Qtyhx5 zQYw== X-Gm-Message-State: AJcUukf93u6WhEbVQcs/AsolHghBfy3QQLn34VFadTnrkNDDjeMvc6/w Ft+C+HqRzyyBjSDNiJEMwrtqAA== X-Google-Smtp-Source: ALg8bN6cyM1hHWz01PlQRLR4VwdQPp1dMrw8xwMCi/tAqb9R+vlqKSjBs9W7t5lBy3IBSAlbB0k/pg== X-Received: by 2002:ac8:6b8a:: with SMTP id z10mr20597975qts.248.1547921232213; Sat, 19 Jan 2019 10:07:12 -0800 (PST) Received: from jkicinski-Precision-T1700.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id v2sm46521518qte.75.2019.01.19.10.07.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Jan 2019 10:07:11 -0800 (PST) From: Jakub Kicinski To: alexei.starovoitov@gmail.com, daniel@iogearbox.net Cc: netdev@vger.kernel.org, oss-drivers@netronome.com, yhs@fb.com, Jakub Kicinski Subject: [PATCH bpf-next v4 00/12] bpf: dead code elimination Date: Sat, 19 Jan 2019 10:06:44 -0800 Message-Id: <20190119180656.24635-1-jakub.kicinski@netronome.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi! This set adds support for complete removal of dead code. Patch 3 contains all the code removal logic, patches 2 and 4 additionally optimize branches around and to dead code. Patches 6 and 7 allow offload JITs to take advantage of the optimization. After a few small clean ups (8, 9, 10) nfp support is added (11, 12). Removing code directly in the verifier makes it easy to adjust the relevant metadata (line info, subprogram info). JITs for code store constrained architectures would have hard time performing such adjustments at JIT level. Removing subprograms or line info is very hard once BPF core finished the verification. For user space to perform dead code removal it would have to perform the execution simulation/analysis similar to what the verifier does. v3: - fix uninitilized var warning in GCC 6 (buildbot). v4: - simplify the linfo-keeping logic (Yonghong). Instead of trying to figure out that we are removing first instruction of a subprogram, just always keep last dead line info, if first live instruction doesn't have one. Jakub Kicinski (12): bpf: change parameters of call/branch offset adjustment bpf: verifier: hard wire branches to dead code bpf: verifier: remove dead code bpf: verifier: remove unconditional branches by 0 selftests: bpf: add tests for dead code removal bpf: verifier: record original instruction index bpf: notify offload JITs about optimizations nfp: bpf: don't use instruction number for jump target nfp: bpf: split up the skip flag nfp: bpf: save original program length nfp: bpf: support optimizing dead branches nfp: bpf: support removing dead code drivers/net/ethernet/netronome/nfp/bpf/jit.c | 42 +- drivers/net/ethernet/netronome/nfp/bpf/main.h | 33 +- .../net/ethernet/netronome/nfp/bpf/offload.c | 9 +- .../net/ethernet/netronome/nfp/bpf/verifier.c | 74 +++- include/linux/bpf.h | 7 + include/linux/bpf_verifier.h | 6 + include/linux/filter.h | 1 + kernel/bpf/core.c | 52 ++- kernel/bpf/offload.c | 35 ++ kernel/bpf/verifier.c | 250 ++++++++++- tools/testing/selftests/bpf/test_btf.c | 396 +++++++++++++++++- tools/testing/selftests/bpf/test_verifier.c | 160 +++++++ 12 files changed, 998 insertions(+), 67 deletions(-) -- 2.19.2