Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4818321imm; Mon, 14 May 2018 13:44:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrfFdCt+gHCW/1Ut+sn3Hd9UXQ8tIAtazkHc15b+jCulm++SqFdzd/Aa73P5qWGqYc3wX+4 X-Received: by 2002:a17:902:9303:: with SMTP id bc3-v6mr11259715plb.18.1526330652121; Mon, 14 May 2018 13:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526330652; cv=none; d=google.com; s=arc-20160816; b=ra25kVizzdYMFS78Fvl4DitCOks7Q7rHxjL7Mskn1HYBVMvNXu3LzG/FtbIRdHy9yd CxJsl1CNAspPK8w6jn+CVMDplHmkT9XZk8j15dGnXuvZSvQ488Ruir+0Ks3OP3jxepPA K5S75cLbrPNRmQwBeLqJt3b5m9f7+3G5/v7hMILThNXcxI9B9vJOtlue/r4djxedBVAv 3HZH+auIuXDMfhGBn+b465P86vsYFN2KGYSuk84Z3ngtoy3PWRbzOhQyevRpoQ+xMXcO yJjaDlDI3jNjV7oIN2joGqe8C0v3RZi2xAAHaQ2bj9lNRRmcVeUXFv3t5Ws0td+tF/6q Ficw== 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 :arc-authentication-results; bh=nEFqHNYeI0KlUDUdgi9RHcGB0lyThjEHxVRzoBJE/f0=; b=xlh3Ev0bR302Qy71L1/HYghgvqzKW6cnqaGYQcG6TuPPj+EviThc8fuKKL6lfmg1vN oRl+UDlfKJcwL7s9iLhyMPW5MCXUS8BoEueNnx+6QExVCqiQOkUDnZ2aqhrUY9rk9lag 4Ks9GB031uLqLHZEt0HDpTH1U7d3CVcsBSbd1nqgHKN3d5VYKF8R5TswHeFiJgDI+83O RBcOo9PSAXPJayOqE2oSuDS/2CTh2fNh6v6tgOD74itP6c6qiF/EEL8P3JyvP4mN4kIS GoeYbFLXWLpyX/ERKZ6skUrUaj4+171DObAZd2V9+Qsx01/kdr12GwVpowSE1vbQpyCi 7jsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=KK7MOHmY; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z9-v6si10933360plk.94.2018.05.14.13.43.57; Mon, 14 May 2018 13:44:12 -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=fail header.i=@gmail.com header.s=20161025 header.b=KK7MOHmY; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752132AbeENUmI (ORCPT + 99 others); Mon, 14 May 2018 16:42:08 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:38583 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751865AbeENUmF (ORCPT ); Mon, 14 May 2018 16:42:05 -0400 Received: by mail-oi0-f66.google.com with SMTP id k17-v6so11974797oih.5; Mon, 14 May 2018 13:42:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=nEFqHNYeI0KlUDUdgi9RHcGB0lyThjEHxVRzoBJE/f0=; b=KK7MOHmYZ+5J5NcVKTPdoTbn0EYs01uciK3r/5TLHxo7XNa2/4VdhRhvoTrgGjGdqQ 38pCdNuDXdHOb2RPsem+jqfPwyvxo0NGQJq9mU+nU/AWuuUoXNJDvR20EGbD9mrtFZtd Co34MeCtftudmWnHdvMyFQSzu2B4RV+R27EYeRPodv5+QrojRbSmPUIiv3vExG1B77og mfOqX/LlBzF2y4EovZBuLMkH94oHCh6xBB/vB0FTdbErkL2qTQ5Rk0BSjoiTHx/z0mWb BDRiNurr0K7c+Bq6KbSYedNbB0NA6LKmr5JbYrVS782XkUiU56/+61z1Th/kAHccqWL/ 2S5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=nEFqHNYeI0KlUDUdgi9RHcGB0lyThjEHxVRzoBJE/f0=; b=sIQkQK3gglJ41jktTyYFIMNCDjL9b+rud9GnUxkESrgHeiRVgiVgrAxd7FNp38GPB2 V5EqSVtNdwzw/cEYFYRYRmOVcgrGOxOzCCDR4xDCFavkJp0IgKo0wnNW7AxUQAIEqhSF SH9LBpu+nqC9b3D67Zdtvwz/eVqZ4QTTcUwFAZ8JpVXrZdZfTo8P1zfjnz23jkvEuCKt NWU/w9879XLeLkrSMa3x4ZKZqBZZwfLFfwoL6xip+W3wYS9ccMurA0jBIyrEKniVYEqE Zu2xE8WYZuJDhW/6/gF7Ji2Mo/QPEI4VWFVOB2kWOGtIU1FA579HMRWxQnB16Ya9hhiC djCQ== X-Gm-Message-State: ALKqPwcUnSYXBtYJq1eWbc2bnFUSXopV6lyaKwBI6nsNB7IUpxZTmeow /PfTByapN4QN/qvNDht5VZXSvtMFreYgpdptnEQ= X-Received: by 2002:aca:5c89:: with SMTP id q131-v6mr7159695oib.154.1526330525253; Mon, 14 May 2018 13:42:05 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:1468:0:0:0:0:0 with HTTP; Mon, 14 May 2018 13:42:04 -0700 (PDT) In-Reply-To: <20180514154523.GA17331@sandybridge-desktop> References: <1525521202-32519-1-git-send-email-yu.c.chen@intel.com> <8775668.fKKdjnIWAU@aspire.rjw.lan> <20180514154523.GA17331@sandybridge-desktop> From: "Rafael J. Wysocki" Date: Mon, 14 May 2018 22:42:04 +0200 X-Google-Sender-Auth: yqtFKdx6wwZJ8hsMvYvCCX7Mgiw Message-ID: Subject: Re: [PATCH][RFC v2] ACPI: acpi_pad: Do not launch acpi_pad threads on idle cpus To: Yu Chen Cc: "Rafael J. Wysocki" , Len Brown , Linux Kernel Mailing List , Lenny Szubowicz , Jacob Pan , Rui Zhang , ACPI Devel Maling List 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 Mon, May 14, 2018 at 5:45 PM, Yu Chen wrote: > On Sun, May 13, 2018 at 11:30:52AM +0200, Rafael J. Wysocki wrote: >> On Saturday, May 5, 2018 1:53:22 PM CEST Chen Yu wrote: >> > According to current implementation of acpi_pad driver, >> > it does not make sense to spawn any power saving threads >> > on the cpus which are already idle - it might bring >> > unnecessary overhead on these idle cpus and causes power >> > waste. So verify the condition that if the number of 'busy' >> > cpus exceeds the amount of the 'forced idle' cpus is met. >> > This is applicable due to round-robin attribute of the >> > power saving threads, otherwise ignore the setting/ACPI >> > notification. >> >> OK, but CPUs are busy, because they are running tasks. If acpi_pad >> kthreads run on them, the tasks they are running will migrate to the >> currently idle CPUs (unless they have specific CPU affinity) and the >> throttling will not really be effective. >> > OK, I think this makes sense, I missed the load balance scenario. > >> I would think that acpi_pad should ensure that the requested number of >> CPUs will not run anything other than throttling kthreads. Isn't that >> the case? >> > Do you mean, we should check if the number of 'idle'(rather than the 'busy' one > in this patch) cpus is larger than the requested one? What I really meant was that acpi_pad kthreads should be started on as many CPUs as requested by the firmware to prevent anything else from running on them. > Then I think we should also add a patch to use the play_idle() as power_clamp to treat > the throttling kthreads as idle threads thus to stop system tick. Yes, we should. > Such as the patch Jacob proposed: Looks OK from a quick glance, but I'll have a deeper look at it tomorrow. > Index: linux/drivers/acpi/acpi_pad.c > =================================================================== > --- linux.orig/drivers/acpi/acpi_pad.c > +++ linux/drivers/acpi/acpi_pad.c > @@ -144,7 +144,6 @@ static unsigned int round_robin_time = 1 > static int power_saving_thread(void *data) > { > struct sched_param param = {.sched_priority = 1}; > - int do_sleep; > unsigned int tsk_index = (unsigned long)data; > u64 last_jiffies = 0; > > @@ -160,33 +159,13 @@ static int power_saving_thread(void *dat > round_robin_cpu(tsk_index); > } > > - do_sleep = 0; > - > - expire_time = jiffies + HZ * (100 - idle_pct) / 100; > - > - while (!need_resched()) { > - if (tsc_detected_unstable && !tsc_marked_unstable) { > - /* TSC could halt in idle, so notify users */ > - mark_tsc_unstable("TSC halts in idle"); > - tsc_marked_unstable = 1; > - } > - local_irq_disable(); > - tick_broadcast_enable(); > - tick_broadcast_enter(); > - stop_critical_timings(); > - > - mwait_idle_with_hints(power_saving_mwait_eax, 1); > - > - start_critical_timings(); > - tick_broadcast_exit(); > - local_irq_enable(); > - > - if (time_before(expire_time, jiffies)) { > - do_sleep = 1; > - break; > - } > + if (tsc_detected_unstable && !tsc_marked_unstable) { > + /* TSC could halt in idle, so notify users */ > + mark_tsc_unstable("TSC halts in idle"); > + tsc_marked_unstable = 1; > } > > + play_idle(jiffies_to_msecs(HZ * (100 - idle_pct) / 100)); > /* > * current sched_rt has threshold for rt task running time. > * When a rt task uses 95% CPU time, the rt thread will be > @@ -196,8 +175,7 @@ static int power_saving_thread(void *dat > * borrow CPU time from this CPU and cause RT task use > 95% > * CPU time. To make 'avoid starvation' work, takes a nap here. > */ > - if (unlikely(do_sleep)) > - schedule_timeout_killable(HZ * idle_pct / 100); > + schedule_timeout_killable(HZ * idle_pct / 100); > > /* If an external event has set the need_resched flag, then > * we need to deal with it, or this loop will continue to >> Thanks, >> Rafael >> > -- > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html