From patchwork Thu Apr 13 12:01:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 9679249 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B570B60326 for ; Thu, 13 Apr 2017 12:02:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6C6B27FAD for ; Thu, 13 Apr 2017 12:02:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B17B285FE; Thu, 13 Apr 2017 12:02:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 329AF27FAD for ; Thu, 13 Apr 2017 12:02:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752610AbdDMMCM (ORCPT ); Thu, 13 Apr 2017 08:02:12 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:37582 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752250AbdDMMCL (ORCPT ); Thu, 13 Apr 2017 08:02:11 -0400 Received: from localhost ([127.0.0.1]) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1cydQV-0003KQ-8m; Thu, 13 Apr 2017 14:00:39 +0200 Date: Thu, 13 Apr 2017 14:01:42 +0200 (CEST) From: Thomas Gleixner To: Peter Zijlstra cc: LKML , Ingo Molnar , Sebastian Siewior , Benjamin Herrenschmidt , "David S. Miller" , Fenghua Yu , Herbert Xu , Lai Jiangshan , Len Brown , Michael Ellerman , "Rafael J. Wysocki" , Tejun Heo , Tony Luck , Viresh Kumar , linux-acpi@vger.kernel.org Subject: Re: [patch 08/13] ACPI/processor: Replace racy task affinity logic. In-Reply-To: <20170413113945.mkdsk24rovzcrod6@hirez.programming.kicks-ass.net> Message-ID: References: <20170412200726.941336635@linutronix.de> <20170412201042.785920903@linutronix.de> <20170413113945.mkdsk24rovzcrod6@hirez.programming.kicks-ass.net> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, 13 Apr 2017, Peter Zijlstra wrote: > > That makes my machine sad... > [ 9.786610] work_on_cpu+0x82/0x90 > [ 9.790404] ? __usermodehelper_disable+0x110/0x110 > [ 9.795846] ? __acpi_processor_get_throttling+0x20/0x20 > [ 9.801773] acpi_processor_set_throttling+0x199/0x220 > [ 9.807506] ? trace_hardirqs_on_caller+0xfb/0x1d0 > [ 9.812851] acpi_processor_get_throttling_ptc+0xec/0x180 > [ 9.818876] __acpi_processor_get_throttling+0xf/0x20 > [ 9.824511] work_for_cpu_fn+0x14/0x20 > [ 9.828692] process_one_work+0x261/0x670 > [ 9.833165] worker_thread+0x21b/0x3f0 > [ 9.837348] kthread+0x108/0x140 > [ 9.840947] ? process_one_work+0x670/0x670 > [ 9.845611] ? kthread_create_on_node+0x40/0x40 > [ 9.850667] ret_from_fork+0x31/0x40 Yuck. So the call chain is: acpi_processor_get_throttling() work_on_cpu(acpi_processor_get_throttling) That work does: __acpi_processor_get_throttling() acpi_processor_get_throttling_ptc() acpi_processor_set_throttling() work_on_cpu(__acpi_processor_set_throttling) Why the heck calls a get_throttling() function set_throttling()? I'm mildly surprised. Does the delta patch below cure the problem? Thanks, tglx 8<-------------- --- 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 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c @@ -62,8 +62,8 @@ struct acpi_processor_throttling_arg { #define THROTTLING_POSTCHANGE (2) static int acpi_processor_get_throttling(struct acpi_processor *pr); -int acpi_processor_set_throttling(struct acpi_processor *pr, - int state, bool force); +static int __acpi_processor_set_throttling(struct acpi_processor *pr, + int state, bool force, bool direct); static int acpi_processor_update_tsd_coord(void) { @@ -891,7 +891,8 @@ static int acpi_processor_get_throttling ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Invalid throttling state, reset\n")); state = 0; - ret = acpi_processor_set_throttling(pr, state, true); + ret = __acpi_processor_set_throttling(pr, state, true, + true); if (ret) return ret; } @@ -1075,8 +1076,15 @@ static long acpi_processor_throttling_fn arg->target_state, arg->force); } -int acpi_processor_set_throttling(struct acpi_processor *pr, - int state, bool force) +static int call_on_cpu(int cpu, long (*fn)(void *), void *arg, bool direct) +{ + if (direct) + return fn(arg); + return work_on_cpu(cpu, fn, arg); +} + +static int __acpi_processor_set_throttling(struct acpi_processor *pr, + int state, bool force, bool direct) { int ret = 0; unsigned int i; @@ -1125,7 +1133,8 @@ int acpi_processor_set_throttling(struct arg.pr = pr; arg.target_state = state; arg.force = force; - ret = work_on_cpu(pr->id, acpi_processor_throttling_fn, &arg); + ret = call_on_cpu(pr->id, acpi_processor_throttling_fn, &arg, + direct); } else { /* * When the T-state coordination is SW_ALL or HW_ALL, @@ -1158,8 +1167,8 @@ int acpi_processor_set_throttling(struct arg.pr = match_pr; arg.target_state = state; arg.force = force; - ret = work_on_cpu(pr->id, acpi_processor_throttling_fn, - &arg); + ret = call_on_cpu(pr->id, acpi_processor_throttling_fn, + &arg, direct); } } /* @@ -1177,6 +1186,12 @@ int acpi_processor_set_throttling(struct return ret; } +int acpi_processor_set_throttling(struct acpi_processor *pr, int state, + bool force) +{ + return __acpi_processor_set_throttling(pr, state, force, false); +} + int acpi_processor_get_throttling_info(struct acpi_processor *pr) { int result = 0;