Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2539013imm; Mon, 10 Sep 2018 02:45:17 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZRV4LSS6PSJ+ueuxIKXbCyVwT5Q0KpNSADxrQWogLKtV+AgQ5t/3muHQDUC3fExaacxh56 X-Received: by 2002:a62:591a:: with SMTP id n26-v6mr22746534pfb.94.1536572717823; Mon, 10 Sep 2018 02:45:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536572717; cv=none; d=google.com; s=arc-20160816; b=QwYf8iXL1vzP5v+qa8WMRQC+KpwG9uy1R1u14FmK9cL/91giCXOrxcTGjgbxKnX1C/ Anz6/DRvY3iQ4FwK6D18Uu4DkkTOdjkKxFyJbI2+hdRIh+h7BokWEZpVFXjMFzebhPMt fGlE6hU5H7hzT8hvmSv2JoVwWMINan8BtpZYG81SgEtpKO3u7CvfiRbpiXGr00KfXNfg McNZjHVpaDELRUyWFFqcNnlsPhQhJvpMfrUOLQa+SxTUEENvrISOTI0PUA+q0kcYeS/r 6RqIyIurKisJnRH8b7Ib4JKfUS2fYXsn03U/MWF4EkFdmavR2ntBt0tQbrTdNICTwAOR KPpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=I2V0d5IN66sz71/g1O786MtIx9dbB2yi2SqwtZBs03g=; b=NtnTsXkjkGh2/5vW/xHSQgUe6AuSr61GJdOf2z7StGQtPpmAkafHAB8LcGA0x7Cn0z 76zql1saaE3TdT5m+v2q9iihqqPZytEtBwk2CFSpVAXRcFZCPL4IJV2OXCI15FaaJ+f8 lH9hhIOazkS7HWMp4xZZUR4u/0GW2movDFQBroJ/frsqd8kNMHllPQK/PBC7B0JJRtJ4 GQSBfrLCK4N8/gCLZH4tM7QeQv4pbYKBPg+fD8NqYULrR83VqTSGOj6v6KVnZ/xcjmga se60+sZrZhVSlRFUD4OTIiMI+KSKvdlP3MGXv+fqr7JUkJBFGra2EiQBZZeC/1C8xuTF +iYw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w68-v6si16748803pfw.308.2018.09.10.02.45.02; Mon, 10 Sep 2018 02:45:17 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728136AbeIJOgR (ORCPT + 99 others); Mon, 10 Sep 2018 10:36:17 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53984 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727261AbeIJOgR (ORCPT ); Mon, 10 Sep 2018 10:36:17 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A8B6B18A; Mon, 10 Sep 2018 02:43:06 -0700 (PDT) Received: from queper01-lin (queper01-lin.emea.arm.com [10.4.13.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 90D783F557; Mon, 10 Sep 2018 02:43:02 -0700 (PDT) Date: Mon, 10 Sep 2018 10:43:01 +0100 From: Quentin Perret To: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" , Peter Zijlstra , Linux Kernel Mailing List , Linux PM , Greg Kroah-Hartman , Ingo Molnar , Dietmar Eggemann , Morten Rasmussen , Chris Redpath , Patrick Bellasi , Valentin Schneider , Vincent Guittot , Thara Gopinath , Viresh Kumar , Todd Kjos , Joel Fernandes , Steve Muckle , adharmap@codeaurora.org, Saravana Kannan , Pavan Kondeti , Juri Lelli , Eduardo Valentin , Srinivas Pandruvada , currojerez@riseup.net, Javi Merino Subject: Re: [PATCH v6 13/14] sched/topology: Make Energy Aware Scheduling depend on schedutil Message-ID: <20180910094255.nzjjsiphjplh7ruk@queper01-lin> References: <20180820094420.26590-1-quentin.perret@arm.com> <20180906143842.xlxcg5notwdaflww@queper01-lin> <1545744.fI5ZvP8FO0@aspire.rjw.lan> <20180907152923.oxsmcqciez4yhmkk@queper01-lin> <20180910082411.oyedkqerxs6b7um5@queper01-lin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday 10 Sep 2018 at 10:55:43 (+0200), Rafael J. Wysocki wrote: > On Mon, Sep 10, 2018 at 10:24 AM Quentin Perret wrote: > > > > Hi Rafael, > > > > On Sunday 09 Sep 2018 at 22:13:52 (+0200), Rafael J. Wysocki wrote: > > > On Fri, Sep 7, 2018 at 5:29 PM Quentin Perret wrote: > > > > On Friday 07 Sep 2018 at 10:52:01 (+0200), Rafael J. Wysocki wrote: > > > > > Well, why don't you implement it as something like "if the governor changes > > > > > from sugov to something else (or the other way around), call this function > > > > > from the scheduler"? > > > > > > > > I just gave it a try and ended up with the diff below. It's basically > > > > the exact same patch with a direct function call instead of a notifier. > > > > (I also tried the sugov_start/stop thing I keep mentioning but it is > > > > more complex, so let's see if the simplest solution could work first). > > > > > > > > What do you think ? > > > > > > This generally works for me from the cpufreq perspective, but I would > > > add "cpufreq" to the name of the new function, that is call it > > > something like sched_cpufreq_governor_change(). > > > > Ok, no problem. > > > > > Also do you really need the extra work item? Governor changes are > > > carried out in process context anyway. > > > > Ah, good point, I can remove that. I just tried and got the following > > lock warning on boot, though: > > > > [ 2.518684] ============================================ > > [ 2.523942] WARNING: possible recursive locking detected > > [ 2.529200] 4.18.0-rc6-00086-g940e7a9fd5ec #10 Not tainted > > [ 2.534630] -------------------------------------------- > > [ 2.539888] kworker/2:3/1349 is trying to acquire lock: > > [ 2.545059] (____ptrval____) (cpu_hotplug_lock.rw_sem){++++}, at: rebuild_sched_domains_locked+0x2c/0x598 > > [ 2.554559] > > [ 2.554559] but task is already holding lock: > > [ 2.560332] (____ptrval____) (cpu_hotplug_lock.rw_sem){++++}, at: cpufreq_register_driver+0x80/0x1d0 > > [ 2.569396] > > [ 2.569396] other info that might help us debug this: > > [ 2.575858] Possible unsafe locking scenario: > > [ 2.575858] > > [ 2.581717] CPU0 > > [ 2.584135] ---- > > [ 2.586553] lock(cpu_hotplug_lock.rw_sem); > > [ 2.590785] lock(cpu_hotplug_lock.rw_sem); > > [ 2.595017] > > [ 2.595017] *** DEADLOCK *** > > [ 2.595017] > > [ 2.600877] May be due to missing lock nesting notation > > > > That seems to happen because cpufreq_register_driver() calls > > cpus_read_lock(), which is then called again by rebuild_sched_domains() > > down the line. So it might just be a missing lock nesting notation as > > the warning suggests ? > > > > I'll have a look. > > It only is nested in the _register_driver() code path, otherwise it may not be. Right. > Using the work item may be the most straightforward way to deal with > that, but then I would add a comment to explain what's up. Indeed, rw_sems don't seem to be appropriate for nested locking: https://elixir.bootlin.com/linux/latest/source/include/linux/rwsem.h#L156 I'll stick a comment explaining that for now, unless I find a better idea than using a work item in the meantime. Thanks, Quentin