Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1872540lql; Wed, 13 Mar 2024 10:21:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWtxJfw7b+uYEXT4k2Y2ElvfBjUVCUiVu9JalCfYTYqlTCCXj33LUsYPlRlCUpsqYAb9BtLmJC3YEqmHv2632km1ZiqxPQUGFePzcUlFQ== X-Google-Smtp-Source: AGHT+IFyFfssXTnWX151Pz7G/Jf8iHiXBbn8qiGKBZY+4tniI/2z6WpNzkTKvPh58WmG4mRdArSH X-Received: by 2002:a05:6a00:9299:b0:6e6:a1ed:aff1 with SMTP id jw25-20020a056a00929900b006e6a1edaff1mr3721036pfb.5.1710350510745; Wed, 13 Mar 2024 10:21:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710350510; cv=pass; d=google.com; s=arc-20160816; b=sA3WBtmmCkQbRRx8V3uLvVt8FkyVoVcAZevt37YNzid9XVdftibctOIzDlsa/fz+x4 lNTKXd+t3HlUm5747cIqccJyPLtktuHEuJfwjdHKBClrliHwFofDSLIT8ZGTF4M1s0ju ACLrmOixGqkwfmYD8Nd0gu06ceIJowzEpP0QCZ/iY31yHYk4RxXGYvoCzwEwCF2VgtTO gSbtZEN/WGipEPpBK4Sw3Mw5SE2hRYYi0aiiViwBSZ13+fCA2wQ5KEZIUJ9cyPODqxGy 1XLhXyNV9e16zQsCTXNT0hUxT4vzbeW/r7OjEh9/SDVuHMKPqCEuyZFh8Yb/cyFdo1r3 MrPg== 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=IpNr8SlArC/dSABKoQq/jbp3H/AMx6z/Uhf/F4LDlP8=; fh=icD+R5m4IzvSLoLsxP3Odku2KGYbuGNa4JGfYzcZLwA=; b=rAM2cqCHxRoTHcUB0UGxvUZQChs+dC5KGdz85eOgW68slEdmcFUWKzJ821ZUPtompD P434RMr71sselgS/AW4whocQEcVqiq3PP+zhbd1MubjmAsULqD1x13JBr8RS7nsRp4ot VNIqV6Jwk/e1Y9VnEGVKD2KF/CHNSrCQWdlg162SQ4UoWnjijWY5kkjSt6ugcHoNUaI/ /fY0PP9eF48LsMtRiVXu0hIp9RO9IwUf6w1eI/FqsAcg+mkvoJIBunG8dB4ljx8UiXWi RbOWfszRBoPVVGIXqPrd13KAcWKYloja+rQC0ZXeLBLiqJhPwbrv3rSelZw60P0ae55g Kf6g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CNMKyvpy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101932-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101932-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l22-20020a63da56000000b005e43a9f911fsi9331774pgj.53.2024.03.13.10.21.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:21:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101932-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CNMKyvpy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101932-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101932-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0213C282858 for ; Wed, 13 Mar 2024 17:18:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98D05130E27; Wed, 13 Mar 2024 16:41:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CNMKyvpy" 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 B60F512FF6D; Wed, 13 Mar 2024 16:41:15 +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=1710348075; cv=none; b=ULMdJfAm8AnGeS3XLmXU3yoIZ47Kgl04Zz52yMnGilSOu53Mlx5F6/O8edHMEAsaUZc1A5V6FiVXsTN02tdUUi/kDn1I8Drm7QVyKVJVBQ3k7SxyNDCh1A0vvnSM3rupxlV8F5/7nxAxjSbywaI5FKjnf29/y/wImihNuOTyXXo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348075; c=relaxed/simple; bh=q1NnXT+AJB00pheXcbHdoAByKtIMEu4fRo46oJpbyZ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qw+ZEm3ValLcG4VSSkplJCPVJAsap30/QhWqhWFGHhK9ddhWwdUDiPWYM17AV2i0Er7Ah4ckhvosINfY050QbsJXMKRq9uT7S6t6WTSCkFuRVy1QPwQwgHAGYrnI3/wdo8yDqgasu32eXqlzyHDXztC1kGp/O9YhS5tvuPoeUN0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CNMKyvpy; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB525C433F1; Wed, 13 Mar 2024 16:41:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348075; bh=q1NnXT+AJB00pheXcbHdoAByKtIMEu4fRo46oJpbyZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CNMKyvpyPiw2AItZ/9DjWPdsENpoJOtKNOfosnbJe8wYeQW+mpS9s2YnDHCK+g3Ot xhZD34IRLDkY9NiZoMRH4sWlLrbAd6lOIqI7oeQDWRqwS9zBgwXKGSLPflio/W4UQ1 5hTkgEufNmh0GPxx2vUHYLabJaooefGTin5pmDOegCOYyu+TXk/uDoXwerTBgQlMuM TZCb1PYMIymXvq5rH/CjTvigNle6yqBBcB1dnGYDnA9xSfa+bIDVr9J1ovUMpB9eKJ hIX1qVfW2/YLKT+UajKGp0CdV5EHsvQHNknYxafNwh1V3i58S5jcW2peTrnjVs7MlT x0ORPxhl8F/iA== 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 6.1 64/71] getrusage: use __for_each_thread() Date: Wed, 13 Mar 2024 12:39:50 -0400 Message-ID: <20240313163957.615276-65-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313163957.615276-1-sashal@kernel.org> References: <20240313163957.615276-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/v6.x/stable-review/patch-6.1.82-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-6.1.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 6.1.82-rc1 X-KernelTest-Deadline: 2024-03-15T16:39+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 2646047fe5513..04102538cf43f 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1822,10 +1822,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