Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1888558lql; Wed, 13 Mar 2024 10:54:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWAgUjMLtoChPlJs6zvRH6TSfJxma9/U83DYzX5MlHcvtBDSv7wkVMehxKymb7K/T4/HHqyC6w7m+xHO+T2Q3CeTb9IA9A/VuDcBHdi7Q== X-Google-Smtp-Source: AGHT+IF8ak0EHlcT0tAT8SMpV9+GhTsKx1YbeCvG7J3oUcojPmG08rmHvyA0X70PuQYWXOVcsyv5 X-Received: by 2002:a05:6358:5e02:b0:17e:6aab:9687 with SMTP id q2-20020a0563585e0200b0017e6aab9687mr773764rwn.22.1710352486535; Wed, 13 Mar 2024 10:54:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710352486; cv=pass; d=google.com; s=arc-20160816; b=XOMEO3gGSoWaocNuH625uwJ7MduLTCVe6nHVn7IT2RWpufx9jNdGvcHyqweqOWOEs8 amWNWk47iDbt6/i+B1qqYq20z3eWnlyKehKSC4roTI9bVXXWkGFwU9XuoMjzgoxyFgWQ mPtJcaeIjRHcmWZb12a8aFnEntmBG0OXLyVFxGPW3b97HFwTZNl8eB+MrjUi2uZcYXfw N1kuEXeDkjZnNIDpsuDL/NYD9iZcBgggBj8rRGLjhEIcD4jpkJ4Tv15UWN8STnhqQ7H0 G50WYLikEZmQSIZYh28+PG5ljsmgpjqQBOwsykmeng7c04Ia3VxveyimmFGY2++t7igA +gjw== 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=cftR7K8fXz+pP8eWxgpVHIERPumIEcasfWxUpAe/pVg=; fh=icD+R5m4IzvSLoLsxP3Odku2KGYbuGNa4JGfYzcZLwA=; b=c5h837QhJUJIkIibXyDlYe/R9dDBQKISGLd1q0vMF4ZLkL5OcCoZsZDJBGgA8iVqMz p2q39L8AAKnvmenRY1IPQskQXmMJBxieOhWPUwJcBNgKppD3tMHbXBMaIQdMT3ZigJNC rRE6frfFttHBD+dbStVbMTYLlTTlCzk0z+Jf/FvOYgt+5+lUjv0UWxiz0YgVWRIXHlXa xNcWL7VOEBzQEXc7HgdwWOtJKp+di69kUhgxtm5Vf5IAMbBI0gWQxYR0KjscqVMZawwn DGUH+00W0urgjfyfnK5v++SDWSrvnjvLUDmZ67r6accJgTcMsg1YSdLQi/D6HicM286f VwkQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pt5Go2TT; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-102088-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102088-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 bs8-20020a632808000000b005dcd29510e5si9147620pgb.349.2024.03.13.10.54.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:54:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102088-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=pt5Go2TT; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-102088-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102088-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 061FD28335E for ; Wed, 13 Mar 2024 17:54:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4956118BDD4; Wed, 13 Mar 2024 16:47:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pt5Go2TT" 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 6C97718BDBC; Wed, 13 Mar 2024 16:47:52 +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=1710348472; cv=none; b=ETPq/tzz+bcU6c8E93PEoXME9pgluPF2Wf7NW4EGWijzpET6p04Y1m38mSaY5VFr2onMXjAR2KRQHhQgnNap8eMzTa/yUnjJQozUt6hims+J9xvsSFi9ch8LJWxARLziD/H+TIIr0sAh7Aerw/R/X3TV8fcWittq+yzzMbweyfo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348472; c=relaxed/simple; bh=EQtMrThS3/qOAKgjVAXRTKvz+c3AvAO/ciTDn8MHz+c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IuFl1nOfeLowxuk6/ZMGk9TDFdtNSy9HS+XGlZcxJj6yoa/HUwhj6ViUPIpn4791Az4QwJHxup09qz6C9KqsKEP2mBwOHX4gvyVhtiulTN9P8T3dBEBeD7juErsEY6fEUwO4JRny/mJmcwpIRg+8yTv6rZwZBlrXat1Y53zPtao= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pt5Go2TT; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C4D9C433C7; Wed, 13 Mar 2024 16:47:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348472; bh=EQtMrThS3/qOAKgjVAXRTKvz+c3AvAO/ciTDn8MHz+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pt5Go2TThD6bN7YB/znaCGpZfKzcZBnsivFxugGaroM97dk3x8nghBkvya8TcMMCu 9RzlFwlUs1WSQkTlBP9uWvyixdvghLKshcShXKMo6rvFN0cKfdPOOAH3ZST1to7nVk Awqq2V8N4iDQNhuRN5RtU4HW4dqkK9yl5oAfNM9czgFC9JscoJQ4NddaW5gcGNzwfC xR8IFdt8VJhytQgJdhu83LQTbRiZ1u9AXOCjSHHfMPUZxhlONCO/qrK+MC5bbXlkbi coglNlbHWQfl7yWHl0QVPYLRi+om8s/2PR/xBIas4kN4MlbpfOjE+m+5pFaSZOH9C1 vtvB21/wvS1Jg== 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.10 62/73] getrusage: use __for_each_thread() Date: Wed, 13 Mar 2024 12:46:29 -0400 Message-ID: <20240313164640.616049-63-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164640.616049-1-sashal@kernel.org> References: <20240313164640.616049-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.10.213-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.10.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.10.213-rc1 X-KernelTest-Deadline: 2024-03-15T16:46+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 26c8783bd0757..f1ae8fa627145 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1780,10 +1780,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