From patchwork Wed Sep 13 13:11:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 138794 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1077800vqx; Wed, 13 Sep 2023 06:15:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqka8lNZ3y7ijG5tz18v6pEKJooiw5AdcAdSmkXHVsnsvJvb9JCxlHRyilQwEmK+QQRYYQ X-Received: by 2002:a17:902:ab05:b0:1c0:e091:6a08 with SMTP id ik5-20020a170902ab0500b001c0e0916a08mr2334509plb.69.1694610924322; Wed, 13 Sep 2023 06:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694610924; cv=none; d=google.com; s=arc-20160816; b=egWzDJ2vAFr/MZewd43eKYN9A9kBftGIATk0dDfs9yjpNHRnBsfvIdncM403Q88IX1 em0WEVNQkJxu2FSeMWfJqJaxK1d/ga/w4OPbCUkgK6XDKNpNbtWXWGtcUfkrYWHlQnzD pqebkIzzhlPqpPsgtNbD4/dB619k+gYWwuBCG+EbG1XUGb5qlovg4EqikR/8nPlDnQr2 27dT0Glf6g7+/HfiNb10f2jEagoNAxZ9tXHcAPWRfHXPrE85rKBtUh/BPvlrah3ehrzG tHg08K7aBSvXQj0ckUefQ2acKiF7luTfOj6Occeh78lJEBQhJN8uUHg1rciksCbGTkA3 erpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=6SEKQAKI17rOlG36fSIZP4oQp/6j7GYXmu+VY5njL/E=; fh=zdCoWWNwZujffrJhBueQUzngzidRSLRPEc3xeSuESio=; b=R/sfWqnnhiXzM3sTL1WnvevBrR07wspsXFa9LhkpUrERIyxNZjWEkezoSGAOJedTUT U+484vsAPg9Wzt5J/9Afjjw+bnuDP2ELJacVdUmGE/6it+xOqf8j4UQO1whdViXNmcJY 0Hm9JqMsddLF7mdMNUCd6a/OgMj1FSx1FwmeOZHGxcg3vTNFeN+mI4/wq3FHlxzKdWwx Bg9aHufR7MQH5hLJ3QOL4I25BcpVlulRIYJlmtGjvHkklzV10AUfH0Bh0UkMExh10y2E 8nIN/czz2vSR0Q0RtnSGXtnfxpXHx0zx7TvhbGdMMPbahKCYq4s+HAcjuhEZtSZHJEuT UjMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Rpge5bez; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id jx16-20020a170903139000b001b876d46162si9757551plb.38.2023.09.13.06.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 06:15:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Rpge5bez; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id CD39880926AC; Wed, 13 Sep 2023 06:11:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240785AbjIMNLX (ORCPT + 36 others); Wed, 13 Sep 2023 09:11:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240781AbjIMNLR (ORCPT ); Wed, 13 Sep 2023 09:11:17 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2995619B4; Wed, 13 Sep 2023 06:11:13 -0700 (PDT) Date: Wed, 13 Sep 2023 13:11:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694610671; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6SEKQAKI17rOlG36fSIZP4oQp/6j7GYXmu+VY5njL/E=; b=Rpge5bezC6ApMrOqp8olKPNvBLXWHdxTafs7vE6woi06tNG73zwdRTamJBQJalBgKjSJ4+ XiHDcAz+cXeycbvS8KN/GTgDTW0WxfQyZR2V8B3qHMG57ztNcMW5w4KVzIGX5PpRUk4gx8 Q6tMskjdGmxJmEgEOI/fO0uui7mICn3P0cSb/ZkgRhkA0s/cL2QoNdKUAWcwpBckWv6Fb0 B2fkBEcBxSxFKjynhEnyjf7MbXOcZ8EGjOa2A+WoX0PPtW9xnxKr39Ex+XyYQVn4VypPi+ z3zQr6j4nwDjmDx/4DJo0UN1Vrk1rfsRc/YNppMJ8cdJcXFbH84xFTmWyM4RBg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694610671; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6SEKQAKI17rOlG36fSIZP4oQp/6j7GYXmu+VY5njL/E=; b=lUcdwMyhxHvEpQzezgAU0AG7a/4usUVaCnNc0TiaMhWCBaBWdG2UZmq5k2QWrvlom5/fv7 xOWjMwuSOjPXzDAg== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched: Simplify sched_move_task() Cc: "Peter Zijlstra (Intel)" , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <169461067118.27769.14953901261043740127.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 13 Sep 2023 06:11:36 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776928344665048463 X-GMAIL-MSGID: 1776928344665048463 The following commit has been merged into the sched/core branch of tip: Commit-ID: fa614b4feb5a246474ac71b45e520a8ddefc809c Gitweb: https://git.kernel.org/tip/fa614b4feb5a246474ac71b45e520a8ddefc809c Author: Peter Zijlstra AuthorDate: Fri, 09 Jun 2023 20:41:09 +02:00 Committer: Ingo Molnar CommitterDate: Wed, 13 Sep 2023 15:01:38 +02:00 sched: Simplify sched_move_task() Use guards to reduce gotos and simplify control flow. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar --- kernel/sched/core.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index d298176..a3f4fb8 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -10437,17 +10437,18 @@ void sched_move_task(struct task_struct *tsk) int queued, running, queue_flags = DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK; struct task_group *group; - struct rq_flags rf; struct rq *rq; - rq = task_rq_lock(tsk, &rf); + CLASS(task_rq_lock, rq_guard)(tsk); + rq = rq_guard.rq; + /* * Esp. with SCHED_AUTOGROUP enabled it is possible to get superfluous * group changes. */ group = sched_get_task_group(tsk); if (group == tsk->sched_task_group) - goto unlock; + return; update_rq_clock(rq); @@ -10472,9 +10473,6 @@ void sched_move_task(struct task_struct *tsk) */ resched_curr(rq); } - -unlock: - task_rq_unlock(rq, tsk, &rf); } static inline struct task_group *css_tg(struct cgroup_subsys_state *css)