Received: by 2002:a05:6500:1ca:b0:1ef:b27b:cc29 with SMTP id c10csp1242129lqn; Fri, 15 Mar 2024 12:55:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVl8GXXGyJVUxuU8ox2CLTIOrF34lxwXYZlKd2lXgvIykI3n8CXaJQ+BBY3xfkaCi+MSfxvlSLhVcw8c+M9GbftSHro7EL0wCHcTXvU0Q== X-Google-Smtp-Source: AGHT+IFNpn79wE9CLkUYSj+bnRpX+Gps+u2J4FLlIUy/UygPqxmpeu8DVLToFzD5pKmll1CJ8J3g X-Received: by 2002:a17:906:b783:b0:a46:6fb2:34e1 with SMTP id dt3-20020a170906b78300b00a466fb234e1mr2044694ejb.52.1710532522247; Fri, 15 Mar 2024 12:55:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710532522; cv=pass; d=google.com; s=arc-20160816; b=NXfOeOtXPDn6G4KJkMSbQohAxISzwOOg8bIPfKDelsSG/3M2vqPwCK3JssWUE9BN8r V6PA+uc3pPbC9vti9kR32q4bgBOT7T/GeyQsJ0/cvejoTv3RjYETonuwqLdI8eGtBMjT ojnpX8NGsEm4BOrpHrREvRZoxMEsUySh0/ivuvfk+lW9PuwoXJpiGV98vBug3V3pkcES ZXKqWHvSMz5e2NZ0bd6tfrxyUPZ6HAmfTa2TK8c4S1BEtJRs/kHq/lKSj3Xki/5Hu9Vc ipgWerZycObbsAD5+AUnApqQ+xx2AXk2kju1jB8RQp8QowYD/IjNrv+5V+SSd3S35PPj MoUQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=hFCxDEQwJlvWrjzvbkqgNENtA83xO4o1dn3KyfRTRKA=; fh=ffaBIf05cObdMoyESL/mQfBN8u9eTk9clbINEXkEmIo=; b=y3/RUYyE0eOx8degcjnjTHWPWAeoUForW+DBWQUlsB6ktyBnQzkI8T0hX3sEJg+dFw wGYj+2Rc0YjSOhMtkrlnYpxVSvmTpmuy6/GKu0jYau1KEZaUs84xVCItalna5EsK067k aaN5EJOXTAYtDF0whIn4abfTdZjEf7kt4dZ9CO//vjwLLbx01UVhAJx1xJQ3HrkqgqwQ 4FRFy0yz2xzYpPRvjSU4PcXilxxuZ5gZ6+bflz2tls8YanVAvTw2xTfWwULPQ3LZQxC0 jN+RzE4hPVB166olM2J9F5L3yxuEGORta2OSqm5oX2nrzic5SrI89pk+Ek2/AIKML6F9 IbKA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=ZRc8at8i; 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-104861-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104861-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 m22-20020a17090607d600b00a4439b5c147si1952887ejc.530.2024.03.15.12.55.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 12:55:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104861-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=ZRc8at8i; 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-104861-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104861-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 F1BAB1F234BF for ; Fri, 15 Mar 2024 19:55:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C5C8535DC; Fri, 15 Mar 2024 19:55:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="ZRc8at8i" Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (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 8D2DE40BE6 for ; Fri, 15 Mar 2024 19:55:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710532507; cv=none; b=erg7xrN6gG09F1aJGaJs4x0jXv/cfPf5FNbWc20kuGLSYyhcUfgQEaYvXg8LruNOwknH4Fbutw14TfK1TxDh7wbh2Li85WTQD0te77YibbKcAsTlJ91PYvabLAiHPwd+2/FbXPYSTf45ZbbYpTU7xnjHI3HJ37+YhFx/t74mXWw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710532507; c=relaxed/simple; bh=CZwUyc/DMM0Uny3U5TTGXkC9yXTk8fyaov4ApURGlJU=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=AAshb341oxwmwAEIsMdNbpsk/4eW4gAb2HwOwZDwqaWWXUWLNS8VS7xv8Hh344UFMeKxn3gYdmwsOCHrQtH7+YpBNBvDlS8Bxebi0k8gxthXSnidsxX71q5GyYEnGbamySCVOLqU+DSHE2BM/EIvEwoYLRzxSPNs8XzDIJraWSk= 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=ZRc8at8i; arc=none smtp.client-ip=209.85.222.171 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-qk1-f171.google.com with SMTP id af79cd13be357-7882dd2b1c9so206649085a.1 for ; Fri, 15 Mar 2024 12:55:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1710532503; x=1711137303; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=hFCxDEQwJlvWrjzvbkqgNENtA83xO4o1dn3KyfRTRKA=; b=ZRc8at8iONxvknmBCFFyHlu9gFSFLwBb453B9kYYGuRULPGhJLb37TucWku2c10dKs hYOcYEnMKNGmKutNCt3x2hGlVlLo+cF/Ub+77ZN61SK1EsVO8qySOu5uFv1RwrqMAmi6 Di+lcr7tZdfpwR9qxa+bznu3bm4sRwLEJoVj1ARHfsZXbpHw9qDp8vopNJy7iAQeXn2t OZq5n9oNy05qJz5prXOz+5b4gxmrwnLatar7jkcJ8l3KsgwurtQ8vWhDT2B8AWbbCbdw sgS0M5tXyGkpxcTk4y2KUfEK2duQNKKaZpah0wD/nOFtU9acliHcH+SmbszcNxtbf/Gl AB0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710532503; x=1711137303; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hFCxDEQwJlvWrjzvbkqgNENtA83xO4o1dn3KyfRTRKA=; b=hOCR5/wEPcBYyNtUOKmBY7dnN5WL/+5SGUICO2BzzzL3kPk5pHdLmQpcmIU8G467kD IpdzVgaU94YJ+zJyzD7kdnN8Os1d5HLnGsjWY6IZUiOJnpPi1bj7HhWFF5A8PKWTKw1T iYmucLMtEyM2EFYYj0NYq6KWdfXKnPzLPDBr9DXGm0O72hiKWCco75dFJ+Ft+SVhjn7q Rb2clJHtsX0+ILleec5Wt8ZIqcu97uZIfDjaAzGB7YgepD+r+CSB9VrFSZZdj0YuKOox rGfk3xWz0Rt6i0fy3jUAs02rmLQd5+5LHyLdn5FZXssUef2id1zpqVAPTTGG0FNfFrhY Mu6g== X-Forwarded-Encrypted: i=1; AJvYcCXCbFy6AMKgVqE8HSx4dsmID/h9c+5hmExMM8omYYYVLiixhdH4g/Fj5kAU5EtEuAocbGQyfqKV1TOk2PyxZttMxuprh57yTRygFz8j X-Gm-Message-State: AOJu0Yz50ahzus6EQhyzoP+DxFwXZXtLR1DVH943kOQXr8dXN2jB/Y0c V0eqSvWo1EN+N0dwx8PXLpzaXDzaKokQhZ0P2ERPRuTJVyj3ec8vsu5Gn1BH1ho= X-Received: by 2002:a05:620a:158f:b0:788:49fd:a3de with SMTP id d15-20020a05620a158f00b0078849fda3demr8820691qkk.16.1710532503509; Fri, 15 Mar 2024 12:55:03 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:1046::19f:c]) by smtp.gmail.com with ESMTPSA id d7-20020a05620a136700b0078863e0f829sm1405472qkl.12.2024.03.15.12.55.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 12:55:03 -0700 (PDT) Date: Fri, 15 Mar 2024 12:55:00 -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 0/3] Report RCU QS for busy network kthreads Message-ID: 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 This changeset fixes a common problem for busy networking kthreads. These threads, e.g. NAPI threads, typically will do: * polling a batch of packets * if there are more work, call cond_resched to allow scheduling * continue to poll more packets when rx queue is not empty We observed this being a problem in production, since it can block RCU tasks from making progress under heavy load. Investigation indicates that just calling cond_resched is insufficient for RCU tasks to reach quiescent states. This at least affects NAPI threads, napi_busy_loop, and also cpumap kthread for now. By reporting RCU QSes in these kthreads periodically before cond_resched, the blocked RCU waiters can correctly progress. Instead of just reporting QS for RCU tasks, these code share the same concern as noted in the commit d28139c4e967 ("rcu: Apply RCU-bh QSes to RCU-sched and RCU-preempt when safe"). So report a consolidated QS for safety. It is worth noting that, although this problem is reproducible in napi_busy_loop, it only shows up when setting the polling interval to as high as 2ms, which is far larger than recommended 50us-100us in the documentation. So napi_busy_loop is left untouched. V3: https://lore.kernel.org/lkml/20240314145459.7b3aedf1@kernel.org/t/ V2: https://lore.kernel.org/bpf/ZeFPz4D121TgvCje@debian.debian/ V1: https://lore.kernel.org/lkml/Zd4DXTyCf17lcTfq@debian.debian/#t changes since v3: * fixed kernel-doc errors changes since v2: * created a helper in rcu header to abstract the behavior * fixed cpumap kthread in addition changes since v1: * disable preemption first as Paul McKenney suggested Yan Zhai (3): rcu: add a helper to report consolidated flavor QS net: report RCU QS on threaded NAPI repolling bpf: report RCU QS in cpumap kthread include/linux/rcupdate.h | 24 ++++++++++++++++++++++++ kernel/bpf/cpumap.c | 3 +++ net/core/dev.c | 3 +++ 3 files changed, 30 insertions(+) -- 2.30.2