Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1957509ybl; Sun, 18 Aug 2019 14:51:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPq6YR7L/Kh3NBdoWr0Ez03FAq60JlUfEHNvzhyraZ2qJpE+fu7oBGCn2leQzy7vKaNCXY X-Received: by 2002:a17:902:8a93:: with SMTP id p19mr19857116plo.106.1566165072962; Sun, 18 Aug 2019 14:51:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566165072; cv=none; d=google.com; s=arc-20160816; b=08T7kmR6EYk0V9pMPNW86JKDtL1mhNYDhMqay0VJ4bt+rbyyV9FIpXswbUesquju6b a4l08vRpxiB+FX4WVZQyrOzLD3qFPfffINEmADg23PGy8XGcgb6C6YEfVRA5JhW/YIBk Mq5gRZ4iToEUyYgzuQZPLuJZl8tAbrsSdWvVWEEc5Q2PSfaBsFGdgzL0MMHfW+EqaHzD Mo1ibHBiA9qPGdrZn7zoQP0zI3dGCu6EPH8Mf4lQk6KosUE/sJJaZCRUvmIF0jnqJVBv ZnuGRMZ6pZvgj+4up9IwkiOTQoEava5Ymx42peDWHSJ9z01FTxQE0i9MsMC3Y69N/9RJ JrBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=Wg9JME0FWTs1tYyJ3nmuvph2mMJv0VgG1hoJmiI+89Y=; b=qZBl58d/CQ+GihJTGywBk1smAqltgJMdvKS5s/fhm3zbdGlN+xbtuymHbxdcOeqnJM uElVqFZqlKTkCWRpj89eXlOsl/UY+diMP/RGKz1hPnvGLGddoUCYsfMmECuBBcuOK3C3 SrwLr0Z0U6B6UNR3z4s5fYTqhAuXZ7eVW0nFbiXnJOWYac9CXp682ifNwj3HSSSXzhTi MXV7mT13hQBQLQ6MG/lUeQU8LBClfO7nqrt1/lyz6jYom0pnfOtdm7tw0+43zw1BNE6b MToQd/wWJrvyb9eO9uZfvZmOpDHIV65gPe4tEXRJL0NNgMAA6Ydu2rlXzwOiaHDnazRA 0jsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=sFx1qyWs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f95si2248985plb.146.2019.08.18.14.50.56; Sun, 18 Aug 2019 14:51:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=sFx1qyWs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726141AbfHRVuH (ORCPT + 99 others); Sun, 18 Aug 2019 17:50:07 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:39548 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726088AbfHRVuH (ORCPT ); Sun, 18 Aug 2019 17:50:07 -0400 Received: by mail-pl1-f196.google.com with SMTP id z3so4830999pln.6 for ; Sun, 18 Aug 2019 14:50:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=Wg9JME0FWTs1tYyJ3nmuvph2mMJv0VgG1hoJmiI+89Y=; b=sFx1qyWsXacdqGPc0XPcx/uSYdMTruibrn5pboJKb0GPUIVxMWLd6yd09zXGovBFEI 31vFPeXRk7jCScWKtdivUBw6ciSCob0vEGXgbXo08y2aals0woz+GXdP4HIl1/QQlsRa bzBo2BdvaV+I3u+DQVQGNIMPMYPA97ZyNigQw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=Wg9JME0FWTs1tYyJ3nmuvph2mMJv0VgG1hoJmiI+89Y=; b=aZbkxp74aJOEBnOpkpBrY4JjtVkb8jGwmmXHfgjbV9gD2+6MXITkE5OTua0EwtZpN7 WEOyuzTC2bSLLwjw1s4jBTHnRKJfpEkbUIaVrTq4i6sAOVFyPaojEp1vEKj7mSAWcG00 oU/ss9+BF0lPENvgf4Jp4CHygTiKmMqUNLc/qf0HMTJBy8YL9czJ3FuyggpkHDYTHOQQ cBn8uFHx02SUczqRX+/m7qER8q+CmzbC/D0W/9e+qjNhdouEZJkWsJHW2YAIk4KFNieh YIEqxH7JGMbtRVkrRVwGF4XoJmWyto/rDNUQaDsdqg0/DEKCN/hnGcaSl53F2bWVzEqb cqUA== X-Gm-Message-State: APjAAAUIw/FZwHmZB1+U/USJclxJJXdxa6+g3l+ACk2wtaXdIBW8PgHg gM8skPcad7j0OkhAtAWci3QDAn8TJQ8= X-Received: by 2002:a17:902:822:: with SMTP id 31mr1685767plk.343.1566165006033; Sun, 18 Aug 2019 14:50:06 -0700 (PDT) Received: from localhost ([172.19.216.18]) by smtp.gmail.com with ESMTPSA id f12sm12543645pgo.85.2019.08.18.14.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 14:50:05 -0700 (PDT) Date: Sun, 18 Aug 2019 17:49:48 -0400 From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , "Paul E. McKenney" , rcu@vger.kernel.org, Steven Rostedt Subject: [RFC v2] rcu/tree: Try to invoke_rcu_core() if in_irq() during unlock Message-ID: <20190818214948.GA134430@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email 2.23.0.rc1.153.gdeed80330f-goog User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When we're in hard interrupt context in rcu_read_unlock_special(), we can still benefit from invoke_rcu_core() doing wake ups of rcuc threads when the !use_softirq parameter is passed. This is safe to do so because: 1. We avoid the scheduler deadlock issues thanks to the deferred_qs bit introduced in commit 23634ebc1d94 ("rcu: Check for wakeup-safe conditions in rcu_read_unlock_special()") by checking for the same in this patch. 2. in_irq() implies in_interrupt() which implies raising softirq will not do any wake ups. The rcuc thread which is awakened will run when the interrupt returns. We also honor 25102de ("rcu: Only do rcu_read_unlock_special() wakeups if expedited") thus doing the rcuc awakening only when none of the following are true: 1. Critical section is blocking an expedited GP. 2. A nohz_full CPU. If neither of these cases are true (exp == false), then the "else" block will run to do the irq_work stuff. This commit is based on a partial revert of d143b3d1cd89 ("rcu: Simplify rcu_read_unlock_special() deferred wakeups") with an additional in_irq() check added. Signed-off-by: Joel Fernandes (Google) --- v1->v2: Some minor character encoding issues in changelog corrected. Note that I am still testing this patch, but I sent an early RFC for your feedback. Thanks! kernel/rcu/tree_plugin.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 2defc7fe74c3..f4b3055026dc 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -621,6 +621,11 @@ static void rcu_read_unlock_special(struct task_struct *t) // Using softirq, safe to awaken, and we get // no help from enabling irqs, unlike bh/preempt. raise_softirq_irqoff(RCU_SOFTIRQ); + } else if (exp && in_irq() && !use_softirq && + !t->rcu_read_unlock_special.b.deferred_qs) { + // Safe to awaken rcuc kthread which will be + // scheduled in from the interrupt return path. + invoke_rcu_core(); } else { // Enabling BH or preempt does reschedule, so... // Also if no expediting or NO_HZ_FULL, slow is OK. -- 2.23.0.rc1.153.gdeed80330f-goog