Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp1808018rwp; Thu, 13 Jul 2023 17:31:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlH5LdlhVuyep1sYT/8ZHIrB3Bb7IIZVxWqgXsyQOOFcUO2p7wBHTeFEx9BfI88UsGr2grqc X-Received: by 2002:a17:906:c30e:b0:994:1978:9993 with SMTP id s14-20020a170906c30e00b0099419789993mr2491530ejz.17.1689294690361; Thu, 13 Jul 2023 17:31:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689294690; cv=none; d=google.com; s=arc-20160816; b=lOJc6/zB8smtKpNwN/Z8NfwHJRt6a4yroRF99tHzLp9Ms0jEHGL3uAjIPj0NMQzEIB kaQaDXRAKrCTnlHCIsqNcS+kRqjvcxBdmlkpbgRzNslIha2S7Hsgsxf4+Yp7LNsbt/u7 CooUsvv4x9g/0v5nLAzHZzcT7jeZjYo2AVg4e9B8nwVJwR+JtWn6e/91SfTgyEU9VHsG ypqC6+rCT0LR+2q1w9c52QWK4Z0APOJt2A+d+gW3PKFvMjQWwecAepeadIcGpgI0gkt/ RX5NVAip1EfesgjMWy+VPIJnoVcXTXScJ6IIr1QLA55eGWjuTmmChZqZwx19OY+KvLS8 HA6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BoriMCQh3dIag72cEJBFwbbsdk2p8pRWSnIKSZD1tr8=; fh=ftBFEEmf8ehmceJKRK/6Az8a9qJDULwIGXKPVozCOdg=; b=Xy6XNuqNnxI20yGgZnvjJqp0dVpYIT9ZbyjBUZLoC1DKdm0tV4csmAfqvHrysnAl6I ItiVXWVHSd+aDoc9hFqv8U07vUS5r+J8AjTseWs1G2IuWIAVnWSEpbF3h86+R2ivI0bP GxJynzk77R3oPcUP6tpWcM5doeIw+JGGHDRKUBwVTshFlDYaLjZBwzrcUAkwOQQCPE81 +gj/fWROKraXpsbSCXMWxZ76bILPUWDxu5k1LXo87TLFJ/t7AUCVjAMRi/bpIwcEtn57 aQbVyc2jQs2X9bA+EcX95BKHSjrRcwgLBsNyy8S28yaHhTR2qlZSwQJUPaj2JhzVSTKc +DQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=VEFm2Lt7; 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 i7-20020a1709064ec700b0098282dca7dcsi8402080ejv.519.2023.07.13.17.31.05; Thu, 13 Jul 2023 17:31:30 -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=20221208 header.b=VEFm2Lt7; 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 S233976AbjGMXRr (ORCPT + 99 others); Thu, 13 Jul 2023 19:17:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232467AbjGMXRo (ORCPT ); Thu, 13 Jul 2023 19:17:44 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFBFF171D; Thu, 13 Jul 2023 16:17:43 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1b9cd6a0051so8103025ad.1; Thu, 13 Jul 2023 16:17:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689290263; x=1691882263; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=BoriMCQh3dIag72cEJBFwbbsdk2p8pRWSnIKSZD1tr8=; b=VEFm2Lt71ugLRnwVFVQdTs0aWUB0AEYBc22YdK7fhIzPH5dwo3jSK23dnghF2D9nkL d//iwTcUajuJL4+oDNQdQGpKS1PrCWFBqfzGC8ARPrVYek4QRnPc6uGpGOq+SL6tdWAz u8d8dMqI67aNdfVTyOM5h2cr7qUpnPToEFa/jRmyH3yO9xtVprhlT1VmZWN8wsK/GcQ5 GvadWEGkR/z5SbRoOM581xoZSJlP+5uN37tEHakuZq4I9rgNiWI7OPovpd8Qg7FmzRLj GN57DsqE8y6X+bb4sVWWfSx8UYFLFj4p4Qt8b+dtFGUZQmjYLxaW4CrefUUQ1TDotulE oI1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689290263; x=1691882263; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=BoriMCQh3dIag72cEJBFwbbsdk2p8pRWSnIKSZD1tr8=; b=T4SfnZwxKaCAf6400XQp9I9Atr6NvJphRfVuiORmu1SKlKQCYmzmvD0lKfGVTTh9E7 ck9CYoB1+5ey2Eq7C4gHLJZ9+wIq4i7RWbK4EFxLs4eunJCGYgCBO34H7IkL76xmWbXn aTVMGfH5SPZ1OJFMSwbTfPq7foVCZQUiNm7qVEA7Pn1f0TUY6b4qcW2xPBA/hJ9XaPLm hpZ00HBGlpSXKvzehpGz1YvmByqxJiChwfY364s6vmD1QGsb8p86qZRiY4ZxlxFzQclY YvWJdQeJniWThmhq5mQaqDhMemhl2+6wCIrNt52zLiU4voiYnZZGS9rpd48O2iNRqGZO oP0A== X-Gm-Message-State: ABy/qLbmxb/B5n9W8XLt0XbRinQcYVCVWHyHTrbc4UaLdkS1DGTK/3Aw plmudSQUTFclRivMJwuKyRw= X-Received: by 2002:a17:902:d4cd:b0:1b8:21f:bcc2 with SMTP id o13-20020a170902d4cd00b001b8021fbcc2mr2732602plg.34.1689290263162; Thu, 13 Jul 2023 16:17:43 -0700 (PDT) Received: from MacBook-Pro-8.local ([2620:10d:c090:400::5:2ff4]) by smtp.gmail.com with ESMTPSA id g4-20020a170902c38400b001b9be79729csm6443195plg.165.2023.07.13.16.17.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 16:17:42 -0700 (PDT) Date: Thu, 13 Jul 2023 16:17:39 -0700 From: Alexei Starovoitov To: "GONG, Ruiqi" Cc: Yonghong Song , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Wang Weiyang , Xiu Jianfeng , gongruiqi1@huawei.com Subject: Re: [PATCH] bpf: Add support of skipping the current object for bpf_iter progs Message-ID: <20230713231739.n3vtl4x36ezbovfl@MacBook-Pro-8.local> References: <20230713051323.2867905-1-gongruiqi@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230713051323.2867905-1-gongruiqi@huaweicloud.com> 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,T_SCC_BODY_TEXT_LINE 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, Jul 13, 2023 at 01:13:23PM +0800, GONG, Ruiqi wrote: > bpf_seq_read() can accept three different types of seq_ops->show()'s > return value: > > err > 0: skip the obj and reuse seq_num > err < 0: abort the whole iter process > err == 0 (implicitly): continue > > but bpf_iter_run_prog() is limited to the last two cases. Extend the > legal return value of bpf_iter progs so that they can skip certain > objects and then proceed to the followings. > > Signed-off-by: GONG, Ruiqi > --- > kernel/bpf/bpf_iter.c | 9 +++++---- > kernel/bpf/verifier.c | 1 + > 2 files changed, 6 insertions(+), 4 deletions(-) > > diff --git a/kernel/bpf/bpf_iter.c b/kernel/bpf/bpf_iter.c > index 96856f130cbf..1c1d67ec466c 100644 > --- a/kernel/bpf/bpf_iter.c > +++ b/kernel/bpf/bpf_iter.c > @@ -716,13 +716,14 @@ int bpf_iter_run_prog(struct bpf_prog *prog, void *ctx) > rcu_read_unlock(); > } > > - /* bpf program can only return 0 or 1: > - * 0 : okay > - * 1 : retry the same object > + /* bpf program can return: > + * 0 : has shown the object, go next > + * 1 : has skipped the object, go next > + * -1 : encountered error and should terminate > * The bpf_iter_run_prog() return value > * will be seq_ops->show() return value. > */ > - return ret == 0 ? 0 : -EAGAIN; > + return ret == 0 ? 0 : (ret == 1 ? 1 : -EAGAIN); This breaks existing progs as you can see in CI and you surely would have noticed if you run the selftests. We're going to start auto rejecting patches without selftests and those that break CI. It's your job to test your patches.