Received: by 2002:aa6:c429:0:b029:98:93ff:f56f with SMTP id g9csp3408024lkq; Mon, 23 Nov 2020 05:03:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwEJCU2R4MICUTiDKWPmqTTDAdTkXY1s4+wsvpl8ouyuU/lz8n13w1e5iEubqqFg82gTxz X-Received: by 2002:a17:906:489a:: with SMTP id v26mr30204660ejq.422.1606136629495; Mon, 23 Nov 2020 05:03:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606136629; cv=none; d=google.com; s=arc-20160816; b=MryboqB5+estlww2GpNEFmAAExOgIRTDztVgjp0luA74bxgCuN+2p4Wp3KUixS/JAd Gb8XJTmEO0OHHg+L4tdNaEslpaYiPPAD4YuGDmZTSGReqK+lNNEaTslkP3WWyaPd2DAn DddWnq1nEwXygNTt/e+2JI+tJC/Jc7DNP6IVuaGBkhpMCo0PmfKHvfHxrUR6jbMpLLVP Y1taGJ+3JP3cn/pIt1wc9Z0yzAQh6nS9yT6Mptqh/o0/i8+j2ud55SfwVMuOQlYzm3L6 bCNP5fKQLXjzWP8htpTSk4+dsDWn9a04/xZ9bgyPs3hNH2gz4SWnvUU6vbkKmYbxrVJe dF3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=y+SeRwvHbZQftOnFfRGkqQkmiVtK8RsTFsZN5mRi71k=; b=x0l6Y5xNg2Nnhs6RNsUxG4BRJ7SpFA6YKObx/jkdEx307aKI1/APGkYQEUntoUdwrI 0TKpzFWkika31UvNEpO45QnrEGot9xv5o1fE7VvfUQjfTaMcG7wDFbtrNGF0tYY7Hs1F 72j06KKgDv8BnPjOYDd3L/p8vW+/1sCCK62Wfii0GG3nih+D8/jzt6Ep++o0WS/2IO0p FkjgiZMtAJmzPxIKy7FTjnL6f1y1vJTPQkxhdRgwjTQLYOv3c8PNM6BbvQXCzEjkT1Ws NqiJ+hnYRDYRF7YbC1y7oilFysXbh3fnwtNdkbbVv9sxIHT46Z2CdducromLgotB4QGK ROUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bug4jrxX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si6930947edm.321.2020.11.23.05.03.13; Mon, 23 Nov 2020 05:03:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bug4jrxX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388172AbgKWM7c (ORCPT + 99 others); Mon, 23 Nov 2020 07:59:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387943AbgKWM6y (ORCPT ); Mon, 23 Nov 2020 07:58:54 -0500 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8E9BC0613CF; Mon, 23 Nov 2020 04:58:53 -0800 (PST) Received: by mail-vs1-xe41.google.com with SMTP id l22so9056259vsa.4; Mon, 23 Nov 2020 04:58:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y+SeRwvHbZQftOnFfRGkqQkmiVtK8RsTFsZN5mRi71k=; b=bug4jrxXcKK+FNJJGQ4a2+cGlNoFaTOm7GdIo0tVMuBvURaXmlvTpLBF+N7IRKLhDM pJG/jgrfh4xqWctEZO+bHNQTf/v1/r4gT8Y54P8ZyBRF4PjFSoC7Nr1Y6JGI6xapoPZz Q3OKMdkP3jf4l4rGVZNXKFUdS5pXM7Kt93LFcfZh0pbmzIaI/HuD/E6xzS41JF9mKpEC FDItjmkiDiOEGFipUCTwYzx5Zt5DrpTkUxpsCPTaDyWk9jlCy0YNGMJdnRAtkUOX9Bvq +VMyC1guOsy9+oyS6zqHAWKX+Ci+jFv4mPaY4gSyyklT2eTqmqhU2RKXkxE0mDfc8UeP t+wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y+SeRwvHbZQftOnFfRGkqQkmiVtK8RsTFsZN5mRi71k=; b=fLFXppsVZTk2EdwCitcEvVrScEL6jl0M4819fzT4epslNKDFjWNC5MZ9AcnpXgloe3 5DdB0lR+leiQwHxiYZ2IdjsUGTl7+D+tU7JUpvjV6yUiCCBJV/OASGGDNvGTpC9zSEmE t/+HmfyCUHZ1CtjyWGPPVm8GEVHQ9Z8gnrscRob7R8ce30g0XegfaewP8vsXxPwvXQb5 pV+k5OhAadDuo483GklilRmWlSN5GOPMZbwC71sAh3DOXC+GP1rXlz+wQnEVSG86McIH YK4/cupT/gr3qeytz81a5/oOiKADA83aQmZr9DeDwz2+3uj4ivTEEdvcMsz4AjqNBxcP Qetw== X-Gm-Message-State: AOAM530Fluo4s6psWLXx94od2W4d4N03hlC4pD70dftsYr3fiIGlKK8a J3wh6DBOxO8JEtsD5WgU1o8= X-Received: by 2002:a67:f587:: with SMTP id i7mr18542248vso.46.1606136333068; Mon, 23 Nov 2020 04:58:53 -0800 (PST) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id h16sm1579091uaw.7.2020.11.23.04.58.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 04:58:52 -0800 (PST) From: Yafang Shao To: mgorman@suse.de, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, Yafang Shao Subject: [RFC PATCH v2 2/5] sched: define task_of() as a common helper Date: Mon, 23 Nov 2020 20:58:05 +0800 Message-Id: <20201123125808.50896-3-laoar.shao@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20201123125808.50896-1-laoar.shao@gmail.com> References: <20201123125808.50896-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org task_of() is used to get task_struct from sched_entity. As sched_entity in struct task_struct can be used by all sched class, we'd better move this macro into sched.h, then it can be used by all sched class. Signed-off-by: Yafang Shao --- kernel/sched/fair.c | 11 ----------- kernel/sched/sched.h | 8 ++++++++ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 8ff1daa3d9bb..59e454cae3be 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -259,12 +259,6 @@ const struct sched_class fair_sched_class; */ #ifdef CONFIG_FAIR_GROUP_SCHED -static inline struct task_struct *task_of(struct sched_entity *se) -{ - SCHED_WARN_ON(!entity_is_task(se)); - return container_of(se, struct task_struct, se); -} - /* Walk up scheduling entities hierarchy */ #define for_each_sched_entity(se) \ for (; se; se = se->parent) @@ -446,11 +440,6 @@ find_matching_se(struct sched_entity **se, struct sched_entity **pse) #else /* !CONFIG_FAIR_GROUP_SCHED */ -static inline struct task_struct *task_of(struct sched_entity *se) -{ - return container_of(se, struct task_struct, se); -} - #define for_each_sched_entity(se) \ for (; se; se = NULL) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 871544bb9a38..9a4576ccf3d7 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2636,4 +2636,12 @@ static inline bool is_per_cpu_kthread(struct task_struct *p) void swake_up_all_locked(struct swait_queue_head *q); void __prepare_to_swait(struct swait_queue_head *q, struct swait_queue *wait); +static inline struct task_struct *task_of(struct sched_entity *se) +{ +#ifdef CONFIG_FAIR_GROUP_SCHED + SCHED_WARN_ON(!entity_is_task(se)); +#endif + return container_of(se, struct task_struct, se); +} + #endif /* _KERNEL_SCHED_SCHED_H */ -- 2.18.4