From patchwork Mon Aug 14 15:08:06 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: 135535 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2846272vqi; Mon, 14 Aug 2023 09:09:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2KFBzyJI5wLqitVtwVDxiRVT74hU2++qfdsDCbF3lXNYHyswp8dPssqXvi8xWSozXNYgs X-Received: by 2002:a05:6a20:1581:b0:144:2ea8:1a92 with SMTP id h1-20020a056a20158100b001442ea81a92mr4654045pzj.12.1692029383774; Mon, 14 Aug 2023 09:09:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692029383; cv=none; d=google.com; s=arc-20160816; b=D+UXwnyHVPV9vdgRBWE5e+aQfT5YndXN30H2kCOBTOMgFUyFKrOVHVpG4psLmEdk+O b43J+evzzOcK45nBxNa2nru6EFkBu2zoZmRMIR2HZn3PREozqv+or/oiu/HF/eExuYaM H7dMKs4ypvdk41XTSRG3Xmu2bkmRR0ZnVHI3i2M2Z6dIFhbO4tcPVHZUn5p+VnxhGJIO BSgqjR8mTq81F5lXHu3qv+PoPf6wvPg6Jx/58KHgvT7DTxwESwO8uFxuFcEM3JGRfMSa SOlW7NLRJ0zbPRTQNbjqWO50k2eTebpXDStEgJH83TV0CoiZCGsGGG3Fv9iqEXq2AL2q 5Krw== 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:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=1+9KtufBaYgo54ysjDk7SUlAA47oGnzGYwwcRXS9alE=; fh=utQzrRGpdyneC53QA2zUro1rWgCYMKhBZhFdjXY/HTE=; b=nRBaj6s178t5xPgleQhXAqANQq71pb8HTDdfHLPmHa2yR2fMVbs8BFyCbFsVC6VsvT gCvAlkUNHDetwP3p56beloc7fckOmSlPu5bS0UWtLtDu+7P2ndQP99rjuzkqJhWEBZ2e OBWCg3o/PcVZfMROqWyrbdZDIeSC86TXYrJppvIV70JQC07Bp9QJzwmAupOdBxeIhaM6 HHpuK05JlkV8gY5Bz65/eLpj8HqSi7LMNb6FTgeTaRUth9Th9Up7BKqn6nNbsxeOAaes gSicu0VcLgUwq/m5vZl8Xr2F8yLcjzga6dtoT54AGdve9hqVANjbJcTVcqdOIKObzlyj /5kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IvhNj7zb; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k13-20020a634b4d000000b0056476f15584si8546151pgl.541.2023.08.14.09.09.09; Mon, 14 Aug 2023 09:09:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IvhNj7zb; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232680AbjHNPIc (ORCPT + 99 others); Mon, 14 Aug 2023 11:08:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232676AbjHNPIM (ORCPT ); Mon, 14 Aug 2023 11:08:12 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7396410F4; Mon, 14 Aug 2023 08:08:08 -0700 (PDT) Date: Mon, 14 Aug 2023 15:08:06 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1692025687; 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: in-reply-to:in-reply-to:references:references; bh=1+9KtufBaYgo54ysjDk7SUlAA47oGnzGYwwcRXS9alE=; b=IvhNj7zbTkTawoRo7s1c0hIrnGrzSzWl7D9XyCUt9Xy8ORqecBL/khBh1KbLROnsebkC9b K0htwf7y6vpomDnVz2g5irHm2pVAeh+EDWuYQ2qN7pE2yDGU52hMVzvxwCro2tMWPzGpQR 13Ry53t6+5POmEdUlpGwLwb2eerdVgdY09vMVavl2l7qM+a/W3zqKsx9jrQX4ENMuuj2cP IVn7vL4ehoLfqwTSHkXewCB4udqzfRH9JqeF79Lf8+MtN/MkPF6JkMzVHD7Lzh7mqBHjp+ GD/VPKqbWpgeo6Za9NSaTpkQuU1C0m3IBWMI3Lm5P5u3prywImJyP5++TEqw9g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1692025687; 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: in-reply-to:in-reply-to:references:references; bh=1+9KtufBaYgo54ysjDk7SUlAA47oGnzGYwwcRXS9alE=; b=Qed8k9Bx+afHNwUxzZSTADaNXNOAHe1ZQw8P6T/zWfIaT2g8pHHuchmXHj5XSI58kUPYtX COGGFi3BoeRHPkAg== 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 sysctl_sched_uclamp_handler() Cc: "Peter Zijlstra (Intel)" , Valentin Schneider , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230801211811.896559109@infradead.org> References: <20230801211811.896559109@infradead.org> MIME-Version: 1.0 Message-ID: <169202568664.27769.1824574211611441233.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773066222276777766 X-GMAIL-MSGID: 1774221403386282620 The following commit has been merged into the sched/core branch of tip: Commit-ID: 0f92cdf36f848f1c077924f857a49789e00331c0 Gitweb: https://git.kernel.org/tip/0f92cdf36f848f1c077924f857a49789e00331c0 Author: Peter Zijlstra AuthorDate: Tue, 01 Aug 2023 22:41:23 +02:00 Committer: Peter Zijlstra CommitterDate: Mon, 14 Aug 2023 17:01:24 +02:00 sched: Simplify sysctl_sched_uclamp_handler() Use guards to reduce gotos and simplify control flow. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Valentin Schneider Link: https://lore.kernel.org/r/20230801211811.896559109@infradead.org --- kernel/sched/core.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 6cda296..6e8a8e9 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1827,7 +1827,8 @@ static int sysctl_sched_uclamp_handler(struct ctl_table *table, int write, int old_min, old_max, old_min_rt; int result; - mutex_lock(&uclamp_mutex); + guard(mutex)(&uclamp_mutex); + old_min = sysctl_sched_uclamp_util_min; old_max = sysctl_sched_uclamp_util_max; old_min_rt = sysctl_sched_uclamp_util_min_rt_default; @@ -1836,7 +1837,7 @@ static int sysctl_sched_uclamp_handler(struct ctl_table *table, int write, if (result) goto undo; if (!write) - goto done; + return 0; if (sysctl_sched_uclamp_util_min > sysctl_sched_uclamp_util_max || sysctl_sched_uclamp_util_max > SCHED_CAPACITY_SCALE || @@ -1872,16 +1873,12 @@ static int sysctl_sched_uclamp_handler(struct ctl_table *table, int write, * Otherwise, keep it simple and do just a lazy update at each next * task enqueue time. */ - - goto done; + return 0; undo: sysctl_sched_uclamp_util_min = old_min; sysctl_sched_uclamp_util_max = old_max; sysctl_sched_uclamp_util_min_rt_default = old_min_rt; -done: - mutex_unlock(&uclamp_mutex); - return result; } #endif