Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1880124lql; Wed, 13 Mar 2024 10:36:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV/39hyyWfgXeNGPjFuosm9Ti6H7OD91PxnC0cY6fjl5XJP29+XPVrVB4gJDv46LhrNekgrJJjc0rH1r43g/XyMWQWIa8ZNv38/cCeElQ== X-Google-Smtp-Source: AGHT+IG7gD5juvNRNpQGR4OFy8aaNmuA/lQL+OMVlMXSxPsGxxd6EvU+dlwpyL5mQgRMtp2o4haQ X-Received: by 2002:a05:6830:20c3:b0:6e4:fa5a:932 with SMTP id z3-20020a05683020c300b006e4fa5a0932mr525897otq.36.1710351395224; Wed, 13 Mar 2024 10:36:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710351395; cv=pass; d=google.com; s=arc-20160816; b=rHWeaOOc2Xfrkn96HJPGZyOQogFeT3kd0BdG346xMq0KQzqseWkeHBUJAHb/03pXpX BkcbPpQ7cbpYVDjzqX3yR/o6/KOBu2v+NGSDKuG5eNZ9w/l2hEAxLpqcDjAk0bCaEJUC 1FEIh+xZ/23o7+lrF6FHYAo1cIWVXLai4R8YMv7xuSa2/+4CLkA1rOl97Js/Rk6IwKHI VVoxf+Dt1FROEvRzcyUyPUFTbC2jSV1CfqlSRkE44sH9hvW9v/RbTrAk9IOcF2dbecBj CozwBbqvztasXJ1CUrIxr2m8eImhxnawtS4rqEr/Mw3j2u4DvmeVEVexrw4ZUfY4zqua V7LA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6l2nqxLD1n6J4tN9XjOjI4EqAnZ1mikDfNcl3pZCGAw=; fh=icD+R5m4IzvSLoLsxP3Odku2KGYbuGNa4JGfYzcZLwA=; b=ilD8CCQ2u5cMYKO3WTkESD5pfKxRYXhPbkp8ckSO8BFucREqTUYmZqygrjfU9koRFY FDBTpvsx8XvJ6T7u8U8BoXOlq7t6ViyasektxPLVl/Q0hHs3fno+bSKX/GpW9FZ5Vkvt u+LWSJAeCwB/0mpynPVJCZfgYBFTFK0xcWXmOphJbP9OowWezVU/YYATq/zLSgQhTXde gpCyEqXDDbrVAs46jKH8u/IXcLL1PNTR40LLJOAo9TjSVwJQxfMcrwqUBGRlGsnQEWAz hsvKiM0c/G8fv6ujl1BU6T+NMcXtkzGBIyPTogSevsOWQxZEQza24CFURShD4kNNsT2u z4Pg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t2jnWM0b; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-102003-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102003-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id s19-20020ac85cd3000000b0042ef03c960asi10498519qta.802.2024.03.13.10.36.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:36:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102003-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t2jnWM0b; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-102003-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102003-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 63F451C22652 for ; Wed, 13 Mar 2024 17:36:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90C0D14BF3F; Wed, 13 Mar 2024 16:43:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="t2jnWM0b" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 AC23F14BF20; Wed, 13 Mar 2024 16:43:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348215; cv=none; b=LyZnI2P8zCH2mNbl1I7aaTMxPiFP3KoEVrFpe806XWycUrV9Ie3bpOcz0u53xyRejpxCe7ZzxyX79Gr78oBZTw3hv78yui6n7p3wXzSfPKHmkpPy0SzsJw1YJrd9ExqMZ1rwOdrl+bkvz+pNKcyhZX37IPBcigLgFyb4ZyG8vy0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348215; c=relaxed/simple; bh=Ua5zIpkGM0VdF4IOpoP+bs2DZ9wApB/huugP8qfRO6Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pqjsAuJFInBI4VA6sKdKg3U6z6btmxz/oDHQHQzvpmJZHav5wLgovCoTNJAc6O2bcXmUE0s9VGCVxOdQBJmMMMr4GObhjK/xXtRRieWVjCW8G6JBQd7yJkfHZsle62xhJ5JV1Fw+vpRDJKjidqo/U8fHm90l3gLhTuZZAQ/724Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t2jnWM0b; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB6C6C43399; Wed, 13 Mar 2024 16:43:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348215; bh=Ua5zIpkGM0VdF4IOpoP+bs2DZ9wApB/huugP8qfRO6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t2jnWM0b1frbqK2QpEXLkLtdCrZSS8glgypjmiMP2IK3bVBCqhkyv1NHCqNhD9a7T bkSWK6Oxt/Eyq/acBPIQBw6WbNxbvT7M34gwhAHTat7dGEStawWk0uCg9hhlgqn1vY TIw5UxmYHJT6u97Qz/r9CThK1bqvRnXhljGOeF6gdGedPGHDgrdIaVta/z/50g2Hhg ewETABWvehbTl9m+ozCu6/3+DaL3wal3Ir5mc/P/no7KIWhSIOUtL9TUqsh11EuLcQ sMGjmX8/68BhZ1/LDQWr8H3RCcV/GTx1H6cwoOOSpS841jooOJOLF7ql1l1tlv+qz/ bwlCiLsHSnr1A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oleg Nesterov , "Eric W . Biederman" , Andrew Morton , Sasha Levin Subject: [PATCH 5.15 62/76] getrusage: use __for_each_thread() Date: Wed, 13 Mar 2024 12:42:09 -0400 Message-ID: <20240313164223.615640-63-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Oleg Nesterov [ Upstream commit 13b7bc60b5353371460a203df6c38ccd38ad7a3a ] do/while_each_thread should be avoided when possible. Plus this change allows to avoid lock_task_sighand(), we can use rcu and/or sig->stats_lock instead. Link: https://lkml.kernel.org/r/20230909172629.GA20454@redhat.com Signed-off-by: Oleg Nesterov Cc: Eric W. Biederman Signed-off-by: Andrew Morton Stable-dep-of: f7ec1cd5cc7e ("getrusage: use sig->stats_lock rather than lock_task_sighand()") Signed-off-by: Sasha Levin --- kernel/sys.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kernel/sys.c b/kernel/sys.c index 25f0c0697356b..85f358a5d5eb5 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1807,10 +1807,8 @@ void getrusage(struct task_struct *p, int who, struct rusage *r) r->ru_oublock += sig->oublock; if (maxrss < sig->maxrss) maxrss = sig->maxrss; - t = p; - do { + __for_each_thread(sig, t) accumulate_thread_rusage(t, r); - } while_each_thread(p, t); break; default: -- 2.43.0