From patchwork Mon Mar 20 23:37:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 72531 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1493026wrt; Mon, 20 Mar 2023 16:41:45 -0700 (PDT) X-Google-Smtp-Source: AK7set9gUGDcUp4mdGG3x5g3He6LbjylGUKGdMzLQ/6l1PQFdz0EwZM0yryuaBMRK5zowNy61nOj X-Received: by 2002:a17:90b:4d12:b0:237:373e:9dfa with SMTP id mw18-20020a17090b4d1200b00237373e9dfamr406131pjb.20.1679355704917; Mon, 20 Mar 2023 16:41:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679355704; cv=none; d=google.com; s=arc-20160816; b=MDCU+w/HJhdUAQjjypYr036gKNm+yODwq+Bxn1fmKREzxrhSIsx0cRLGOL+Q4gchqo Jb81cO+tMII0NLXh1u7p7cOqpUekjWvXaFggVOaCslJHJxN6sa5deF8eslRB+BnFjtWk 8P1ZrqVLX93a/C0zzVLY/lMw2fFm+wJf8Vlbg4AUstzp8jHy75ApVNkBFVF4wSSQP6kh xFO2qGI/gqP3nJeCueKtSNgQpWrssMBIsrWx57bnRICvaANwhSm2feyqwf//FFANDG7t r0ky3Ld3jjlkbDCLn/kbmtu7L9c7KmR+VMjnwFRJo3xf6CdiwNdoLDkw/nEZcWPhkSdZ wuYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=M9InGmtBwylP8bL6euAgOOc7oo3A0OeHZtEdYhhnysM=; b=CMdoU8x7I4CamU7FQ0QbCED2G4qpCkfKkCtFQ9XeTKe62Kz1hr7VEVrT/1px538Dl5 vc9AZNpLiZB6PygGPxwsv19W8j4nFgHTd2t2/cbYMqnrNR+XAU6GnzlfrjOe6MxTUxIn F6RZ0diJH+wUSPNPvT1Kno31jE3W8YZAPhyuh5BqbdlTL0GH/9cL3Dre6nm/1T667T9u t7mYymCd9+o8b1WE8rUtnDj69HlP/hxVkfIvbKsDV67XtgWRD4fqDeZceeQ70UIMj+O6 VetFBCWz2FYsLl3AaV8EcU3RZrIKLq6rc4nhxvFf0MxDkW4ygI2Zwd8qEYFGmQzeLdlK sqlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=tBdJJ3bX; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u5-20020a17090a400500b00234b0c3e853si16711511pjc.93.2023.03.20.16.41.32; Mon, 20 Mar 2023 16:41:44 -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=@google.com header.s=20210112 header.b=tBdJJ3bX; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229945AbjCTXiQ (ORCPT + 99 others); Mon, 20 Mar 2023 19:38:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230001AbjCTXiG (ORCPT ); Mon, 20 Mar 2023 19:38:06 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E9F236FCE for ; Mon, 20 Mar 2023 16:37:48 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id 16-20020a056a00071000b00627e9b4871eso3226638pfl.11 for ; Mon, 20 Mar 2023 16:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679355467; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=M9InGmtBwylP8bL6euAgOOc7oo3A0OeHZtEdYhhnysM=; b=tBdJJ3bXzEAqBg5M0RohgU8XkpUgmAhZxi1F0ozqNaJD6/TmyjVYC+9AfydDlWAM5p e+gPMOfd3Qxx7L7CE+2mTiQoZNNfTDDwrJAsqSOZjZ8a701+03qydsrxkSV4g5ToI9bI pdv/wYQAg0XHJUvrG+UfODoKHkUrEEJmqlyoE7//VxvFl03fyRJeA+2+oARodE0+F2v+ hJTNcXMtgC//nZ6xBQpwKFQEJqeKTCR9C8SYsKqYHYLeUIYmi19Nv2wGbysNKET8gu4q Qg/UWnCrbgzrIzSRaZanCxvhJVagIUPxzn0BHKstG9QF3jd7izTWrWR84W7DT54Y4vJt Dzkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679355467; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=M9InGmtBwylP8bL6euAgOOc7oo3A0OeHZtEdYhhnysM=; b=V/n0li+T7obXhBw1nr1+UHcBt7yWooP7RgJSaIVk9lweBGfKOTNfkLHdT7NLAPF9qM AxhydsVG090Am6UML8f9H5mJJu17xLfeVkCJUCWDQwbmtwZ+rxadf6UaKr+mlQFyL1yB ugTnLu4pCU1ysH1OnZ+0HgKa6ByY5F14kuMFTD9u/mTlkgpAbzCYjFLaFlYWF7PDG48P ZpwSXxLswozbZh2NjWsLqN5raxMl99qWou/MPD6X4RtAGn3CXQ/g6cVU4PMbUKJM96Uj JpQjUuy9z9BvZsY1BPIAUZQjKQdbfnKb08KE/m30zlDAdYXOmX0XiMMBvMJ9tEmLBtbt HMGg== X-Gm-Message-State: AO0yUKUHMbesA3rsMAyCeAYnz+FSDPcjuCLKhXmAgHc59PW4UqzSKzvV TGuZiv/75EouvH8ndwgJpepr+Csi1J6RpAKEayyQ1opcS+5mI5bqx6VzDoYcYwhIds6OtdDLrUW SU9TPeN6fD5cepUUF/Tja5ZL0wWqACs7KpNZDRFCSgg52gz0HN/ElkSU8tS2w1hiG1PGg0JU= X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a17:903:183:b0:19a:ec61:98d4 with SMTP id z3-20020a170903018300b0019aec6198d4mr87109plg.0.1679355466445; Mon, 20 Mar 2023 16:37:46 -0700 (PDT) Date: Mon, 20 Mar 2023 23:37:17 +0000 In-Reply-To: <20230320233720.3488453-1-jstultz@google.com> Mime-Version: 1.0 References: <20230320233720.3488453-1-jstultz@google.com> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog Message-ID: <20230320233720.3488453-10-jstultz@google.com> Subject: [PATCH v2 09/12] sched: Unnest ttwu_runnable in prep for proxy-execution From: John Stultz To: LKML Cc: John Stultz , Joel Fernandes , Qais Yousef , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Steven Rostedt , Ben Segall , Zimuzo Ezeozue , Mel Gorman , Daniel Bristot de Oliveira , Will Deacon , Waiman Long , Boqun Feng , "Paul E . McKenney" , kernel-team@android.com X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760932087988144676?= X-GMAIL-MSGID: =?utf-8?q?1760932087988144676?= Slightly rework ttwu_runnable to minimize the nesting to help make the proxy-execution changes easier to read. Should be no logical change here. Cc: Joel Fernandes Cc: Qais Yousef Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Valentin Schneider Cc: Steven Rostedt Cc: Ben Segall Cc: Zimuzo Ezeozue Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Will Deacon Cc: Waiman Long Cc: Boqun Feng Cc: "Paul E . McKenney" Cc: kernel-team@android.com Signed-off-by: John Stultz --- kernel/sched/core.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ab6b1917bc70..82f5b29ae675 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3773,18 +3773,20 @@ static int ttwu_runnable(struct task_struct *p, int wake_flags) int ret = 0; rq = __task_rq_lock(p, &rf); - if (task_on_rq_queued(p)) { - if (!task_on_cpu(rq, p)) { - /* - * When on_rq && !on_cpu the task is preempted, see if - * it should preempt the task that is current now. - */ - update_rq_clock(rq); - check_preempt_curr(rq, p, wake_flags); - } - ttwu_do_wakeup(p); - ret = 1; + if (!task_on_rq_queued(p)) + goto out_unlock; + + if (!task_on_cpu(rq, p)) { + /* + * When on_rq && !on_cpu the task is preempted, see if + * it should preempt the task that is current now. + */ + update_rq_clock(rq); + check_preempt_curr(rq, p, wake_flags); } + ttwu_do_wakeup(p); + ret = 1; +out_unlock: __task_rq_unlock(rq, &rf); return ret;