Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1838316lql; Wed, 13 Mar 2024 09:27:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+TkzALAIgpkbxKPgOVWf70kp/Wbpb0FayBwtkq38LbaDHD9cYxG6B26r8Vne6QWd57Sch9aUk70Gy0symM7EIIQodaKy1UBu0McuqDw== X-Google-Smtp-Source: AGHT+IG4ebHGK/H8EomwMPrLtEaCmPQKDIkDxTKwVPP8HvdEdKaLFuRkfM0uwvv8B+Y92EZNYH8F X-Received: by 2002:a05:6808:398d:b0:3c1:d322:5c85 with SMTP id gq13-20020a056808398d00b003c1d3225c85mr439148oib.1.1710347238704; Wed, 13 Mar 2024 09:27:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710347238; cv=pass; d=google.com; s=arc-20160816; b=KI+5XMWdmHXJjrJ7i0qQaLVMcq5q5F6bgDN7eSJE5Eyy0CT0UQEVXbAsm1lKKfjG87 PLKVPXwqq7STIjqTprODcLRdAbgio9XkAvV79FCvnW7/2/kykdx+UPSCKdF5dquLFWl0 Cd9mcghtW7M521vnt6GvlA8cT/NppBoo4PcsW0ZsM15zS1efVU3PZoGJWAUeOsCWMeAl /roYKGs7FYzn51VjrbJemHEYypR8/Ar6lY0BwdablNGq3Hfu86UbnDbBCbHsGaeHy81s vEnMqvdkLR+KUP93qR+U0JdOV5yv9NdBE+WEXWbtIC+7M3a8GKwssrHCKTNNkpw8g7rn P55g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=JuTpc8vOHdn72vm+nW+iFZ+lBgZnpQ42Xv3ej2YV4rQ=; fh=eWrcPiUOUBJ+7XumnSiKSs5K/veMizCaC8VnAo70dF8=; b=zF779Hb553QRQIzjJ8pGOGPjTG989LwLyWedmVT5oChHk46VJNMkAJ3IYR6e99Mv72 OuT4PKqw8spHi0DYDLZHrAsrF53rF9k7LmF+vCinUcfejLkP/94BN87JzOkngVVRiiCM J26Z8K4b/xxmjnqE5Dl5WVK3Wi46Gk3UWVqdhlLfCbfn4G+UiKBDDHXSSAIaKznDsevX 9M/UoezYgIIdUfOW/4Zm5pdURTS4pD4gZOGsOTMYuNM3cbjvnOuYHEKvNXDVYbE4/u2j /A9ipFem3wCexYjeOpr6SGA29LFiGg+cGvUhD2mDpJ8EwsRba2eFKPUWiSGulsuczK6O ZLFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=YveUiEzC; arc=pass (i=1 spf=pass spfdomain=cloudflare.com dkim=pass dkdomain=cloudflare.com dmarc=pass fromdomain=cloudflare.com); spf=pass (google.com: domain of linux-kernel+bounces-101730-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101730-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x9-20020a05622a000900b00430919a5460si1352940qtw.602.2024.03.13.09.27.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 09:27:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101730-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=YveUiEzC; arc=pass (i=1 spf=pass spfdomain=cloudflare.com dkim=pass dkdomain=cloudflare.com dmarc=pass fromdomain=cloudflare.com); spf=pass (google.com: domain of linux-kernel+bounces-101730-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101730-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6C4B41C21E80 for ; Wed, 13 Mar 2024 16:27:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ACDD752F8C; Wed, 13 Mar 2024 16:26:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="YveUiEzC" Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (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 5F5014F1FE for ; Wed, 13 Mar 2024 16:25:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710347160; cv=none; b=d6Q/S7zdXvNjr9zu8ZbDgusPe1W4ySUys+yKZclxPsaMkS/qw+Bse0txpGI/JEKqnupM398f6DfncDLK8NOjTzgQVWhB/WQpbdsIOnvxq+qE/cVHLpvbVURKUNQEMfk+WqkcNlz6uiu6UxIWV9rLBubKzZxK1IZfYlQqqLqjr58= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710347160; c=relaxed/simple; bh=WZXQ3n6OAHQk56baal6CzZ+snXfrxRm2xjx8a0VoWYc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FdONIzOlBhj48gE5tORHrAJ9Jou6+NswSuPnZ7dXH+Ug7lL/GWL7I9u83kGUj/ge2N6nxXyvpADYJlvbJDaqMn+Es/7gY3Kfsk16I4tGZoDS//yaOtWrNxepOBFR4RASi5jg7FUn/4FcxLGI8kNZ4LU8IuO5Q/9D5AQ2U3JJ560= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com; spf=pass smtp.mailfrom=cloudflare.com; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b=YveUiEzC; arc=none smtp.client-ip=209.85.160.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloudflare.com Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-42f37657e91so26800351cf.2 for ; Wed, 13 Mar 2024 09:25:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1710347158; x=1710951958; darn=vger.kernel.org; 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=JuTpc8vOHdn72vm+nW+iFZ+lBgZnpQ42Xv3ej2YV4rQ=; b=YveUiEzC/32H1ytCovwTz9zaPUHN1E0CPx783n6uHVYrg7GjxAUME3P0UhV1DTd6Ah 3zMTCZED8Fjuvqmq57tZma7oeF+mofWikhPkKytUA+a4s5Og6RErjr2LieFYUovauFWf AKoyQ3gh7xQ13w7nKgU/BOnF9UNTvzgh58A45IPS7AIKCE6zCtSq5askW1IljZw/xnKK 8yRqkdSl5Noc9xw8a4zyK1+jySvQuVsJV6jJuJUALn1aalzUIfP4aBeat0wXg4y2PVWh CevkxTP3UDfbhulwPsQTwX7a/cSOZnQvBmpF1A+5qIQE+C+MtNxsFh8zJnvYeszxXIQB KplA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710347158; x=1710951958; 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=JuTpc8vOHdn72vm+nW+iFZ+lBgZnpQ42Xv3ej2YV4rQ=; b=sTRbCzLYiNWSwbr8PTBha8LAwZWJFA7CVsnkr/Ob9bj1i3LlVid9wLkJcivu1u6t67 8o4B1Av1ajmrcNqq1LRg1nKQbipUl9u9foxi+hpmaJ7vEQgO5Ro1kiwGqW7dNAlejpOv 0dpXdZ+/GjqMSgWzNvkJKP8b8LQXey+bpV3+szvOZNf0BqG2Maq74uQxwaBBmmuSojTh C+zgXfXA7i0i+QGamHDFus+uvJQ58qmFHIEe93qvGAFn7utR4FyNA229i3Ek+qGRLsen Y+PDJS8pmhwemq1nIQvldQHw/itNUmgQWA6upaaX9eUO9QRdD8Ds/t1I5B8gcoWCGLED owUA== X-Forwarded-Encrypted: i=1; AJvYcCX8IGJABLFMSu+BmVeMblC4/0tQEdrZtOv7UEDxOqFVr93fgu+JIPmje7d///T9PPGXIvU87rhiST9YjGa6s9LzqAZoWj1J2u/I5gbX X-Gm-Message-State: AOJu0YwqQDF9N9LnPDlE4qwf7Um2U6kAGevjAi8dQnoSDeoXLzXfgqsR +AQ0OtfZT0nE7FDO9Q8QXgWfV1Ble27S5pnza7RVyZJCDGYGrmcm8aqGmLoEMLY= X-Received: by 2002:a05:622a:11d5:b0:430:9773:b083 with SMTP id n21-20020a05622a11d500b004309773b083mr823078qtk.19.1710347158423; Wed, 13 Mar 2024 09:25:58 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f91::18d:37]) by smtp.gmail.com with ESMTPSA id c25-20020ac853d9000000b0042f2130cd0csm4975824qtq.34.2024.03.13.09.25.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 09:25:57 -0700 (PDT) Date: Wed, 13 Mar 2024 09:25:55 -0700 From: Yan Zhai To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Simon Horman , Daniel Borkmann , Lorenzo Bianconi , Coco Li , Wei Wang , Alexander Duyck , Hannes Frederic Sowa , linux-kernel@vger.kernel.org, rcu@vger.kernel.org, bpf@vger.kernel.org, kernel-team@cloudflare.com, Joel Fernandes , "Paul E. McKenney" , Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= , Alexei Starovoitov , Steven Rostedt , mark.rutland@arm.com, Jesper Dangaard Brouer Subject: [PATCH v3 net 3/3] bpf: report RCU QS in cpumap kthread Message-ID: <3112a13efb21893b6cf285b3757877dc466c5f58.1710346410.git.yan@cloudflare.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: When there are heavy load, cpumap kernel threads can be busy polling packets from redirect queues and block out RCU tasks from reaching quiescent states. It is insufficient to just call cond_resched() in such context. Periodically raise a consolidated RCU QS before cond_resched fixes the problem. Fixes: 6710e1126934 ("bpf: introduce new bpf cpu map type BPF_MAP_TYPE_CPUMAP") Reviewed-by: Jesper Dangaard Brouer Signed-off-by: Yan Zhai --- kernel/bpf/cpumap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c index ef82ffc90cbe..8f1d390bcbde 100644 --- a/kernel/bpf/cpumap.c +++ b/kernel/bpf/cpumap.c @@ -262,6 +262,7 @@ static int cpu_map_bpf_prog_run(struct bpf_cpu_map_entry *rcpu, void **frames, static int cpu_map_kthread_run(void *data) { struct bpf_cpu_map_entry *rcpu = data; + unsigned long last_qs = jiffies; complete(&rcpu->kthread_running); set_current_state(TASK_INTERRUPTIBLE); @@ -287,10 +288,12 @@ static int cpu_map_kthread_run(void *data) if (__ptr_ring_empty(rcpu->queue)) { schedule(); sched = 1; + last_qs = jiffies; } else { __set_current_state(TASK_RUNNING); } } else { + rcu_softirq_qs_periodic(last_qs); sched = cond_resched(); } -- 2.30.2