Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3712690imu; Mon, 28 Jan 2019 09:28:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN6uRepI1ojwg1A0bOosYTG2Kgv1WeVqxid7JYY5MU17aNg03xmveNSdyh05NqTB49ASWsXX X-Received: by 2002:a62:b511:: with SMTP id y17mr22874632pfe.199.1548696504542; Mon, 28 Jan 2019 09:28:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696504; cv=none; d=google.com; s=arc-20160816; b=IIGgzW1nOULr8EbyQXF/ytTTWEJYa4r3P9DKalO5NopmcZBulsKjeZ1C9dytIFKtsV B/7FEnjEYrEDG2tX7w3zQTuWrJvdhJtBFHRmjt6pr19aKkp6qovl+3aKjAYGVIEfqzba C1r3HUXVwQor5JxxBj8VbhPEFEfG5zSnrqjM7mlP4TkVvYSbrCNxe3vhXJqqeplJ2ilB JpM9m4XaEIBbvQgk3GqizvNo0I400dlJ2LEFyofQOWMl1ufLIV69U0sINizNpOC26utz YJKZRoL7FmiufEGLyQLRV+06JhWTnmFdB1VTvDlG6TMD65oUrxXLJm4ckE8AG+uwsMh4 eV6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yzxff1qa8k+qYcOq5qVRtupSygFFh1P8d+PsXEkTPgo=; b=yWkQCXUbwTJKE+4C5TyhMZv4TbqxyEEOytZPfCO37VOKbatfjYgcQEitDSMQK6bIqS IDm+Xuc5SfiIvZRKVD5I2Tqgq7er2NhGoUpwHWaJ9QWc+qqZ/nu3ZcroeQbNUdebyfZS hWq1i/9yk7/itDbZS2YoGSatNCu2pMpNPpsppvQUuqruEa80MATRr7SMCvDxRE/HVM2i 8WFdP2Lu9LDobCPRll7BmzrnZvpTx/WIoV0Vx2ixCMjQHsAE/YVV01UEYvKHp2mNNBuy rEbrB7s5vNUfSTzBq8/EH1vRTDnEIcIbwIelQKJ7673sRBNF0VLSvJivzQULjDjSnQkh 51Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DR8fOYaO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h70si32259318pge.221.2019.01.28.09.28.09; Mon, 28 Jan 2019 09:28:24 -0800 (PST) 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=@kernel.org header.s=default header.b=DR8fOYaO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731107AbfA1R0v (ORCPT + 99 others); Mon, 28 Jan 2019 12:26:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:45812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729294AbfA1QAb (ORCPT ); Mon, 28 Jan 2019 11:00:31 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C464821848; Mon, 28 Jan 2019 16:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691230; bh=d+T4q3J7C/K4rCY+5+UoUXcpQ11m0dOMCGOWeaKkp5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DR8fOYaOlAyEqDt42Ufhln+oeOKiVeeYE/m9pvDmapIPzWqJs2Bo/5Gri+WuRBFFa rdW+nN/OZVmxcWjbXDX3WY2Ur7jwhcBaB1eHkwvKIl5sStwV0n4zWsl/Wee6miG/bg sXUHSeYElP30Cl6n1TIuyNFiKORyKp6VHkjtdFo4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Paul E. McKenney" , Sasha Levin Subject: [PATCH AUTOSEL 4.19 024/258] srcu: Prevent __call_srcu() counter wrap with read-side critical section Date: Mon, 28 Jan 2019 10:55:30 -0500 Message-Id: <20190128155924.51521-24-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Paul E. McKenney" [ Upstream commit 0607ba8403c4cdb253f8c5200ecf654dfb7790cc ] Ever since cdf7abc4610a ("srcu: Allow use of Tiny/Tree SRCU from both process and interrupt context"), it has been permissible to use SRCU read-side critical sections in interrupt context. This allows __call_srcu() to use SRCU read-side critical sections to prevent a new SRCU grace period from ending before the call to either srcu_funnel_gp_start() or srcu_funnel_exp_start completes, thus preventing SRCU grace-period counter overflow during that time. Note that this does not permit removal of the counter-wrap checks in srcu_gp_end(). These check are necessary to handle the case where a given CPU does not interact at all with SRCU for an extended time period. This commit therefore adds an SRCU read-side critical section to __call_srcu() in order to prevent grace period counter wrap during the funnel-locking process. Signed-off-by: Paul E. McKenney Signed-off-by: Sasha Levin --- kernel/rcu/srcutree.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index 1ff17e297f0c..4b0a6e319b2c 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -853,6 +853,7 @@ void __call_srcu(struct srcu_struct *sp, struct rcu_head *rhp, rcu_callback_t func, bool do_norm) { unsigned long flags; + int idx; bool needexp = false; bool needgp = false; unsigned long s; @@ -866,6 +867,7 @@ void __call_srcu(struct srcu_struct *sp, struct rcu_head *rhp, return; } rhp->func = func; + idx = srcu_read_lock(sp); local_irq_save(flags); sdp = this_cpu_ptr(sp->sda); spin_lock_rcu_node(sdp); @@ -887,6 +889,7 @@ void __call_srcu(struct srcu_struct *sp, struct rcu_head *rhp, srcu_funnel_gp_start(sp, sdp, s, do_norm); else if (needexp) srcu_funnel_exp_start(sp, sdp->mynode, s); + srcu_read_unlock(sp, idx); } /** -- 2.19.1