Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1680293pxb; Wed, 9 Feb 2022 02:02:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUk3zZM5N+8hA0DWuP3SohmUKhCwV2m5WNlh4LfYWXQBpC0EgYvqfW51TtGOGGpCo66rNq X-Received: by 2002:a17:902:ea0e:: with SMTP id s14mr1314582plg.133.1644400923533; Wed, 09 Feb 2022 02:02:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644400923; cv=none; d=google.com; s=arc-20160816; b=QsC8hkyKuL25vpBFHKHj4WoJVFVx2TnluIFmb3hppUpBR9XKB2ul3eH38ohw6nQmhE 8OxTf5MMyDyBFdkYuNDn9RJs6m5sSSdu0RRQpVqjvTlZ55WT0k3L9Crt6NJKspgnOSAS ySN3xzzYk9eTPuQmTQqS0aKh7NCgzV+ikz7klQvXwRsgERQr0T0WlXCbrH6IBiT9lr45 EULS76N9tLkbsr+6chZ9TLgLly4JjjLEVOWMVe4Qe4RuoSV9MYDD/zHgVS1HumABlMAl eF7XHRfM/MPlgjzfu1d171QA/omRLg57GthXzWUD+jtMoQXvMs8vN21o+NeUqauwdMs8 fJ1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VF8ZPG3kAVA/hr4CrVRc3vNtZkRjyIPlUv+pStGpS50=; b=flesGcHUH5EtZMDZPgK4OOHsk2+vjUNH30HsJtZklVnYO94c283MPpy69KHDuF7Ny0 NpD1zosn+pfuk0CF2EHNDBoY1/XgzXqnDx3pIW3LKXixf+41MNbUgDViyz3sxz4ystjV siEZ7fhYVjypvtiGNrPj3GmlIQG7B9P1/H2xSVNVZgwgArdT51je/hdfyIS07bo7PTOV wkY/OyVcDgqZrYU99xgDHnLMUmyL68nZxp9Avf0I/WZncfNmIAq8inA4rEsySlR/8fVl BUU1ZZjJk4z9h5QxHcv7Clgnhiyi+3p/JhrMP8gCVnsHoZt0DszYGDRf3Y9DLHyw9drP V/pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wbaHFfLZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j10si5145779pjl.107.2022.02.09.02.01.50; Wed, 09 Feb 2022 02:02:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wbaHFfLZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385371AbiBGLbj (ORCPT + 99 others); Mon, 7 Feb 2022 06:31:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382631AbiBGLU0 (ORCPT ); Mon, 7 Feb 2022 06:20:26 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87A62C03E94C; Mon, 7 Feb 2022 03:20:12 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 25CF46126D; Mon, 7 Feb 2022 11:20:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F36D3C004E1; Mon, 7 Feb 2022 11:20:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644232811; bh=tB5ykpycoZ7rTEDHLWjtzHvL5qtmrfWQCoQ0Z7I1mNo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wbaHFfLZXDwfg0EiY1gFWVzOJsJYbm3KcG0ne5nXFccgM0wx6uqu915I0FXoajjmX Jft6wDg4G9pNiGFkLMsPKz0JNjUeqcFn/WJxy+jPnwmNFTBvqPwUfQqXS9FlaoIhSO GUcQfcNXjG6x91d7eraTWGAaItkHQm7MHNVkOt0w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Waiman Long , Phil Auld , Tejun Heo Subject: [PATCH 5.4 44/44] cgroup/cpuset: Fix "suspicious RCU usage" lockdep warning Date: Mon, 7 Feb 2022 12:07:00 +0100 Message-Id: <20220207103754.590640611@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103753.155627314@linuxfoundation.org> References: <20220207103753.155627314@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Waiman Long commit 2bdfd2825c9662463371e6691b1a794e97fa36b4 upstream. It was found that a "suspicious RCU usage" lockdep warning was issued with the rcu_read_lock() call in update_sibling_cpumasks(). It is because the update_cpumasks_hier() function may sleep. So we have to release the RCU lock, call update_cpumasks_hier() and reacquire it afterward. Also add a percpu_rwsem_assert_held() in update_sibling_cpumasks() instead of stating that in the comment. Fixes: 4716909cc5c5 ("cpuset: Track cpusets that use parent's effective_cpus") Signed-off-by: Waiman Long Tested-by: Phil Auld Reviewed-by: Phil Auld Signed-off-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- kernel/cgroup/cpuset.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1473,10 +1473,15 @@ static void update_sibling_cpumasks(stru struct cpuset *sibling; struct cgroup_subsys_state *pos_css; + percpu_rwsem_assert_held(&cpuset_rwsem); + /* * Check all its siblings and call update_cpumasks_hier() * if their use_parent_ecpus flag is set in order for them * to use the right effective_cpus value. + * + * The update_cpumasks_hier() function may sleep. So we have to + * release the RCU read lock before calling it. */ rcu_read_lock(); cpuset_for_each_child(sibling, pos_css, parent) { @@ -1484,8 +1489,13 @@ static void update_sibling_cpumasks(stru continue; if (!sibling->use_parent_ecpus) continue; + if (!css_tryget_online(&sibling->css)) + continue; + rcu_read_unlock(); update_cpumasks_hier(sibling, tmp); + rcu_read_lock(); + css_put(&sibling->css); } rcu_read_unlock(); }