Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5304272pxv; Wed, 7 Jul 2021 00:06:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw++4qV1a91+jctTUV5S9w90mN8Eo9WyznarwnJAqXfcGwf03bfDihXEsffO56ASAVfhXtA X-Received: by 2002:a17:906:8590:: with SMTP id v16mr12721979ejx.336.1625641587457; Wed, 07 Jul 2021 00:06:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625641587; cv=none; d=google.com; s=arc-20160816; b=VWxTRFRT14WZbIk5NYCI0iz+D9ux/uea8eAg6Ejam9WOmBoxdmKEOrohnYsJ+uYbjf lJiylvY1fmkf4Gt2HO7ocvBBSwSOrft8mz3qO1TzDJVnImIS7LlA5PpBMFLdz11brewN ZOUEmMfs0NHW9pgAdmG5K2CtUdaCQp6xIzzOCRGK/pNa7X/MAKD6Cy6peq+i7zS1H4Vo Gl/hq8kqfkTAgQP3ryCFbXCBekWaDaXVDYkau67Wn3+tFv5xesNAtRf//HKlF2GRC5uy UdSqdeXftWn8jQKqgz22aRmgLRhj/lfwXyogtleLSVKU6Zfeeb1/KbwGGb4Uwan/pomo S2dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=4SIEVBdL723rgDiCcRkYWl6yF0vD7Wfn0wKvnj4vwqI=; b=d/fZwudKCHen0Um0hTLU+DRknBzhws0AQNt1oa4b6zWBbE6ndyK8ID2CokBFeYAUs8 dPB3Jb/jAjKPT4Iccr5rSgWG258KymOp7rTiWQhSTsHBeY860ugKL2V7MQJYh4Jz9SQx 9dMLsjxY078sigi/B23pYjKXOD8/dlerfhjNKMxY9aNxGbIoZHXW2NMR0NCnDKhWvynI UzvhcEXXW3Pe2HLU00TNzaHsvgn0JCowA+ol+HdZ0k5xXFOu9BR1ujzTcyoVH8f5pqXM RKTFxfQq6/C+FT+yHR9sGD/toIEuIOjYr17fkuV0izvYM6axw8FeAHnZYqOJ+pElueVk 38lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Opw0/Qnf"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co20si6195319edb.324.2021.07.07.00.06.04; Wed, 07 Jul 2021 00:06:27 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Opw0/Qnf"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230374AbhGGHFp (ORCPT + 99 others); Wed, 7 Jul 2021 03:05:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:44400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230312AbhGGHFo (ORCPT ); Wed, 7 Jul 2021 03:05:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CEBB461C82; Wed, 7 Jul 2021 07:03:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625641384; bh=7tAg32fZBNuoC3CL6Ig9nwQmfyHrXRZJzl9msb7tNXU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Opw0/Qnf0maQx5i0xrXCvxYz4iruyv0anc2s2/Yi8j2FibTvuZd72eSwqyzlwgv5c 3uvuNYklFsC/cmGR1ir7xHpgCugutKIj7FOFYu+/ocnEdRJfZutXprzzgG6Tvk6nQa 628ybg+RSg1CRj4bOIujhUob5TVhHdMYUDkr9fjB9KjywTHzkLf4YUjF//nNNZLwP2 hQuoSkeAUvTIVPfWtR7WCrvG5luMiDhE54qyFiHCviLOnq/ZvfATTc0/P3WEc3I6IB /LL4EF/hv4Qc5ESJpS0USl3BU++e31Q8EzUfzeEvgOycU7EwguC8XsmRHEGjvf4QJZ jE7zrpcBTUkkw== Received: by mail-lf1-f52.google.com with SMTP id f30so2318795lfj.1; Wed, 07 Jul 2021 00:03:04 -0700 (PDT) X-Gm-Message-State: AOAM5300V/ChYahK3dtqfz/IxOoI9WDhjuUoLTLpDa+VtpSQWWTAfL+3 GLUSE7D0NM8B6PbH1Rbu6oOilo/5FXzUzOC8Fpc= X-Received: by 2002:ac2:42cb:: with SMTP id n11mr14678250lfl.160.1625641383121; Wed, 07 Jul 2021 00:03:03 -0700 (PDT) MIME-Version: 1.0 References: <20210707043811.5349-1-hefengqing@huawei.com> <20210707043811.5349-2-hefengqing@huawei.com> In-Reply-To: <20210707043811.5349-2-hefengqing@huawei.com> From: Song Liu Date: Wed, 7 Jul 2021 00:02:52 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [bpf-next 1/3] bpf: Move bpf_prog_clone_free into filter.h file To: He Fengqing Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "David S . Miller" , Jakub Kicinski , Networking , bpf , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 6, 2021 at 8:53 PM He Fengqing wrote: > > 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. > */ After the change, we can remove the comment above. > - fp_old->aux = NULL; > - fp_old->stats = NULL; > - fp_old->active = NULL; > - __bpf_prog_free(fp_old); > + bpf_prog_clone_free(fp_old); Please add a couple sentences in the commit log about this chanage. Thanks, Song