Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp99261rdb; Mon, 14 Aug 2023 10:36:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFe07QCBfSsuomZbkDBYW8KoXNt+sG/T8Ak6E75CCFRMjKxyJhgZhGGk4eUDE9EwV/hWVwO X-Received: by 2002:a05:6a00:398e:b0:688:2253:ce07 with SMTP id fi14-20020a056a00398e00b006882253ce07mr8282544pfb.2.1692034582055; Mon, 14 Aug 2023 10:36:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692034582; cv=none; d=google.com; s=arc-20160816; b=cb15r6qwAbNqflurIN3qPnpY+oNoB6ScQVBYT2QWZQD8G82c/RXhs1nB1zI0yA2/YJ 9GHFgCyUTebHNb9KEbIWLuLvpKjup6qEuq+khobpVlUjETZgmFkVHHkI5oAk3/IdF++k gzhVbnLTQvCuVZkFsWMFE9ibx9bcB9jGKgnMjb9vaYwjTAhkLQ+MfnoBJ0PQKQVEsnsb swY0534YtG/Ig5P9dCkp4sfJtorXzACh8pt5ZLhZpWjxfAORUvvjuiclFl8683HmYIj1 JbmIOnmdOVuF/3bd+sb+FN+0ZvzofC0dcXnQz12E2lTOfg+vFH+qSMNM5bK6+zNs3UvY P2LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=klWKyCaQaMM6/yKLS6/tQBPou6nr0c7eYZv3+B1cSxE=; fh=167WG/v2gSjr9V9fesDQjJK4FjKyNSbxpIa1Xvm+JZ4=; b=wRSNK+SL4Nw5S3yG336h2Mpk9Ii9csVtcMf8xTECGx6V5tw862HzixVmKztAp06OmD sBfrH8uUvnZsY9/rIQ4cIUtBdut1CxBbuiSNoAAiBxA03IsJh8PITDYtqMrzUHaEXu2n 3LjtmtacvBcKRmolPEOxaFYoNMT0WF/6JZBkifGKCOedn3CcCT3W8BqPzmiNRan5Qtpl Ipf22OBYx8UNaIZe6VXgH6tGy7cxEclieeCEojZJgjlnmAEivayB3TaBnanDnZ3gkFUf mqG59y4ihXDtpqT8Dv8zcewKuYEaGUy0axSYkChb2ymDtisSwzVZEFstcBXqWyVgWVis obpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=QWjiaGMu; 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=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j70-20020a638049000000b0056532015a58si8270205pgd.774.2023.08.14.10.36.09; Mon, 14 Aug 2023 10:36:22 -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=@linux.dev header.s=key1 header.b=QWjiaGMu; 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=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229790AbjHNQ5H (ORCPT + 99 others); Mon, 14 Aug 2023 12:57:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232602AbjHNQ4w (ORCPT ); Mon, 14 Aug 2023 12:56:52 -0400 Received: from out-124.mta0.migadu.com (out-124.mta0.migadu.com [IPv6:2001:41d0:1004:224b::7c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C28C173F for ; Mon, 14 Aug 2023 09:56:32 -0700 (PDT) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692032144; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=klWKyCaQaMM6/yKLS6/tQBPou6nr0c7eYZv3+B1cSxE=; b=QWjiaGMuRoRj8P+8ts/4jZ9thYR/uD1ou/hGBlCgB1NyCSBREk89vBed9eHJqH2jkZoooH pZgqC6laGqD/DXD62HtBL35b51aU+uj4qlPKuvVkfqAJb2ZiQb3ETw2owrm4w/DwKb/jEc M/fT/Kfx/Pmz1b4j/ONvury1SIEUUow= Date: Mon, 14 Aug 2023 09:55:37 -0700 MIME-Version: 1.0 Subject: Re: [PATCH bpf-next] bpf: Support default .validate() and .update() behavior for struct_ops links Content-Language: en-US To: David Vernet Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, haoluo@google.com, jolsa@kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, tj@kernel.org, clm@meta.com, thinker.li@gmail.com, Stanislav Fomichev References: <20230810220456.521517-1-void@manifault.com> <20230810230141.GA529552@maniforge> <20230811201914.GD542801@maniforge> <20230811233616.GE542801@maniforge> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Martin KaFai Lau In-Reply-To: <20230811233616.GE542801@maniforge> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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 8/11/23 4:36 PM, David Vernet wrote: > I see, thanks for explaining. This is why sched_ext doesn't really work > with the BPF_F_LINK version of map update. We can't guarantee that a map > can be updated if we can't succeed in ->reg(), because we can also race > with e.g. sysrq unloading the scheduler between ->validate() and > ->reg(). In a sense, it feels like ->reg() in "updateable" struct_ops > implementations should be void, whereas in other struct_ops > implementations like scx() it has to be int *. If validate() is meant to > prevent the scenario you outlined, can you help me understand why we > still check the return value of ->reg() in bpf_struct_ops_link_create()? > Or at the very least it seems like we should WARN_ON()? ->regs() can fail if another struct_ops under the same name has already been loaded to the subsystem. If another subsystem needs another return value to support .update, I believe it can be done if that is blocking scx to support "updateable" link. >> If it needs to validate struct_ops as a while, There was a typo: as a /whole/. >> >> 1. it must be implemented in .validate instead of .reg. Otherwise, it may >> end up having an unusable map. > > Some clarity on this point (why we check ->reg() on the ->validate() > path) would help me write this comment more clearly. hmm... where does it check ->reg() on the ->validate() now? I was meaning the struct_ops supported subsystem should validate the struct_ops map in '.validate' instead of in the '.reg'. or I misunderstood the question? > >> 2. if the validation is implemented in '.reg' only, the map update behavior >> will be different between BPF_F_LINK map and the non BPF_F_LINK map. > > Ack, this is good to document regardless. > > I'll send a v3 on Monday with these comments added both to the code, and > to the commit summary. > > Thanks, > David