Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5638763imm; Wed, 12 Sep 2018 08:54:29 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYrVRZvFxCSovHRjbukPWkxRLFVAx0brvkIsU0WjguXRpdcr5uqtwB+YVSIE2beWUGDtwPe X-Received: by 2002:aa7:800f:: with SMTP id j15-v6mr3130667pfi.174.1536767669751; Wed, 12 Sep 2018 08:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536767669; cv=none; d=google.com; s=arc-20160816; b=RkGq4qEGUYXN5WE+JHRT/+3agjTG5XyLxypfd5rhB0y1Oy7CB1nwlfud2vEuDdN6m7 A61Bd7eIKqR/gfeG+13xPgT1H1t9oWDfOmNh6Btn1MeUt2rDjWICZo1GPSj4ym8BivjV 8cZIkoSA++cMYyZd7O0CrIG1iBjYZSz39j7p5U106fEcgOr0pswEwcF+O/uXD9J4Q63W 4j/KlMg+nF/pDiHSGLfP9201LuUd7UoxpLat6xxydKkQBM9uUf8xCbHnDtFiQwDAdg8E yTGZbVw9K0+fGJtRyTKm/K7R/s3hc1yCn76y5kdLzn2faSfftzAYfsD06Elzt9DINKot rCvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=vMxjIYsPT62Ms5PO71zSuZ7sdybICRm7CloYVdoetH8=; b=sh8EejCSTySyo7RhBpFY3ZIuis41mQapmlj34TMdU6WzIA2ibf1IiANnOUF0mwIF1V oPva7OIhXUVZUxa2OmAZm38c+QWj1B3mipbHX47Idu0c8tCKlr0X2SXEDW6IrkGujYwd lBaqyRm/zsPHf9s4oz6I8nC5zswmu1dIR6dESjgml/NRNyZOZ9SkXOWyeviuAZ1NzGLs RP7Jv2wUFsBD82d3GIujOi8GLOUiV3rt1AKPGRB2pZHSmDeHWqWjHXmVwoO2B/WT94AB BwfMnvmh/wjjVZhyfyi2PYu61Cb/EP9szUKcrc0L3jt8fRiv8GqRXahQPAvu7+60INpV sxBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=U5+TY7FH; 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=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o18-v6si1386895pgn.190.2018.09.12.08.54.13; Wed, 12 Sep 2018 08:54:29 -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=@google.com header.s=20161025 header.b=U5+TY7FH; 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=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727648AbeILU6t (ORCPT + 99 others); Wed, 12 Sep 2018 16:58:49 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:38930 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726640AbeILU6t (ORCPT ); Wed, 12 Sep 2018 16:58:49 -0400 Received: by mail-wm0-f68.google.com with SMTP id q8-v6so3006609wmq.4 for ; Wed, 12 Sep 2018 08:53:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=vMxjIYsPT62Ms5PO71zSuZ7sdybICRm7CloYVdoetH8=; b=U5+TY7FH6U4qKmynhZ7b2YcrxoenltWnVoFkYxt/wtufwK2jk5FhmA5Flm2EcuQBIf tD4ktfwffleNFMNiGW1HmIZDLHmv3t608ip0qiyzL0/zO/SS/i59yGwNQEdFSsaZN2C5 jijgcCaxH40y1FWe95Ey7JbYV/mYVAzxDVM2gTNoJLVAAK7OoJDmcNyY55BcEWMmC1Aj 7vKh4tcxDkiZu1S8wEnjRnU3mSch3qglAGEqm3uGq1CVakIqEOug3YnfxoTQJ4ubT9+Y t4d7Ly/OIwHt9gKsu0YDlX4SVX37ArCZycAo2hbyyu4vROlTwvQ+Nrj+VrhIYI2PMTF4 HlTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=vMxjIYsPT62Ms5PO71zSuZ7sdybICRm7CloYVdoetH8=; b=WAD+Jez0pkjOFI6ubI7Z5EZNdwhG0A1aJrvThyKXav0qglWhM6mWutAJG2xPD9ad0c 3pd3AG6RtFRXkYfHiT4SkF+F5gIYVI8Qf47z88jtWeqFFy6XgKgRWUSorVk2ilmw4s/g SUvSPRZg4bCQ9LVuhXXWm5kSguADmJqwk4+tCufgKT6t9KLhrbpAcc6yWt4ov7eVo/wF 4T9mUVVGjZbznye7Fx3evUcfC/EUk5GPgf1vjNMQyGS/OJTpJ6Dpu86qb2w0xFtBz05y OXMwOKBQhXAgNG5vWASHMyVdLwfmqLNEygKvb9yK+96Ic9bktISIcBHQjZi1sOTsP7gL KQ1g== X-Gm-Message-State: APzg51DdZeClajnHKswUDSs0GbszGZjtOthH3fKm1Y4J4f7BsXN0IWw7 zsvviEEKUO49TSh+GzvKXL6U+2Xa88RJ0p9suc40/O8V X-Received: by 2002:a1c:a8d0:: with SMTP id r199-v6mr2072370wme.97.1536767620370; Wed, 12 Sep 2018 08:53:40 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:adf:c710:0:0:0:0:0 with HTTP; Wed, 12 Sep 2018 08:53:39 -0700 (PDT) In-Reply-To: <20180912141923.GF1413@e110439-lin> References: <20180828135324.21976-1-patrick.bellasi@arm.com> <20180828135324.21976-10-patrick.bellasi@arm.com> <20180912141923.GF1413@e110439-lin> From: Suren Baghdasaryan Date: Wed, 12 Sep 2018 08:53:39 -0700 Message-ID: Subject: Re: [PATCH v4 09/16] sched/core: uclamp: map TG's clamp values into CPU's clamp groups To: Patrick Bellasi Cc: LKML , linux-pm@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Tejun Heo , "Rafael J . Wysocki" , Viresh Kumar , Vincent Guittot , Paul Turner , Quentin Perret , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 12, 2018 at 7:19 AM, Patrick Bellasi wrote: > On 09-Sep 11:52, Suren Baghdasaryan wrote: >> On Tue, Aug 28, 2018 at 6:53 AM, Patrick Bellasi >> wrote: > > [...] > >> > +/** >> > + * release_uclamp_sched_group: release utilization clamp references of a TG >> >> free_uclamp_sched_group > > +1 > >> > + * @tg: the task group being removed >> > + * >> > + * An empty task group can be removed only when it has no more tasks or child >> > + * groups. This means that we can also safely release all the reference >> > + * counting to clamp groups. >> > + */ >> > +static inline void free_uclamp_sched_group(struct task_group *tg) >> > +{ > > [...] > >> > @@ -1417,9 +1444,18 @@ static void __init init_uclamp(void) >> > #ifdef CONFIG_UCLAMP_TASK_GROUP >> > /* Init root TG's clamp group */ >> > uc_se = &root_task_group.uclamp[clamp_id]; >> > + >> > uc_se->effective.value = uclamp_none(clamp_id); >> > - uc_se->value = uclamp_none(clamp_id); >> > - uc_se->group_id = 0; >> > + uc_se->effective.group_id = 0; >> > + >> > + /* >> > + * The max utilization is always allowed for both clamps. >> > + * This is required to not force a null minimum utiliation on >> > + * all child groups. >> > + */ >> > + uc_se->group_id = UCLAMP_NOT_VALID; >> > + uclamp_group_get(NULL, clamp_id, 0, uc_se, >> > + uclamp_none(UCLAMP_MAX)); >> >> I don't quite get why you are using uclamp_none(UCLAMP_MAX) for both >> UCLAMP_MIN and UCLAMP_MAX clamps. I assume the comment above is to >> explain this but I'm still unclear why this is done. > > That's maybe a bit tricky to get but, this will not happen since for > root group tasks we apply the system default values... which however > are introduced by one of the following patches 11/16. > > So, my understanding of the "delegation model" is that for cgroups we > have to ensure each TG is a "restriction" of its parent. Thus: > > tg::util_min <= tg_parent::util_min > > This is required to ensure that a tg_parent can always restrict > resources on its descendants. I guess that's required to have a sane > usage of CGroups for VMs where the Host can transparently control its > Guests. > > According to the above rule, and considering that root task group > cannot be modified, to allow boosting on TG we are forced to set the > root group with util_min = SCHED_CAPACITY_SCALE. > > Moreover, Tejun pointed out that if we need tuning at root TG level, > it means that we need system wide tunable, which should be available > also when CGroups are not in use. > > That's why on patch: > > [PATCH v4 11/16] sched/core: uclamp: add system default clamps > https://lore.kernel.org/lkml/20180828135324.21976-12-patrick.bellasi@arm.com/ > > we add the concept of system default clamps which are actually > initialized with util_min=0, i.e. 0% boost by default. > > These system default clamp values applies to tasks which are running > either in the root task group on in an autogroup, which also cannot be > tuned at run-time, whenever the task has not a task specific clamp > value specified. > > All that considered, the code above is still confusing and I should > consider moving to patch 11/16 the initialization to UCLAMP_MAX for > util_min... > >> Maybe expand the comment to explain the intention? > > ... and add there something like: > > /* > * The max utilization is always allowed for both clamps. > * This satisfies the "delegation model" required by CGroups > * v2, where a child task group cannot have more resources then > * its father, thus allowing the creation of child groups with > * a non null util_min. > * For tasks within the root_task_group we will use the system > * default clamp values anyway, thus they will not be boosted > * to the max utilization by default. > */ > > It this more clear ? Yes, I think so. Thanks for covering that. > > >> With this I think all TGs will get boosted by default, won't they? > > You right, at cgroup creation time we clone parent's clamps... thus, > all root_task_group's children group will get max boosting at creation > time. However, since we don't have task within a newly created task > group, the system management software can still refine the clamps > before staring to move tasks in there. > > Do you think we should initialize root task group childrens > differently ? I would prefer to avoid special cases if not strictly > required... I don't see a problem with the current approach. > > Cheers, > Patrick > > -- > #include > > Patrick Bellasi