Received: by 2002:a05:6500:1ca:b0:1ef:b27b:cc29 with SMTP id c10csp1242685lqn; Fri, 15 Mar 2024 12:56:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVKYTm1/ngtIL7ZTWzY7apCecU9EA/zQWdKEA6JSdersye+3L5dYySt1n6fCZG0We4F072UnORjdXRBWeBrh5MHfJ51BwLNSf5ATDs2cQ== X-Google-Smtp-Source: AGHT+IEDsROQS1Wu4mPCFxhp2akrhhvWlYvreBIpqz8ODK4N9+u2xXrJ8h9ork401NvLO2ze+SMt X-Received: by 2002:a17:906:f918:b0:a46:6dcf:3f3d with SMTP id lc24-20020a170906f91800b00a466dcf3f3dmr3968142ejb.73.1710532590546; Fri, 15 Mar 2024 12:56:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710532590; cv=pass; d=google.com; s=arc-20160816; b=umkt0sg/sFb5p6PH+V9JoWAE63YdxmeZtL6j0WZYZ0O0jy+ZqrwLEKSUnGSCkrm4+3 xC8BPxwoTKQA11+49uoflapeiQJdZzYka/wvgGFWdgq89sIPXqS8wa2UXnYuS7GQmDQ4 KSxJg70kAgCiss2qLxlfEV+fG7NHW4EhZZJbg6ToxuqA8tpo/hwUVmGM21FVSFu5UT0y xAUB6b+6OKpH1YPDT8bNEimaDxAvIr1o57PS3XgDJdBuwIQDmCx7DdTqzrt0fd8dQcMc kqC7j1x3Gt9G7OWTbtGL6lUZ58ua/Gviea1iJ4/TGbbL8em/P5hd3yFBjdi0VooWyeM/ m+bA== 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=Zg3vyQOcvPtiphP1OG7zM1hj29JDQei2S3fuY6oN0u0=; b=onBcU9L2/MmHtr9oGKtFWcDC7LEcQPggMt/T+DWhdn0EPp4b+6rAWJyaknTw0pCJ4m 6+PsCboLHT1EmFhkRXgG+hQx4e7whWqih4JXCpIbwH++PSDUhZMjXt2LRAOo+1GQ9DgJ axabKg4bTG5tVkXYyxM+NwKwOHQKQk2a+YxGk195RideQq4XA+IV5CKIXCnm8m+FGwgO rsZBSYJEg7GyY+Fh2mSbmSbfDiEfLBI5lFuqHbLnTPXSLEXSizHJFragmLyoHF6A772v EhCre2ncBvq/CCF9CwiHVgqdbfSjXNWbyy3Qr1TY7cEZuro5QSsnazNSgOJKrcFyViV4 cAeg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=B8iM9QDV; 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-104864-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104864-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ne9-20020a1709077b8900b00a4670167b36si2137857ejc.722.2024.03.15.12.56.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 12:56:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104864-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=@cloudflare.com header.s=google09082023 header.b=B8iM9QDV; 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-104864-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104864-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4B60C1F23323 for ; Fri, 15 Mar 2024 19:56:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A0E04CB2E; Fri, 15 Mar 2024 19:55:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="B8iM9QDV" Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) (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 7FF0D54902 for ; Fri, 15 Mar 2024 19:55:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710532517; cv=none; b=aT+SpUUos0o8XoAe0Qax7aRdFEig1xQA47iDRwkrZePhsWdnZ/xXRba0FGOIga8MrJRc9hm7JQPt+GdmKDW5Y7h0sbYyvc14VtiUJ3JiMNd6RjULtz0YGSlvPzwX0XJKXEUVWdpnntS2B4mXaDYf6rB6YC/veDvtgrMQszGv7Zs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710532517; 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=GuntBKWnjrqzQNqh/+URQbC5TSe+2PDgtx6qgGAMJx7GTZDH7DEMnrrAdUzSFSMuD9apfbMG6swiPCgw2DkGcKI5p1uKm9UG9DEjgOwID9HSQhtDGhkMpcUULkC7WGoMi5Yg9k9FM3XM7cjoQCZS7zviL1aaAHjGDZw6pmfgRPE= 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=B8iM9QDV; arc=none smtp.client-ip=209.85.219.173 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-yb1-f173.google.com with SMTP id 3f1490d57ef6-dcbd1d4904dso2489893276.3 for ; Fri, 15 Mar 2024 12:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1710532512; x=1711137312; 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=B8iM9QDVZLZoUQZ8+NLabWS5GVaGI8Isyl0UZeZNi6c7bxWMDdD9oOzjKm+InlbPtd nLtyh/PmJjVYabW8/ArekKixTswp0SJY9jxQLAy4uANQmBoi4FNZ1kEf5v58iLn+lflE cvSy0WnZRUsVqeCOG8yHqRq/VircQ3NdY/VOZD652Ya6yioJSClcndMz7Dx9NliOLBoB Uxa3CffXk6RcH7qLIVVsFtAeZ80I8beZvtT1jSBwmrg8C3oATJ0UfNWGDuf0HloYEFBq 7jlSpRAKasi40HOg/8QIJWkHFfbcSgJ3PWlIFSYEk+rSGMjFBxHTM8sjYzkGwID1e5oG xIOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710532512; x=1711137312; 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=puBq/7Os1w9mPXaVeFW6VcdvDZxSdv7XBbCm483BtVqU//AkcwqUGMIECivCCdRxP4 ETuH3HBX5zFI2ppztkuCcJtwWMtyhWHuR3Dw7PfQ9XXU9EcsF8UgoQJLkVm7LGiaBvBQ 6Pv8PK97ZFh8EbIb/z2YmU+VnT7SjWSlVeDsTJPCE24fNoR7ZGBh9p/dtPoeoaqG0guq 2I+uNG/YqO25Ss05SIv0CfmWcCFAnc1FavxiaBF7yFIkPBYzfhMqqIL1XDsnO8RFZX8W smOh7OvIet7dB/CWBbh0anMI2pgSbGhKtP+kRO1NK00B8R+2lpo61dzcta2g32DaBh8N GSoQ== X-Forwarded-Encrypted: i=1; AJvYcCWNVwq9QqdmkrHRx0k683pY6aUAfFIkXnrPIpSlkcsXzgS4EhSHoKbztnlvdl+f4YJrGCGyJMp5sUUDJVKmcCzCmnd6EegNVBds25oF X-Gm-Message-State: AOJu0Yyy7ALSJ1gWypOvcwqq0PULTXY1j6RDvjkb+PEnyMQmJkv8NDwe 4Yj0QeKhyAzMPMFtAeYYRD7loTtfdfJFvtvf+5M8OUlmp4BTgwKFUNA9pItFCwbxD6kM17LcINq /dFY= X-Received: by 2002:a25:ea43:0:b0:dc6:ff12:1a21 with SMTP id o3-20020a25ea43000000b00dc6ff121a21mr5517436ybe.31.1710532512300; Fri, 15 Mar 2024 12:55:12 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:1046::19f:c]) by smtp.gmail.com with ESMTPSA id j6-20020ac86646000000b0042e2002ed12sm2251399qtp.57.2024.03.15.12.55.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 12:55:11 -0700 (PDT) Date: Fri, 15 Mar 2024 12:55:09 -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 v4 net 3/3] bpf: report RCU QS in cpumap kthread Message-ID: 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