Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1180840pxb; Wed, 6 Apr 2022 10:38:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxE5VeBpnA/kw+3omHzyoIr+AHB61j90NEEUivvQxEwkN4hDFhx29xmJGFAtZjfjBiJQsFD X-Received: by 2002:a63:b40a:0:b0:35e:d274:5f54 with SMTP id s10-20020a63b40a000000b0035ed2745f54mr7758926pgf.200.1649266711419; Wed, 06 Apr 2022 10:38:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649266711; cv=none; d=google.com; s=arc-20160816; b=cUcJthw5/crgiXhSoTQXjLYSiWUXCGIVFKnmDBoOdbgY+J+z7QdjWujSABZOXbWDGb 0KrF5W3cNeVMWcOQ/+8UM7jmj+fb5RZrBW48tes+W4eukQtir5zJV3UFyTdGvXstvyvk C7/a5jqvKScMeCQdY2YdfiYlXplaVdFV3bhfWVaiGVKqXQtUWejkR/JZzOJhxeGQDgLi E3TQxYN0SDbsJKXcKEczU24HPh4qHNRyRnq0n/5DcHah2e+pN6N2J5pjzioWvVjL39HA 6aKUumAaPjkp6DgCQeJN75txqeFkXpGcqvfRW81dHfOjRRLN4szlIKln7o1zY50GXyfe Bl0Q== 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=QmolHhmWUDeuA6W93lL3cPQ5QCEiH3d+VGJZLdfEzsg=; b=V6CrR1Fu1EkjbzyzpB678frx53gASVc+m9IeEJCyxh9WAKt9J/d47R+i+pMrQ2Ggao hOp3EbLKckJwcpEOsUCxhlwLwArAoz+9FROUelxaQwnyfWfNgp3isVfPvwNTAuOfevQW wSl48j/mszPWoT8fLpcJQiFofc5AmSTzuRLXj7H0dXVau2T/+4eFE+P5ts+JMCJ1RtHw w1traKBO2Pq3jOGQDjDRQfWWwIhFzImtx5ALmduzP9U9HmZSmnIGe3G8Rdlx2EAoXm6p 5C/8PoBvOQdxpZGOtHi7IVNx1UaEhYDz6fzJb4ApLG5y5qSI55SD3np0/K51lIiOTmcD qE3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q9tKaQ18; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id rj2-20020a17090b3e8200b001bedf1f3526si5789335pjb.146.2022.04.06.10.38.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 10:38:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q9tKaQ18; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C4D981DDFC6; Wed, 6 Apr 2022 10:34:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239139AbiDFRgj (ORCPT + 99 others); Wed, 6 Apr 2022 13:36:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239204AbiDFRf6 (ORCPT ); Wed, 6 Apr 2022 13:35:58 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D31692F653A for ; Wed, 6 Apr 2022 08:44:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 2B2E7CE2492 for ; Wed, 6 Apr 2022 15:44:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82425C385AD for ; Wed, 6 Apr 2022 15:44:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649259857; bh=vWK0HC0ZdB8sGlZbserDZ72jYW8Fc7a6wD4c+Cm9cEU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Q9tKaQ181ABxBjopzcekbKg07gHajXbcwu63QACqRHdX43M+cU4bZnoShL5BErCY3 Dag7krCNvzPT+GUx50eHYxdRSUPNYGhqEo0D3m/kFQRtGoPPNbIUqMYZnxYPBT4KUM sSM8KuyMVdcjT1kstSunkZEtGKk3mMctT28M774MizgpP/hfmGmg/sCt2R8gJl2seV ymXqtU26gFr6XXAXM6vsOd0pfBn1x8H1LHHxp4uSC4Y72cgmJTdKTHQyt/i8G/IOha qKGXanhgEXiLsgSrxRuz37E69s8vyWQPN4z+8W9v6FG1QYa6zpeOBVAwzriNDpUKFO m3+E4T6jaClLA== Received: by mail-ed1-f49.google.com with SMTP id x20so3104108edi.12 for ; Wed, 06 Apr 2022 08:44:17 -0700 (PDT) X-Gm-Message-State: AOAM532sEum3tqqzt3u+VtIzHW8fXAfJAtbK86FocNPoFH/3blZkQ1lN oyRB9l7ejhpW0Ji6wdXkMKkJgIhtuG2/8OGCohQaJg== X-Received: by 2002:a05:6402:f1c:b0:41b:54d2:ef1b with SMTP id i28-20020a0564020f1c00b0041b54d2ef1bmr9317277eda.185.1649259855672; Wed, 06 Apr 2022 08:44:15 -0700 (PDT) MIME-Version: 1.0 References: <20220401000642.GB4285@paulmck-ThinkPad-P17-Gen-1> <20220401130114.GC4285@paulmck-ThinkPad-P17-Gen-1> <20220401152037.GD4285@paulmck-ThinkPad-P17-Gen-1> <20220401152814.GA2841044@paulmck-ThinkPad-P17-Gen-1> <20220401154837.GA2842076@paulmck-ThinkPad-P17-Gen-1> <7a90a9b5-df13-6824-32d1-931f19c96cba@quicinc.com> <20220405203818.qsi7j74jpsex7oky@kafai-mbp.dhcp.thefacebook.com> In-Reply-To: <20220405203818.qsi7j74jpsex7oky@kafai-mbp.dhcp.thefacebook.com> From: KP Singh Date: Wed, 6 Apr 2022 17:44:05 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [BUG] rcu-tasks : should take care of sparse cpu masks To: Martin KaFai Lau Cc: Neeraj Upadhyay , paulmck@kernel.org, Eric Dumazet , LKML , Stanislav Fomichev , andrii@kernel.org, ast@kernel.org, bpf Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Tue, Apr 5, 2022 at 10:38 PM Martin KaFai Lau wrote: > > On Tue, Apr 05, 2022 at 02:04:34AM +0200, KP Singh wrote: > > > >>> Either way, how frequently is call_rcu_tasks_trace() being invoked in > > > >>> your setup? If it is being invoked frequently, increasing delays would > > > >>> allow multiple call_rcu_tasks_trace() instances to be served by a single > > > >>> tasklist scan. > > > >>> > > > >>>> Given that, I do not think bpf_sk_storage_free() can/should use > > > >>>> call_rcu_tasks_trace(), > > > >>>> we probably will have to fix this soon (or revert from our kernels) > > > >>> > > > >>> Well, you are in luck!!! This commit added call_rcu_tasks_trace() to > > > >>> bpf_selem_unlink_storage_nolock(), which is invoked in a loop by > > > >>> bpf_sk_storage_free(): > > > >>> > > > >>> 0fe4b381a59e ("bpf: Allow bpf_local_storage to be used by sleepable programs") > > > >>> > > > >>> This commit was authored by KP Singh, who I am adding on CC. Or I would > > > >>> have, except that you beat me to it. Good show!!! ;-) > > > > Hello :) > > > > Martin, if this ends up being an issue we might have to go with the > > initial proposed approach > > of marking local storage maps explicitly as sleepable so that not all > > maps are forced to be > > synchronized via trace RCU. > > > > We can make the verifier reject loading programs that try to use > > non-sleepable local storage > > maps in sleepable programs. > > > > Do you think this is a feasible approach we can take or do you have > > other suggestions? > bpf_sk_storage_free() does not need to use call_rcu_tasks_trace(). > The same should go for the bpf_{task,inode}_storage_free(). > The sk at this point is being destroyed. No bpf prog (sleepable or not) > can have a hold on this sk. The only storage reader left is from > bpf_local_storage_map_free() which is under rcu_read_lock(), > so a 'kfree_rcu(selem, rcu)' is enough. > A few lines below in bpf_sk_storage_free(), 'kfree_rcu(sk_storage, rcu)' > is currently used instead of call_rcu_tasks_trace() for the same reason. > > KP, if the above makes sense, can you make a patch for it? > The bpf_local_storage_map_free() code path also does not need > call_rcu_tasks_trace(), so may as well change it together. > The bpf_*_storage_delete() helper and the map_{delete,update}_elem() > syscall still require the call_rcu_tasks_trace(). Thanks, I will send a patch.