Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3347866ioa; Tue, 26 Apr 2022 01:44:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxX4fc9X44rK9TpXlOwkJC3kkqTWaI+vToNSPXpj+dJxJamdGVtPevwVk79uhMU8Dg6Bzx2 X-Received: by 2002:a17:907:1c11:b0:6f0:d63:69b3 with SMTP id nc17-20020a1709071c1100b006f00d6369b3mr20278767ejc.691.1650962676773; Tue, 26 Apr 2022 01:44:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650962676; cv=none; d=google.com; s=arc-20160816; b=tcEoYs+49aCkGorq6sJXBYIbwsX9usI1dJuyshP3zhhG8UI3/6FwtSwUddsTi7PxUb K7SF9U8TRTnWbAUn8nCxUScX7vtqhdpeujl3VmiR/6GV931lNi0X3/NdVqVpT4NOPvVb 4zBkLSMl4/3xcT/f3cpK+UQb3098qlohviy6XOPRpXTc9L6hCzIEAkoDawtxwc2vUwQU orBo7eJjw/kMbbO1XSEaaf+w7b5f8maCqFSE6ZNmw+CG+6EmKVDfR2rXTLTplkhHSctH 0ZQjxFD59g+f0VKMND5L/Mc6alGCxRdWFN6tM0cMP5wxwKs/WUvhYzK2HP4+MHMmoex2 +wrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=frgqbBmEnlLOFkP5YQ4kOPLeHQM9VGrk+Z9lDLuwteY=; b=W0IEx3nQ7/N2VszmoqVTVmWBhPSnoosGS9vfipubOlt+gtMHSuV1qZOrn0S70WsGzL qUCYyZg1OrpY+mEFV5GNxuX1RTqP1QeCf066gJkJVkFSc9Xe7Hysw2x9kiovT3QgHW4x 4b6gaVMOZFLF4k7LGnk/Mx0Z8WVhNHnxgi4JEB1Z8H4fpmiWVg8kA+IdBKP5Wor5jtM3 +DHCnNxAD5NAN3GXhtMDRhVb98OIW9oHAEZQlIbP5JX97+xekMHwiHNd9tstNmHhFPKR VeQoEVg/Z8ZOSQL4vULUwai2DpznyOVFYIKR36z9MGGJ3KyFFwhN2Clg3uXS/Yvb4yfi 2Nbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fuTPWvdI; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s26-20020a056402037a00b00425f2e1051asi2773449edw.69.2022.04.26.01.44.12; Tue, 26 Apr 2022 01:44:36 -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=fuTPWvdI; 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 S244058AbiDZEih (ORCPT + 99 others); Tue, 26 Apr 2022 00:38:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233208AbiDZEib (ORCPT ); Tue, 26 Apr 2022 00:38:31 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEDB46831A; Mon, 25 Apr 2022 21:35:24 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id c125so18122129iof.9; Mon, 25 Apr 2022 21:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=frgqbBmEnlLOFkP5YQ4kOPLeHQM9VGrk+Z9lDLuwteY=; b=fuTPWvdIbbSrrzCFmPB61LaqlpMmWCsBW+Cf6tVztqhkjWbmHtHWh4YGNFpvI0KN34 wMYjp2l8kUJocGct62qVYItbLFTQu8I6nPuG6MX+PIhwzrjc4STlMVYVFxOzO0Iteh/A 7VmkgIM+whoQZUjfyLYLhCmPii+tQE6RyVD1nfIa/H/gTde0jvwfav5G4iB+92Jrduhi 4DqwmfTTktTwD0txUHLKIpR5GS13pXR1QtyhEgxVHiSPmsgDftVbvcu6lVYc6KMVmRtX wmuW6kId0zUTMKMZlIHYMzfa1y4qUHcqBTG8tOQ2he+DYzHQr2OD77aXkqtXIQrgugWZ VNCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=frgqbBmEnlLOFkP5YQ4kOPLeHQM9VGrk+Z9lDLuwteY=; b=v1BiyliNqx1Zmn+1nsPj+0CEzrzjhzdrRCHyErw4xcrDtMijJMKR28gs1S7krJOzij HdSpY+RbYMLp8SHOVrTlNIoswYQ9lZncW5LC8jmjQMLy78WSGPiDR3J/prKRZKk44Gvx jS6mwebKbHsMMNxBD1yUuXmM+TaGSBjT/tDZPdE8acuhZCg2X4Wx+VODMdd5VNuky7fV 5stzEzM4T2VaWBiMOBokDVzmzQXy9doFJkcq22Hz7h5oqbLlMgWFvYfdRaYNX9P+O2In R43McAzwRYDq6ysUTFP//CDil7/iX4nM8cuHxlKatPrDx1PnKXrFQpPcYQ2erIh5x0JM L1hQ== X-Gm-Message-State: AOAM530QonFaBW3JNfypgKvRzSf5R7sYrT0KBP9hxqXqjSUm1/ABBPmN jRGOhKlQeOmB+l0k3t7Z55QJiZrHz2P0nkdZOGk= X-Received: by 2002:a5d:9f4e:0:b0:652:2323:2eb8 with SMTP id u14-20020a5d9f4e000000b0065223232eb8mr8494566iot.79.1650947724372; Mon, 25 Apr 2022 21:35:24 -0700 (PDT) MIME-Version: 1.0 References: <20220421120925.330160-1-shaozhengchao@huawei.com> In-Reply-To: <20220421120925.330160-1-shaozhengchao@huawei.com> From: Andrii Nakryiko Date: Mon, 25 Apr 2022 21:35:13 -0700 Message-ID: Subject: Re: [PATCH bpf-next] samples/bpf: detach xdp prog when program exits unexpectedly in xdp_rxq_info_user To: Zhengchao Shao Cc: bpf , Networking , open list , Alexei Starovoitov , Daniel Borkmann , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , john fastabend , Andrii Nakryiko , Martin Lau , Song Liu , Yonghong Song , KP Singh , Wei Yongjun , YueHaibing Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 21, 2022 at 5:07 AM Zhengchao Shao w= rote: > > When xdp_rxq_info_user program exits unexpectedly, it doesn't detach xdp > prog of device, and other xdp prog can't be attached to the device. So > call init_exit() to detach xdp prog when program exits unexpectedly. > > Signed-off-by: Zhengchao Shao > --- > samples/bpf/xdp_rxq_info_user.c | 21 +++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) > you are introducing a new compilation warning, please fix it /data/users/andriin/linux/samples/bpf/xdp_rxq_info_user.c: In function =E2=80=98options2str=E2=80=99: /data/users/andriin/linux/samples/bpf/xdp_rxq_info_user.c:153:1: warning: control reaches end of non-void function [-Wreturn-type] 153 | } | ^ It also would be good to instead use bpf_link-based XDP attachment that would be auto-detached automatically on process crash (bpf_link_create() FTW). Please consider also converting this sample to skeleton (and then bpf_program__attach_xdp() as high-level alternative to bpf_link_create()). > diff --git a/samples/bpf/xdp_rxq_info_user.c b/samples/bpf/xdp_rxq_info_u= ser.c > index f2d90cba5164..6378007e085a 100644 > --- a/samples/bpf/xdp_rxq_info_user.c > +++ b/samples/bpf/xdp_rxq_info_user.c > @@ -18,7 +18,7 @@ static const char *__doc__ =3D " XDP RX-queue info extr= act example\n\n" > #include > #include > #include [...]