From patchwork Tue Sep 12 10:28:57 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: 138419 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp655667vqx; Tue, 12 Sep 2023 13:14:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHClzhZWc69dxOC2ZS3LwirX6+CuurIrbLsD1Rf1aUyZ9WJutyvP6ic2Q+nSbQRKqm+YUzu X-Received: by 2002:a17:90a:f013:b0:268:2523:652c with SMTP id bt19-20020a17090af01300b002682523652cmr316946pjb.31.1694549665926; Tue, 12 Sep 2023 13:14:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694549664; cv=none; d=google.com; s=arc-20160816; b=nSfNRuU5xXSVUCDnW+7Z5eDWC8+vFq++qoECzuTh5LOy/uJIPO30NiiCkR5ei0JK8w hTt70cYlDtWp36RkSL4xwnpqCUsW2DCUhCDp72khJTcPtisOkX/uAm+/SlgUvTyfxPAw re5025XvphM00glEZikmj3q5RdFJ9HDh3856+VKRQAOEc93YuOZ7knEOX4YtmK5gtyUs 9H4QniEzMksbDe3bbvaPUQnd73dyWxifXxpls9EciekpxsAiUWjjiKB3/WbRyumz2nTR mRqh5kCdlcZEb9elX6xO2QTC/zRrmuOuBsyHW9awdtfiWj1OM2qDGltfR0pRLngxpvEe cihA== 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=xW3uHBe4EVpDKpMR5ruXEoKnvBzEJaz6nuKa3rYSCWg=; fh=H2MkSknZKy/XcUE0SNWlqZifRHvGVZQUr5cmv0Cbtz8=; b=PwfdnVT+BTp7mUucOXCmqnCRafHJjT25+4GMb5RF8nBaxvId1mzKLo39IilHxH+E3Z 9eoRF4WyruDfTwhcJcQ11E0VESkDdHQeh5l86+A2TBBCmUuMCzv+JWvZ6UvO2EJHmdDU UqhkQG0E9tPb22E79UBOQpfm35zDVojOs3+S6iqw2rAzZ6Rlr6f20Cj1WgqJ7+aLbfe0 /1yh1evVQydt2GgAsYRmUmvYxS5sqEOK4qR7fEQYpEI4bQhC7QRNYu4pZcv/FgWXInC2 hkDpSs9zpxCOivX+41LZYA56awWU/SSMrJJpfPnw3a6fi117jOokrsHwGZswlBC+KR6G 3etw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=az9gPPXG; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id c8-20020a17090a674800b002685065230asi7655pjm.37.2023.09.12.13.14.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 13:14:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=az9gPPXG; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 83309857E57F; Tue, 12 Sep 2023 03:34:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234088AbjILKeY (ORCPT + 37 others); Tue, 12 Sep 2023 06:34:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234384AbjILKag (ORCPT ); Tue, 12 Sep 2023 06:30:36 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3CBA1721; Tue, 12 Sep 2023 03:28:59 -0700 (PDT) Date: Tue, 12 Sep 2023 10:28:57 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694514538; 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=xW3uHBe4EVpDKpMR5ruXEoKnvBzEJaz6nuKa3rYSCWg=; b=az9gPPXGEbv1gWAxMo78KFFQ3SfVir2dhFukdfKaukFaIIH+2VnWfjn5vmU75JLAsSn2Wj lUPD0onwBDpoOU90Htxwp4VPvfei3eI/hB16WhjVOR9tZKnrGWQchq8GMzFGWx47Wc5M4l kOEVw2wXatFGivt8ZoPJgVLfWzQKHO8ipe/3lGcG26zDvTkGhyVyvV3JSd+n1cf6pxLE9J B9l9F3WYULv6a1ifhb+Y2irWUol7OxOYmPqi78W6jgubHlbQeIg926XBjGXq3HsOAAxZxH 0lJudRwu7gZeDnup93/MJuJ/rQG1rdaM9PnGsIcotM8UeAMGm+DKy0oMC5llVQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694514538; 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=xW3uHBe4EVpDKpMR5ruXEoKnvBzEJaz6nuKa3rYSCWg=; b=lsaYGDpRqK1pfiMNTzqsqcg11HkI+NyeweBPeibkFurL8AQCLnomb/SH21E4tdP7itUbO+ 6WwXMCXc0NEznsAQ== 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)" , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <169451453771.27769.16417895756640508965.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 (howler.vger.email [0.0.0.0]); Tue, 12 Sep 2023 03:34:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776864106208118478 X-GMAIL-MSGID: 1776864106208118478 The following commit has been merged into the sched/core branch of tip: Commit-ID: 3840155df4460200584624c7ce71be8e9c9d4f6a Gitweb: https://git.kernel.org/tip/3840155df4460200584624c7ce71be8e9c9d4f6a Author: Peter Zijlstra AuthorDate: Fri, 09 Jun 2023 20:41:09 +02:00 Committer: root CommitterDate: Sat, 09 Sep 2023 15:10:17 +02:00 sched: Simplify sched_move_task() Use guards to reduce gotos and simplify control flow. Signed-off-by: Peter Zijlstra (Intel) --- 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 acaab2d..bcae6e3 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -10438,17 +10438,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); @@ -10473,9 +10474,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)