Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3771763yba; Tue, 23 Apr 2019 09:20:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzy9A8KqmQwgYgPefFyv4N5lyfy8IeaNgWEEJpiHrvv4Pu4RIS3AddBW6Phx5Py3ond+31g X-Received: by 2002:a63:27c5:: with SMTP id n188mr2638998pgn.338.1556036418202; Tue, 23 Apr 2019 09:20:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556036418; cv=none; d=google.com; s=arc-20160816; b=mdHolh50YLJG+nKGXQqcztzYWaXcrbiGmVUNAsvB08opM/i8R/4DN6q18yLxDdQCob Xa9OS7Tlpu2yNJ+1O4+bGjW8UtjcVOmXMcQ6E4GlxM/rzKCP4VwmZ6hjAflr+U8cQDZl i32Fz5bnpuolo6K9alDuRsCFtMm5PnWglgnHfe5pMlLw9utImR8jNf4D7bceDJEkf18P yi/B9avoO+lljntcPYIgI3XsiFRKAcWUVTcAprzQkmO6HsJe3rPPDpiEkDxi11h6ifE3 3uIXwRl6W15ehHGKfkQOyQskgYxHlgzXuSnB2aeoFr+RnZ2Seul7lPVWSjsevDhVPkEr f7Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=EtZk3SeeXKQqkXCHRONf08T07XQMFClawAltZ/fWtIE=; b=iLoFesI8RE6L1/CXn/VwMxkdlJ4OfpKXTnhTE86udNfPvaviwoBkSWohuXhLZCiv8j IZ4lmVMf5aCWrdJgRFlZW6PIHYG0Rwl8m17RZ7qWb6UATkEs9eIYVh4ma/KzTZdynzvR xRASeGradU610fU286LveGdoPUODiSWPFyALBVXMmwatIMERYOH/WCRXOjIVSmh633Dg nLs+lfuTo/h8niYF+SVY4Zmfa9Qgk6G8iXEDAXlPRYiDy9LRCQeYx6WzGVQwPgGPr38B Awp/IRaA+VNM8NI39ENx7IC3Sf+Z5NsSbwDNwJpt63zNOk46g7bklfg6nU9qkq/e/esh /5dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@digitalocean.com header.s=google header.b=LyEFbdwU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=digitalocean.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x13si16201642pll.96.2019.04.23.09.20.03; Tue, 23 Apr 2019 09:20:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@digitalocean.com header.s=google header.b=LyEFbdwU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=digitalocean.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728742AbfDWQS5 (ORCPT + 99 others); Tue, 23 Apr 2019 12:18:57 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:51124 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728712AbfDWQSx (ORCPT ); Tue, 23 Apr 2019 12:18:53 -0400 Received: by mail-it1-f194.google.com with SMTP id q14so1166606itk.0 for ; Tue, 23 Apr 2019 09:18:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digitalocean.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=EtZk3SeeXKQqkXCHRONf08T07XQMFClawAltZ/fWtIE=; b=LyEFbdwUCN5y5Ma4NDSi1pXikJqvX6wSnD3zS+PmORAbo5Qpf+5mixZHhsuHt93w5I Z79S9H9aqMQHGoisIff9QbcAIAHLdsZHjozPg7GZYbM8SjFr1/P/lA9ZlE/cD6+2HS6i UtaZOiylH/6QUdqvj6Tr7RnKNn2mbgNPT+bPQ= 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:in-reply-to:references; bh=EtZk3SeeXKQqkXCHRONf08T07XQMFClawAltZ/fWtIE=; b=e0Ue96ldg0BT6QS3SUAwabxwnHAfgvBBghu4I3dlRT8Pm2+5fii3mrSq4FsAQP4W5a p/9KwEyx4+kNJ0xbmvOvND59XPF3+uEmvAoUsK+72Yw532T+rWKM+aJJHojkD+tLdzIN WCk40lXAcu0H0JamkkppBc4p6rGK1D8n5g541dJgbVqbkxS1U4oWfcU0u2YV4MTYpa2G Q8x1XXRYbNNxLwRxbPixlM208ygikk23DqVQYRTYUqO3a/BQrllV6LE7M7OtBh/5Utqg Xk6Y29XfzWV+/sOH8Rq86zrMzYujJqGzimlcNbIUKJ4PtsIWk+Q00RINjo2FVvSwBXGN DwrA== X-Gm-Message-State: APjAAAWMb7cu702whgbOKBppCaQU+2T9v7liy7SRBowFhfFx9CzfoSq1 qWFjzJfehZpXI1KJvl8lg0b9XQ== X-Received: by 2002:a24:e48d:: with SMTP id o135mr2609305ith.132.1556036332936; Tue, 23 Apr 2019 09:18:52 -0700 (PDT) Received: from swap-tester ([178.128.225.14]) by smtp.gmail.com with ESMTPSA id q12sm2603362iog.85.2019.04.23.09.18.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Apr 2019 09:18:52 -0700 (PDT) From: Vineeth Remanan Pillai To: Nishanth Aravamudan , Julien Desfossez , Peter Zijlstra , Tim Chen , mingo@kernel.org, tglx@linutronix.de, pjt@google.com, torvalds@linux-foundation.org Cc: linux-kernel@vger.kernel.org, subhra.mazumdar@oracle.com, fweisbec@gmail.com, keescook@chromium.org, kerrnel@google.com, Phil Auld , Aaron Lu , Aubrey Li , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini Subject: [RFC PATCH v2 12/17] sched: A quick and dirty cgroup tagging interface Date: Tue, 23 Apr 2019 16:18:17 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra (Intel) Marks all tasks in a cgroup as matching for core-scheduling. Signed-off-by: Peter Zijlstra (Intel) --- kernel/sched/core.c | 62 ++++++++++++++++++++++++++++++++++++++++++++ kernel/sched/sched.h | 4 +++ 2 files changed, 66 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 5066a1493acf..e5bdc1c4d8d7 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6658,6 +6658,15 @@ static void sched_change_group(struct task_struct *tsk, int type) tg = container_of(task_css_check(tsk, cpu_cgrp_id, true), struct task_group, css); tg = autogroup_task_group(tsk, tg); + +#ifdef CONFIG_SCHED_CORE + if ((unsigned long)tsk->sched_task_group == tsk->core_cookie) + tsk->core_cookie = 0UL; + + if (tg->tagged /* && !tsk->core_cookie ? */) + tsk->core_cookie = (unsigned long)tg; +#endif + tsk->sched_task_group = tg; #ifdef CONFIG_FAIR_GROUP_SCHED @@ -7117,6 +7126,43 @@ static u64 cpu_rt_period_read_uint(struct cgroup_subsys_state *css, } #endif /* CONFIG_RT_GROUP_SCHED */ +#ifdef CONFIG_SCHED_CORE +static u64 cpu_core_tag_read_u64(struct cgroup_subsys_state *css, struct cftype *cft) +{ + struct task_group *tg = css_tg(css); + + return !!tg->tagged; +} + +static int cpu_core_tag_write_u64(struct cgroup_subsys_state *css, struct cftype *cft, u64 val) +{ + struct task_group *tg = css_tg(css); + struct css_task_iter it; + struct task_struct *p; + + if (val > 1) + return -ERANGE; + + if (tg->tagged == !!val) + return 0; + + tg->tagged = !!val; + + if (!!val) + sched_core_get(); + + css_task_iter_start(css, 0, &it); + while ((p = css_task_iter_next(&it))) + p->core_cookie = !!val ? (unsigned long)tg : 0UL; + css_task_iter_end(&it); + + if (!val) + sched_core_put(); + + return 0; +} +#endif + static struct cftype cpu_legacy_files[] = { #ifdef CONFIG_FAIR_GROUP_SCHED { @@ -7152,6 +7198,14 @@ static struct cftype cpu_legacy_files[] = { .read_u64 = cpu_rt_period_read_uint, .write_u64 = cpu_rt_period_write_uint, }, +#endif +#ifdef CONFIG_SCHED_CORE + { + .name = "tag", + .flags = CFTYPE_NOT_ON_ROOT, + .read_u64 = cpu_core_tag_read_u64, + .write_u64 = cpu_core_tag_write_u64, + }, #endif { } /* Terminate */ }; @@ -7319,6 +7373,14 @@ static struct cftype cpu_files[] = { .seq_show = cpu_max_show, .write = cpu_max_write, }, +#endif +#ifdef CONFIG_SCHED_CORE + { + .name = "tag", + .flags = CFTYPE_NOT_ON_ROOT, + .read_u64 = cpu_core_tag_read_u64, + .write_u64 = cpu_core_tag_write_u64, + }, #endif { } /* terminate */ }; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 42dd620797d7..16fb236eab7b 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -363,6 +363,10 @@ struct cfs_bandwidth { struct task_group { struct cgroup_subsys_state css; +#ifdef CONFIG_SCHED_CORE + int tagged; +#endif + #ifdef CONFIG_FAIR_GROUP_SCHED /* schedulable entities of this group on each CPU */ struct sched_entity **se; -- 2.17.1