From nobody Sat Oct 4 14:16:59 2025 Received: from baidu.com (mx24.baidu.com [111.206.215.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60EDE20013A; Fri, 15 Aug 2025 09:15:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=111.206.215.185 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755249341; cv=none; b=QxOhUMKIYF5lNJsVgRoxhNRzoq8zyQMTlgSz1JpMrMqWz7clx4XnjPbPlHELX+3KajJ4kTJaInuf/c2DaL6+Gku0zo1/H/wfeTj489++8I9h7OWE2o343PXq70HJdmiSYjw5ksj3bOkOwH//EYa7BL6RsYabNEvtvQ6DcUl4r0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755249341; c=relaxed/simple; bh=nVIvDBy/Jm3WR2xeA1aZWmOPqonh3tIFG7Otxlac60o=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=cWhomrzgt0zh1qmgTR6xyfphxsGaCS/UOaZzi+F81gDq8uYzXuGn9WPwATto2J16WaytfSoHtiW7U5G0sCdI+8GABywRzTykq0+QuiYZqcQqKBP/ISmgFqRnTteXfm85KiHKxmxHowiYpp6FdBL9wiruTtUUGA6765w8vyA7ntE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com; spf=pass smtp.mailfrom=baidu.com; arc=none smtp.client-ip=111.206.215.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baidu.com From: lirongqing To: , , , , CC: Li RongQing Subject: [PATCH] cgroup: Remove redundant rcu_read_lock() in spin_lock_irq() section Date: Fri, 15 Aug 2025 17:14:30 +0800 Message-ID: <20250815091430.8694-1-lirongqing@baidu.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: bjhj-exc2.internal.baidu.com (172.31.3.12) To bjkjy-exc3.internal.baidu.com (172.31.50.47) X-FEAS-Client-IP: 172.31.50.47 X-FE-Policy-ID: 52:10:53:SYSTEM Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Li RongQing Since spin_lock_irq() already disables preemption and task_css_set() is protected by css_set_lock, the rcu_read_lock() calls are unnecessary within the critical section. Remove them to simplify the code. Signed-off-by: Li RongQing --- kernel/cgroup/cgroup.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 312c6a8..db9e00a 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -2944,14 +2944,12 @@ int cgroup_attach_task(struct cgroup *dst_cgrp, str= uct task_struct *leader, =20 /* look up all src csets */ spin_lock_irq(&css_set_lock); - rcu_read_lock(); task =3D leader; do { cgroup_migrate_add_src(task_css_set(task), dst_cgrp, &mgctx); if (!threadgroup) break; } while_each_thread(leader, task); - rcu_read_unlock(); spin_unlock_irq(&css_set_lock); =20 /* prepare dst csets and commit */ --=20 2.9.4