From patchwork Fri Mar 18 04:55:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 12784880 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EE1CC433F5 for ; Fri, 18 Mar 2022 04:56:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232425AbiCRE6E (ORCPT ); Fri, 18 Mar 2022 00:58:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232424AbiCRE6D (ORCPT ); Fri, 18 Mar 2022 00:58:03 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91FE5268C03 for ; Thu, 17 Mar 2022 21:56:45 -0700 (PDT) Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 22I14mZR024714 for ; Thu, 17 Mar 2022 21:56:45 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=facebook; bh=o93ZB+i8GjIQrJaHPc8kE5LG4gGapbhEHIBxDpKsMKU=; b=rOvp5g3DCF+I57tAicd5wXiEDhoT9ltnMKk+CW0S31+zlfDYCbYgTxjPkktdn/9LmgTG ZuEGIGi7uRsPtMVd8ggoXvX7FzzTy1kSWybdCqPli6utfH/6d3KuJ4G+ScUSK+MwYuBb X1OZfFMv1WXTOm9KdpgTcxEnbMiv+dR86LI= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3evg3kgt37-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 17 Mar 2022 21:56:45 -0700 Received: from twshared5730.23.frc3.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::e) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 17 Mar 2022 21:56:43 -0700 Received: by devbig010.atn6.facebook.com (Postfix, from userid 115148) id 9C5659C8E634; Thu, 17 Mar 2022 21:56:35 -0700 (PDT) From: Joanne Koong To: CC: , , , , , , , , Joanne Koong Subject: [PATCH bpf-next v3 0/2] Enable non-atomic allocations in local storage Date: Thu, 17 Mar 2022 21:55:51 -0700 Message-ID: <20220318045553.3091807-1-joannekoong@fb.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: xkiPTAmwHXxxhMViTkDYM6wguKAr4-q6 X-Proofpoint-ORIG-GUID: xkiPTAmwHXxxhMViTkDYM6wguKAr4-q6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-18_05,2022-03-15_01,2022-02-23_01 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: Joanne Koong Currently, local storage memory can only be allocated atomically (GFP_ATOMIC). This restriction is too strict for sleepable bpf programs. In this patchset, sleepable programs can allocate memory in local storage using GFP_KERNEL, while non-sleepable programs always default to GFP_ATOMIC. v3 <- v2: * Add extra case to local_storage.c selftest to test associating multiple elements with the local storage, which triggers a GFP_KERNEL allocation in local_storage_update(). * Cast gfp_t to __s32 in verifier to fix the sparse warnings v2 <- v1: * Allocate the memory before/after the raw_spin_lock_irqsave, depending on the gfp flags * Rename mem_flags to gfp_flags * Reword the comment "*mem_flags* is set by the bpf verifier" to "*gfp_flags* is a hidden argument provided by the verifier" * Add a sentence to the commit message about existing local storage selftests covering both the GFP_ATOMIC and GFP_KERNEL paths in bpf_local_storage_update. Joanne Koong (2): bpf: Enable non-atomic allocations in local storage selftests/bpf: Test for associating multiple elements with the local storage include/linux/bpf_local_storage.h | 7 ++- kernel/bpf/bpf_inode_storage.c | 9 +-- kernel/bpf/bpf_local_storage.c | 58 ++++++++++++------- kernel/bpf/bpf_task_storage.c | 10 ++-- kernel/bpf/verifier.c | 20 +++++++ net/core/bpf_sk_storage.c | 21 ++++--- .../selftests/bpf/progs/local_storage.c | 19 ++++++ 7 files changed, 103 insertions(+), 41 deletions(-)