Message ID | 20230326092208.13613-5-laoar.shao@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp840360vqo; Sun, 26 Mar 2023 02:23:45 -0700 (PDT) X-Google-Smtp-Source: AKy350Y9hUsruUvV2VHz1UTgcnRFgkP79bQN8v2WkFSC6sjNuCrob5QzSQsJAdppgh9N/7gCFzOA X-Received: by 2002:a17:906:175a:b0:92c:8e4a:1a42 with SMTP id d26-20020a170906175a00b0092c8e4a1a42mr9304512eje.32.1679822625236; Sun, 26 Mar 2023 02:23:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679822625; cv=none; d=google.com; s=arc-20160816; b=G1Ro7j+SdCtKwm1X97RW2T8EnJ42vLheMSV56QdthkU5rG4A5qpGLfeZoyhkI9h4Pj RvT3wWVg+BBz1n2Qo3PYs7//G+O6ck2MWLYw6y4hNYZblzW2oH5DLEUodV7jnAIUrqGU jHNACDrMJ5BcjC0zCm0PVtwtqWSuBX/PhCZxYNBPx27duThGuClybWxSlfvkp1vJATij E+88kK6N8g/zdZSb1kfzQoLWog12T1XzuzUTfricMVMwUA5Af5fMDQz0n04jxVaqIgaH NonDmabmnvUX0qeBE3D4cq6HFA3JLtkv3rhKahBEjCM7NmpuQeSXaSEpmQ9TW/rTF+JZ zYwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=I1Zf6mBo0BAcs/anjiNOAvLM/6WnwvWROkn3ev6fwzU=; b=t6NwS1Qlmfs3uQ3HZ1RWQFNuvj2dSw/SIKSfDGke96tl+HF+E39eF8ofyQet+WU9b+ 1NCh1PLH8RI9JKojIK7bHNDA2DCYdH01iXuTtjRMvBIaGvjk7RNprYs0lxsAo0m6zW3p KTkKIe58Md2SOnZ1R7P4lvlgGsk9IAtV6jVaoiHxRTV5B9bOtFMF1kMiYwmUuwlh+3Sx CE2m3HI9qnkY/bKe6DCRXOaBSqWJjQYWi3K0MhqGPsuuZ6AGezRWZK1NdfkWlyNMCRBp QES1MULbFXBSFimPasqHkJLU9SaSRHcB6p66/BEst1nEK+LlMhohlLE7FDrspJlPoF+c WYlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Xny1OUgl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g23-20020aa7c597000000b004fe95a8ef89si26762705edq.392.2023.03.26.02.23.22; Sun, 26 Mar 2023 02:23:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Xny1OUgl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231856AbjCZJWe (ORCPT <rfc822;makky5685@gmail.com> + 99 others); Sun, 26 Mar 2023 05:22:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231817AbjCZJWW (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 26 Mar 2023 05:22:22 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7793B5BB1; Sun, 26 Mar 2023 02:22:21 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id a5so5875433qto.6; Sun, 26 Mar 2023 02:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679822540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I1Zf6mBo0BAcs/anjiNOAvLM/6WnwvWROkn3ev6fwzU=; b=Xny1OUglEPhpvieEbLz2cvRjjAo5MlD0Obh5seAAppIv9GfutRhWTPb3tufsXZ53HN Yx7a1Uc79EAcYyoN4mTwOOzN5+508MyW09h2B5uau8cRtgZvtFz6pBpdIKBgUjjRPQo8 9ylDg4S6pkddVF/NEvDaFoPvAFiDK29IqcMvXyMmWp0xTMQoeUKLayA/YbQ/juEry+Rl O5MRw7j66yPLjPeHE2IbpwWAl9HiPQbjd5ZFTBH9aVR2d6i3TouSRE+peWBap7JP2GYX RpgoHp2Q6M2cYXQgnekplpEh/isWECLBxnXZUhXeJkfYtWDZ3XqSG5Xulh9KpfZi3JUz 9XjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679822540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I1Zf6mBo0BAcs/anjiNOAvLM/6WnwvWROkn3ev6fwzU=; b=ppFgc9aXn54xsrG/aN8/ZQ8QWSyg8spoIHiCrz4XeHCgDR3Rvj7UQEUyE9TL2rU40Q IH9cF6o7aVBA7d1uBdH7BhzquaMzjjjT9E4EU+nbiHZtF9USyOBbSE4F7/KOgCXvSAvi V1yukz/xEzxaNhur2qKw4IdmWxC/t4SVy+BOf3MCF/gq6FSB6SBnn2c89KNS7TBKCBB/ ecGA3DtOuG8WMsJQG349Iq+KYj0S15yp6hzn0bkcd44rxwkMN3MgSkhQR1HaOre90lI5 9azKfrhhrEyRoFFQ+LATtKeon1cRmE0Bq8o+/Tvu4u6Y32KVIKbCLl1WvG3Zz8Y6FSYH e2jQ== X-Gm-Message-State: AO0yUKVyXjH1iKMfrYlk1WVyJSH5hdIlfQ6PErL/S2GY8VPwhJPf+unh Px26eupC66UZtagFIHWOlmU= X-Received: by 2002:ac8:5c16:0:b0:3df:50ef:fafa with SMTP id i22-20020ac85c16000000b003df50effafamr14597478qti.4.1679822540545; Sun, 26 Mar 2023 02:22:20 -0700 (PDT) Received: from vultr.guest ([2001:19f0:1000:1a1f:5400:4ff:fe5e:1d32]) by smtp.gmail.com with ESMTPSA id y5-20020ac87085000000b003e014845d9esm10257987qto.74.2023.03.26.02.22.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Mar 2023 02:22:20 -0700 (PDT) From: Yafang Shao <laoar.shao@gmail.com> To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao <laoar.shao@gmail.com> Subject: [RFC PATCH bpf-next 04/13] bpf: No need to check if id is 0 Date: Sun, 26 Mar 2023 09:21:59 +0000 Message-Id: <20230326092208.13613-5-laoar.shao@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230326092208.13613-1-laoar.shao@gmail.com> References: <20230326092208.13613-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761421689025889653?= X-GMAIL-MSGID: =?utf-8?q?1761421689025889653?= |
Series |
bpf: Introduce BPF namespace
|
|
Commit Message
Yafang Shao
March 26, 2023, 9:21 a.m. UTC
idr_alloc_cyclic() will return -ENOSPC if there's no available IDs, so
don't need to check if the id is less than the start number.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
kernel/bpf/syscall.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index e18ac7f..f3664f2 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -387,9 +387,6 @@ static int bpf_map_alloc_id(struct bpf_map *map) spin_unlock_bh(&map_idr_lock); idr_preload_end(); - if (WARN_ON_ONCE(!id)) - return -ENOSPC; - return id > 0 ? 0 : id; } @@ -2032,10 +2029,6 @@ static int bpf_prog_alloc_id(struct bpf_prog *prog) spin_unlock_bh(&prog_idr_lock); idr_preload_end(); - /* id is in [1, INT_MAX) */ - if (WARN_ON_ONCE(!id)) - return -ENOSPC; - return id > 0 ? 0 : id; }