Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2298057ybl; Sat, 25 Jan 2020 22:45:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwYiiC+5NvInCn0AFAUNWIR7Hpi+l6mlUZHTDdAIb9DtjJFe8W3b/khf3SjwuPb75AoC2Zh X-Received: by 2002:a9d:2028:: with SMTP id n37mr8727703ota.127.1580021155724; Sat, 25 Jan 2020 22:45:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580021155; cv=none; d=google.com; s=arc-20160816; b=E47lateihP3P9koQF8PsQhfT3vWF+stIpiJZAZGsqbaS+TAhbVEVgqYhnIiNRqAZAv v9Uv7uAlHO9X0i/DWmnjqX+/4ahY/AgRbLdDX7aeH9tqR+NbOPO4gzMWMNLpmg8n4HZ9 pwdRKno0UBnVrjV+dzIwFnrMV+GoSSMAq8Ypx4KF6abrFg6yN27bk3DIbnEMlMJbrmse f/cNoEdW8gabL+ryhQ98WnxXqjvnQQbYMCG7n69WxXYvHZ48XZgjjpBbztMwdhDqAoep p0XfvvRO0YwQ1H+RVxTtUAZ0Cz6RQMaqF2WNQlzDbJdK27borhwhMnrUbKaZYr6dzAYc yisw== 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 :in-reply-to:references:mime-version:dkim-signature; bh=5C28FWFmtkB52uEIeP3Jlf3NfYS9TEO0X+j3iCrN7vk=; b=k8DaKxNxFzzp5N1Igl0ytdmKvI3hVj6PSfD0SU0Tr38x54sUOEAU+tYEHPt52F/s1U EfFM04QAzdmNZzzx50fUSdLCYalsFiDiciRUg0f6EFTUEMGJeP5RvGF9ukWEWAfdkvI6 Vkazeksz1B/QJTjrm/raMT6mD0Zz2pD8OixJrnn1jwDsBOenTojJQH5X1AyUwiZQYOFH tIWeXJqedViG8r9Pr5O19/YYFwDeawGUQqJSCDbjaBRnL1wYFtEBEWq6AzE0hZ6JjMB0 efzrCRjkNqXYdbWuSUQbd07fFTCu3WlPJ5K5GWRZ2RwzS0mlxCGLcLEHPp9rjNjqcN2x nU0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VwAfuCGK; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t23si5484333otk.304.2020.01.25.22.45.07; Sat, 25 Jan 2020 22:45:55 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=VwAfuCGK; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726426AbgAZGlw (ORCPT + 99 others); Sun, 26 Jan 2020 01:41:52 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:35907 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726098AbgAZGlw (ORCPT ); Sun, 26 Jan 2020 01:41:52 -0500 Received: by mail-lf1-f65.google.com with SMTP id f24so4030268lfh.3 for ; Sat, 25 Jan 2020 22:41:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5C28FWFmtkB52uEIeP3Jlf3NfYS9TEO0X+j3iCrN7vk=; b=VwAfuCGK7dXmdgy4VgKXiclK866t47Gl1YYdvqp+K4j9JqL/fJ/FXC35OdhlfTa5MO NuPhd2wumA8iedA+5pk4t83qOKxYYlEzml+fPNjgQts2u7GwLeJ9Ofn1NvvnuTbIJiqY eAJvtUrYtGQd2TK8EBn07GAfvebsdImNJDPlBntiE84LY97gxIzDmPTa1vxW4IINZ55b /YYbp6w197Qa4wpZyVsaSwPjoa1UoBpV8oSzy4DYtCwpfDxjkYzPspGEO2npawPAfScd 64x4Ym1Vt/iN7KP4ptHV+a6c+aUWEEJNZfVItpQvpNZDXk3Cxt/CSBP6C4lwxGnmGm7a OYbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5C28FWFmtkB52uEIeP3Jlf3NfYS9TEO0X+j3iCrN7vk=; b=F+wMEUN0J+npUUlNjF+A2UJEt6Sk58eK87jUs9DymRbEWroaPYNjsz3VavtIUSXKVJ /wdAeM5d7Wj5U1N7U/jvaBATI3vnNYaNcI1HSEjwaJmJ4+uucNn654HB/S9G4xJCoxbD gIhQEwYIwmRJ4hqvq9rZ224pm+980eCHnqALoAf4Dt9QpMf2/ptYj08rcRveVycGJRsH YUA1PM0XVMURup+JMg4NW/fyxaza9RQFL22S5d/q7x+h/iHI1LBycjKXccST49jyuC7G 88BEs1fv0QxWppTnknCDy4N9hEgvLAQrVd++oIOdMu3Y86j/gcSDZnuuGkNa0oLRTY4s DkAg== X-Gm-Message-State: APjAAAWTzI6xN8KbYvfRvX3e0cyw7VmsUvPkzIjetWmjXO4C2lD/1mmP TzZGEVJP96iJThnakNUfheLvArIMfBgqm53bH7Y= X-Received: by 2002:ac2:599c:: with SMTP id w28mr5299421lfn.78.1580020910045; Sat, 25 Jan 2020 22:41:50 -0800 (PST) MIME-Version: 1.0 References: <20200124002811.228334-1-wvw@google.com> <20200124025238.jsf36n6w4rrn2ehc@e107158-lin> <20200124095125.GA121494@google.com> <849cc9f0-f4ae-f2b6-8449-f55697928cf5@arm.com> <20200124113050.i6ovkibcmutypm3q@e107158-lin> <20200125235934.wrs2nryuk3wmtkxr@e107158-lin> In-Reply-To: <20200125235934.wrs2nryuk3wmtkxr@e107158-lin> From: Wei Wang Date: Sat, 25 Jan 2020 22:41:14 -0800 Message-ID: Subject: Re: [PATCH] [RFC] sched: restrict iowait boost for boosted task only To: Qais Yousef Cc: Wei Wang , Valentin Schneider , Quentin Perret , dietmar.eggemann@arm.com, chris.redpath@arm.com, Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Steven Rostedt , Ben Segall , Mel Gorman , LKML 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 Sat, Jan 25, 2020 at 3:59 PM Qais Yousef wrote: > > On 01/24/20 12:55, Wei Wang wrote: > > > > So I'm pretty sure we *do* want tasks with the default clamps to get iowait > > > > boost'd. What we don't want are background tasks driving up the frequency, > > > > and that should be via uclamp.max (as Quentin is suggesting) rather than > > > > uclamp.min (as is suggested in the patch). > > > > > > > > Now, whether that is overloading the usage of uclamp... I'm not sure. > > > > One of the argument for uclamp was actually frequency selection, so if > > > > we just make iowait boost respect that, IOW not boost further than > > > > uclamp.max (which is a bit better than a simple on/off switch), that > > > > wouldn't be too crazy I think. > > > > > > Capping iowait boost value in schedutil based on uclamp makes sense indeed. > > > > > > What didn't make sense to me is the use of uclamp as a switch to toggle iowait > > > boost on/off. > > > > Sounds like we all agree on adding a new toggle, so will move forward > > with that then. > > Looking more closely at iowait boost, it's not actually a generic cpufreq > attribute. Only schedutil and intel_pstate have it. Other governors might > implement something similar but under a different name. > > So I'm not sure how easy it'd be to implement a generic toggle for something > that probably should be considered an implementation detail of a governor and > userspace shouldn't care much about. > > Of course, the maintainers might have a different opinion. So don't let mine > discourage you from pursuing this further! :-) > Indeed, that's why I was hesitate to add the toggle and wanted to bring this up for Android common kernel first. :-) > > For capping iowait boost, it should be a separate patch. I am not sure > > if we want to apply what's the current max clamp on the rq but I do > > see the per-task iowait boost makes sense. > > It is true the 2 patches are orthogonal, but if you already cap the max > frequencies the background task can use, by ensuring the iowait_boost in > schedutil respects the uclamp restrictions then this should solve your problem > too, no? > We haven't tried on 5.4, and there is no uclamp policy placed for background yet. Also I am not sure it is beneficial to do uclamp restriction on those kernel threads (e.g. is f2fs's gc), but that is an interesting experiment on power balance. Also for applying at rq lever, what if there are foreground tasks (and it could be the case sometimes). > The patch below only compile tested. > > > background/cpu.uclamp.max = 200 # Cap background tasks max frequencies > > --- > > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c > index 9b8916fd00a2..a76c02eecdaf 100644 > --- a/kernel/sched/cpufreq_schedutil.c > +++ b/kernel/sched/cpufreq_schedutil.c > @@ -421,7 +421,8 @@ static unsigned long sugov_iowait_apply(struct sugov_cpu *sg_cpu, u64 time, > * into the same scale so we can compare. > */ > boost = (sg_cpu->iowait_boost * max) >> SCHED_CAPACITY_SHIFT; > - return max(boost, util); > + boost = max(boost, util); > + return uclamp_util_with(cpu_rq(sg_cpu->cpu), boost, NULL); > } > > #ifdef CONFIG_NO_HZ_COMMON > > -- > Qais Yousef