From patchwork Sun Aug 20 12:53:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Jinchao X-Patchwork-Id: 136323 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2781516vqi; Sun, 20 Aug 2023 21:35:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBQND/61p8punXLZ6eYUm6ozCFRiAlGG/kp//TAKRCbAfKkrT0e7h+MRqEwUC0xOLW/cJ+ X-Received: by 2002:a05:6402:268e:b0:522:b723:11bd with SMTP id w14-20020a056402268e00b00522b72311bdmr5941983edd.4.1692592536281; Sun, 20 Aug 2023 21:35:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692592536; cv=none; d=google.com; s=arc-20160816; b=kIaavSerThckAERrlTgFgx4kduaF4FY+rm4SG6Cp/seMNC7ZpWBl+T5qR58UCbKayt s3bq7GExtYNSazAgAlkgnDnoJ/qU0Qw2+QRNa8sTx+d/pJyEktD5S6CUNRxvLCc5uGoh RL/JBh89oQEO17ut5g8OPWC+HHeOc77VxmQmxFd3cQd/acEMu4cncu9Y2wcgOuvP5NLd ALtnHMEzZGROiDSUzoau5Q1mUayIGNGzVqt7mNrhv30ZHBXcLGN0fQl2sWsE/RWZ5/uq ZfWPKvXXi726yddXO5J1MrUevT7eAuoJoJk6MTWEeKTOIBNZdrM4vDOJc3t4V0FTO+3v u5EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date; bh=lH8jkTya9bcBGHn/tTzOTS6Ex00us3y4unLlZw9IrCQ=; fh=mM3+fCgV9zRlVBtZLfZoYdgb8efcm0mMIpFA+bbRATw=; b=qi8jREErqU+2zaUPt+OcVWTb5Ds4y1USSml6MydGj0Ucmc219F6eihCpzpKppswQoG SMUtI9jJqrh22DrNv4DCKGONxXack/I9Tx2VLiDrfpwiRsUG+3+CJNd3I6TFvB6+VI2m uoK3WStC5tk9Qz1IzidI78Q5TGHLJjzC0IgRn7O8caPVpa6ljBnnnvgCFmAFgs+sovJE kP30DBfSWlflyPFia3Q7oAdTjtyTCRx4yJb6/cx2dKH1bnjO5TgeAym0P7mn7TQwdiSP 02HS2sTNveekNY6E+73vFL9RwWXsx8zVafhXGfVDxrYiUffQE0/rxBknncPupKSYcNpg Sp7g== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a50fc02000000b005288f0e5487si4777119edr.163.2023.08.20.21.35.13; Sun, 20 Aug 2023 21:35:36 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231211AbjHTMxb (ORCPT + 99 others); Sun, 20 Aug 2023 08:53:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231179AbjHTMx2 (ORCPT ); Sun, 20 Aug 2023 08:53:28 -0400 Received: from wxsgout04.xfusion.com (wxsgout04.xfusion.com [36.139.87.180]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E55D4EF8 for ; Sun, 20 Aug 2023 05:53:24 -0700 (PDT) Received: from wuxshcsitd00600.xfusion.com (unknown [10.32.133.213]) by wxsgout04.xfusion.com (SkyGuard) with ESMTPS id 4RTFqZ20qyz9v7ck; Sun, 20 Aug 2023 20:51:54 +0800 (CST) Received: from localhost (10.82.147.3) by wuxshcsitd00600.xfusion.com (10.32.133.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Sun, 20 Aug 2023 20:53:18 +0800 Date: Sun, 20 Aug 2023 20:53:17 +0800 From: Wang Jinchao To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , CC: Subject: [PATCH] sched/core: Refactor task_flags check for worker sleeping Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Originating-IP: [10.82.147.3] X-ClientProxiedBy: wuxshcsitd00601.xfusion.com (10.32.135.241) To wuxshcsitd00600.xfusion.com (10.32.133.213) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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: 1774811911580040118 X-GMAIL-MSGID: 1774811911580040118 Simplify the conditional logic for checking worker flags by splitting the original compound `if` statement into separate `if` and `else if` clauses. This modification not only retains the previous functionality but also reduces a single `if` check, improving code clarity and potentially enhancing performance. Signed-off-by: Wang Jinchao --- 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 c52c2eba7c73..9621ee979b0b 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6745,12 +6745,10 @@ static inline void sched_submit_work(struct task_struct *tsk) * If a worker goes to sleep, notify and ask workqueue whether it * wants to wake up a task to maintain concurrency. */ - if (task_flags & (PF_WQ_WORKER | PF_IO_WORKER)) { - if (task_flags & PF_WQ_WORKER) - wq_worker_sleeping(tsk); - else - io_wq_worker_sleeping(tsk); - } + if (task_flags & PF_WQ_WORKER) + wq_worker_sleeping(tsk); + else if (task_flags & PF_IO_WORKER) + io_wq_worker_sleeping(tsk); /* * spinlock and rwlock must not flush block requests. This will