Received: by 2002:ab2:2997:0:b0:1ec:cbc4:63fb with SMTP id n23csp468973lqb; Thu, 29 Feb 2024 06:22:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUgqjrHF7t1XXfaFyDMZB/qf0DfqYhf3NzIHwNbjw3oBot9dmm4EggQydCo7XR8jefwpuGSMe/2Drm3WWtvs+mR0+cC8vNFEfTPQ9YUeQ== X-Google-Smtp-Source: AGHT+IF8OLn3RKpazEn1ba4vZj0tH9G//vNBWpuURD7/DLBzEzwlTnKfprEqUEEFKOHxfE0DrWGA X-Received: by 2002:a17:906:af8a:b0:a3e:e04c:457 with SMTP id mj10-20020a170906af8a00b00a3ee04c0457mr1461958ejb.19.1709216546155; Thu, 29 Feb 2024 06:22:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709216546; cv=pass; d=google.com; s=arc-20160816; b=cvgF4ikDpiq/owl+WarIrsrfWRaG17qxkeXKVZpB9/tr+lpegdvO5ZiTuYsyaQJPoS +ktuDJTAsf6WDGHXjdlgHt2RgPWJFXRqpMgp8TrYdRD8fpFCU4Y4GkSWBix1v1jsGZWE 8hCXv7n0giES421X/Tf+7Yegkv0abflWZ0cJA/wK6s8JHk7nyTJbrhhirY0V41h/xGe7 QbXgIQhZ9CccnfDfg/9IyP7biK1zXUTSk9NqlOZXqAzjbvwWc9Sscgga/hxtYdjS9UsC hU5drvCuHutDUG3uKsv+6/BL7kEvzjRwt1HAwHCxMi7eVil10Z+me8WUYo2PSxRf1wEj /jww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=I7QQf86WBSLlT/8W/ge7tfKbRHIzhxvhjanWb4LCZ2Q=; fh=lhq+1X1UjpnfdX6J6Py3AJedTIiiSTBmmtQFb70aICY=; b=g5jlXT7QbHFhzZS1IDYQ9DZ+41m2pHR7yOn6X/Yhy4UCSnx1MIKgkOPim0NxIh+J5Z hYNd9qpgWHHaJG9rXOOj0TJcNHGsKakbZKf+n2/v3cDc9vhjaf/K9cOZawLnTuLJKOhJ +lTha7Rfe2GB2XyOOaRsmLhKOArSPwk1jWxzB9wUtY0UnD80NaJ+MkakxBpo7kwcBZFM hYiDD+XVT/9Weiw88S8XJRA0nyoEt2LBj1LvlZ1ACn4bdTZUNM6P2v4RiEp3isOJeby+ aZXPvpuIO/9seRpgJ8n03c/1aZqfriaGHsVj/dkOZstVWqmttx99xAFUvscDruMLuiCf NEOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=TbyqMLjB; arc=pass (i=1 spf=pass spfdomain=joelfernandes.org dkim=pass dkdomain=joelfernandes.org); spf=pass (google.com: domain of linux-kernel+bounces-86826-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86826-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a22-20020a17090640d600b00a4420ff1365si633673ejk.390.2024.02.29.06.22.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 06:22:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86826-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=TbyqMLjB; arc=pass (i=1 spf=pass spfdomain=joelfernandes.org dkim=pass dkdomain=joelfernandes.org); spf=pass (google.com: domain of linux-kernel+bounces-86826-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86826-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B8F121F224F3 for ; Thu, 29 Feb 2024 14:22:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD79213667B; Thu, 29 Feb 2024 14:21:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="TbyqMLjB" Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 484767D060 for ; Thu, 29 Feb 2024 14:21:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709216514; cv=none; b=BMNrBcvY7yz1wBoKeOEZHXfRvhNcOkNjz0NGcSrGppwW8WhNxXlzWU4ExtmIWt+RVRE6KqAAfNuqFVCNRQ6MWfjlKgOrogqclz4b3qhpl3CcTakghogKdjMCtzFFkVoDLpEQEi/a1b1ARLQ2lp7TD+rlg+jsUxgp4PG8jEbzSzA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709216514; c=relaxed/simple; bh=s9koWyBOH5kffAk/ctMX8vICzTEVqUgQIoSQO1DAJ1g=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=nvyRRvTzAN/q0770C9QYCU+dtlF8bGgxuEZ+Zcew4vezrthijL1IZSPCU3J+WJPVEKVgfj42s1cAPacholLEuBHpm7aBbHXGTIePWQmOILM6Q5MilZe6/RiKZbVMsgH4FKBdkTa6kPIVDEWSuEq5ZLaNkzuObEbMo6ldOuSiWz0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org; spf=pass smtp.mailfrom=joelfernandes.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b=TbyqMLjB; arc=none smtp.client-ip=209.85.166.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=joelfernandes.org Received: by mail-io1-f53.google.com with SMTP id ca18e2360f4ac-7c810b04bc0so26790039f.2 for ; Thu, 29 Feb 2024 06:21:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1709216512; x=1709821312; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=I7QQf86WBSLlT/8W/ge7tfKbRHIzhxvhjanWb4LCZ2Q=; b=TbyqMLjBGFbW1XYlgjVchNT8LUCoGp061bxAeusS9ycHO17B69pk9QuQEIqVi7WC0X Dop1CM197ycc7ib2kiUp7R8DuZcUDT67qc9LprKNzsVz4XpwfpGKFb6wEWqwgX9MTTJq gDwqVGEzpcbftbs9iqIUAPuH8dbaOtFXJrE84= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709216512; x=1709821312; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=I7QQf86WBSLlT/8W/ge7tfKbRHIzhxvhjanWb4LCZ2Q=; b=KPkR/PnawkqTvAQ4ES9EXJm4wJQ5/zMQevRt+lWJkUWB4qXBwKe9lTen7uHs5u8EF0 zFAk4OgVA8VRJHAh7K5PtDMUrOmuzIPUcvWUzzX+FZ7b7WlouqOnr8QQScbzE9g+OKqR /ugFT4/N+GDw793QmGzgZJeeohpjNIkylDAjOm7d0wAmdvfNllnYSa03j7P7wmNGyiHS emkGtMjrQJfoxhAiTsvY6/oxKtnWX5FTDckvUVf/kFzkq12TvXJovbCiXe41zhEuOpho aWtf6xSR0M3+tl71wv8mSigrbGg4fcXRoFKltLcCqNFwECd0b4R5pn/wo+EXutR6lnBI z2rA== X-Forwarded-Encrypted: i=1; AJvYcCUYcgKwVW2stc61V5Qs07TEOvvgVnCwzsa7srES0VfvygM0NwmIZcyU+iYY1wx1yMDHY/J6wFjpnJY05mxLSXX/P0PXH9AN2m3e9X7R X-Gm-Message-State: AOJu0Yw0R8Gp2VIFoVe+QOPdA+7ueGRgPhKLXSQNTsYrXLoshevkvlG1 PLFw7LciDABNFDw8qK8NZIZKgg0bP5bjNJufNS5UqzMZNHtZbNDcJBGYVWvKwew= X-Received: by 2002:a05:6602:3b97:b0:7c7:9c58:c970 with SMTP id dm23-20020a0566023b9700b007c79c58c970mr2398006iob.4.1709216512347; Thu, 29 Feb 2024 06:21:52 -0800 (PST) Received: from [10.5.0.2] ([91.196.69.76]) by smtp.gmail.com with ESMTPSA id a14-20020a5d9ece000000b007c8197e8473sm86044ioe.5.2024.02.29.06.21.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Feb 2024 06:21:51 -0800 (PST) Message-ID: <888d2f90-6d2f-4d4f-a9f6-fbf2f2611821@joelfernandes.org> Date: Thu, 29 Feb 2024 09:21:48 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] net: raise RCU qs after each threaded NAPI poll Content-Language: en-US To: paulmck@kernel.org, Alexei Starovoitov Cc: Steven Rostedt , Yan Zhai , Eric Dumazet , Network Development , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Simon Horman , Daniel Borkmann , Lorenzo Bianconi , Coco Li , Wei Wang , Alexander Duyck , Hannes Frederic Sowa , LKML , rcu@vger.kernel.org, bpf , kernel-team , Mark Rutland References: <02913b40-7b74-48b3-b15d-53133afd3ba6@paulmck-laptop> <3D27EFEF-0452-4555-8277-9159486B41BF@joelfernandes.org> <20240228173307.529d11ee@gandalf.local.home> <8ae889cb-ee1d-4c72-9414-e21258118ce3@paulmck-laptop> From: Joel Fernandes In-Reply-To: <8ae889cb-ee1d-4c72-9414-e21258118ce3@paulmck-laptop> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 2/28/2024 5:58 PM, Paul E. McKenney wrote: > On Wed, Feb 28, 2024 at 02:48:44PM -0800, Alexei Starovoitov wrote: >> On Wed, Feb 28, 2024 at 2:31 PM Steven Rostedt wrote: >>> >>> On Wed, 28 Feb 2024 14:19:11 -0800 >>> "Paul E. McKenney" wrote: >>> >>>>>> >>>>>> Well, to your initial point, cond_resched() does eventually invoke >>>>>> preempt_schedule_common(), so you are quite correct that as far as >>>>>> Tasks RCU is concerned, cond_resched() is not a quiescent state. >>>>> >>>>> Thanks for confirming. :-) >>>> >>>> However, given that the current Tasks RCU use cases wait for trampolines >>>> to be evacuated, Tasks RCU could make the choice that cond_resched() >>>> be a quiescent state, for example, by adjusting rcu_all_qs() and >>>> .rcu_urgent_qs accordingly. >>>> >>>> But this seems less pressing given the chance that cond_resched() might >>>> go away in favor of lazy preemption. >>> >>> Although cond_resched() is technically a "preemption point" and not truly a >>> voluntary schedule, I would be happy to state that it's not allowed to be >>> called from trampolines, or their callbacks. Now the question is, does BPF >>> programs ever call cond_resched()? I don't think they do. >>> >>> [ Added Alexei ] >> >> I'm a bit lost in this thread :) >> Just answering the above question. >> bpf progs never call cond_resched() directly. >> But there are sleepable (aka faultable) bpf progs that >> can call some helper or kfunc that may call cond_resched() >> in some path. >> sleepable bpf progs are protected by rcu_tasks_trace. >> That's a very different one vs rcu_tasks. > > Suppose that the various cond_resched() invocations scattered throughout > the kernel acted as RCU Tasks quiescent states, so that as soon as a > given task executed a cond_resched(), synchronize_rcu_tasks() might > return or call_rcu_tasks() might invoke its callback. > > Would that cause BPF any trouble? > > My guess is "no", because it looks like BPF is using RCU Tasks (as you > say, as opposed to RCU Tasks Trace) only to wait for execution to leave a > trampoline. But I trust you much more than I trust myself on this topic! But it uses RCU Tasks Trace as well (for sleepable bpf programs), not just Tasks? Looks like that's what Alexei said above as well, and I confirmed it in bpf/trampoline.c /* The trampoline without fexit and fmod_ret progs doesn't call original * function and doesn't use percpu_ref. * Use call_rcu_tasks_trace() to wait for sleepable progs to finish. * Then use call_rcu_tasks() to wait for the rest of trampoline asm * and normal progs. */ call_rcu_tasks_trace(&im->rcu, __bpf_tramp_image_put_rcu_tasks); The code comment says it uses both. Thanks, - Joel