Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5204748pxv; Tue, 6 Jul 2021 20:54:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwASPXuUpTlzypYUrya1txFjWaAhnJZqr08z7fd3xArN7LqVYhllvxEJZJA+mlXZZjtpClC X-Received: by 2002:a02:b388:: with SMTP id p8mr19564619jan.88.1625630095955; Tue, 06 Jul 2021 20:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625630095; cv=none; d=google.com; s=arc-20160816; b=S1/KGfb1UcOoSsCCq7+U+ZqLoevdvcUnrVwnh0VMdzxc2r5cWONOlBcaRz82jbTQjS 7rCoOKcG/61rFw3rJe5t757gdHd6C5jkXYoGQgyE2hh3WFqP5k5tsx/vI/iv5zAuIhRC d3lbaH75TpE31yfRydf9wO81gnq3Ubyfj7spAooniRqLc1THGOxftgfDDITSuOybeBCL QPpT0WFcVSqYJQijRQ6xLcloEM+FLl6dugCN2yIk+T/lSAuYLYKoYiLtFIjp9p5BgttR cVLks2hYsjZDv7Gt++1ezfYVXuvXYVj59l8p1Qpit+LpeKiLmf1lgX+rHSKtAX4XVAxh 1dNw== 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; bh=773uqnZzkm5bxApIIg1YLIp1gx1M3PVlJNou8zcu/iQ=; b=u2JYsSfaw3f9p3+xswIf9yANah+ZRUB3kYkHSZticLhcS8/a781F+sew7DTihyhcUx EDuNJPCF+WKgr8aockrcmYeZQ1L6mWidex3xss7ZO9swE5yuIoc4ZMZnuc3dwIn3dCT4 ugkigRO2oYwwPXNpj/NCf/qtD2+g4PqRJ/qNf1SUKhODBzx3rjRnRszhBcNYek+v5KdO nqZ32ArWziEDb/TbyrInfbYMq98oC120k+MRMkvvflvjCSZ6SoLW5MDa0UO2sPc2ak9Y 72NqkuCyAILJkfKwPp0ZVvxAITD79gcEYT0bzBNEVOXd4K9+7HVFq09vTxIYCMP4m/yJ qVpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a7si22093833iod.38.2021.07.06.20.54.44; Tue, 06 Jul 2021 20:54:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230141AbhGGDzb (ORCPT + 99 others); Tue, 6 Jul 2021 23:55:31 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:10322 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230037AbhGGDzb (ORCPT ); Tue, 6 Jul 2021 23:55:31 -0400 Received: from dggeme751-chm.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4GKQPm6cHZz76m8; Wed, 7 Jul 2021 11:48:28 +0800 (CST) Received: from k03.huawei.com (10.67.174.111) by dggeme751-chm.china.huawei.com (10.3.19.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 7 Jul 2021 11:52:49 +0800 From: He Fengqing To: , , , , , , , CC: , , , , Subject: [bpf-next 1/3] bpf: Move bpf_prog_clone_free into filter.h file Date: Wed, 7 Jul 2021 04:38:09 +0000 Message-ID: <20210707043811.5349-2-hefengqing@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210707043811.5349-1-hefengqing@huawei.com> References: <20210707043811.5349-1-hefengqing@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.174.111] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggeme751-chm.china.huawei.com (10.3.19.97) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move bpf_prog_clone_free function into filter.h, so we can use it in other file. Signed-off-by: He Fengqing --- include/linux/filter.h | 15 +++++++++++++++ kernel/bpf/core.c | 20 +------------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/include/linux/filter.h b/include/linux/filter.h index 472f97074da0..f39e008a377d 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -884,6 +884,21 @@ struct bpf_prog *bpf_prog_realloc(struct bpf_prog *fp_old, unsigned int size, gfp_t gfp_extra_flags); void __bpf_prog_free(struct bpf_prog *fp); +static inline void bpf_prog_clone_free(struct bpf_prog *fp) +{ + /* aux was stolen by the other clone, so we cannot free + * it from this path! It will be freed eventually by the + * other program on release. + * + * At this point, we don't need a deferred release since + * clone is guaranteed to not be locked. + */ + fp->aux = NULL; + fp->stats = NULL; + fp->active = NULL; + __bpf_prog_free(fp); +} + static inline void bpf_prog_unlock_free(struct bpf_prog *fp) { __bpf_prog_free(fp); diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 034ad93a1ad7..49b0311f48c1 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -238,10 +238,7 @@ struct bpf_prog *bpf_prog_realloc(struct bpf_prog *fp_old, unsigned int size, /* We keep fp->aux from fp_old around in the new * reallocated structure. */ - fp_old->aux = NULL; - fp_old->stats = NULL; - fp_old->active = NULL; - __bpf_prog_free(fp_old); + bpf_prog_clone_free(fp_old); } return fp; @@ -1102,21 +1099,6 @@ static struct bpf_prog *bpf_prog_clone_create(struct bpf_prog *fp_other, return fp; } -static void bpf_prog_clone_free(struct bpf_prog *fp) -{ - /* aux was stolen by the other clone, so we cannot free - * it from this path! It will be freed eventually by the - * other program on release. - * - * At this point, we don't need a deferred release since - * clone is guaranteed to not be locked. - */ - fp->aux = NULL; - fp->stats = NULL; - fp->active = NULL; - __bpf_prog_free(fp); -} - void bpf_jit_prog_release_other(struct bpf_prog *fp, struct bpf_prog *fp_other) { /* We have to repoint aux->prog to self, as we don't -- 2.25.1